Пример #1
0
 def onMakeCommand(self):
     new = Toplevel()  # a new top-level window
     new.title('Enter Python command')  # arbitrary python code
     frm = frame(new, TOP)
     label(frm, LEFT, '>>>')
     ent = StringVar()
     entry(frm, LEFT, ent)
     button(frm, RIGHT, 'Run', lambda s=self, e=ent: s.onCommand(e))
 def onMakeCommand(self):                       
     new = Toplevel()                      # a new top-level window
     new.title('Enter Python command')     # arbitrary python code
     frm = frame(new, TOP)
     label(frm, LEFT, '>>>')
     ent = StringVar() 
     entry(frm, LEFT, ent)
     button(frm, RIGHT, 'Run', lambda s=self, e=ent: s.onCommand(e))
Пример #3
0
    def makeWidgets(self):  # 7 frames plus text-entry
        entry(self, TOP, self.text)
        rows = ["abcd", "0123", "4567", "89()"]
        i = 0
        frm = frame(self, TOP)
        for row in rows:
            j = 0
            for char in row:
                b = Button(frm,
                           text=char,
                           command=(lambda x=self, y=char: x.onOperand(y)))
                b.grid(row=i, column=j, sticky=N + S + E + W)
                j = j + 1
            i = i + 1

        frm = frame(self, TOP)
        for char in "+-*/=":
            button(frm, LEFT, char, lambda x=self, y=char: x.onOperator(y))

        frm = frame(self, TOP)
        button(frm, LEFT, 'cmd', self.onMakeCommand)
        button(frm, LEFT, 'dot', lambda x=self: x.onOperand('.'))
        button(frm, LEFT, 'help', self.help)
        button(frm, LEFT, 'quit', self.quit)  # from guimixin

        frm = frame(self, BOTTOM)
        button(frm, LEFT, 'eval', self.onEval)
        button(frm, LEFT, 'clear', self.onClear)
    def makeWidgets(self):                        # 7 frames plus text-entry
        entry(self, TOP, self.text)
        rows = ["abcd", "0123", "4567", "89()"]
        i = 0
        frm = frame(self, TOP)
        for row in rows:
            j = 0
            for char in row: 
                b = Button(frm, 
                       text=char, 
                       command=(lambda x=self, y=char: x.onOperand(y)))
                b.grid(row=i,column=j, sticky=N+S+E+W)
                j = j+1
            i = i+1

        frm = frame(self, TOP)
        for char in "+-*/=": button(frm, LEFT, char,
                               lambda x=self, y=char: x.onOperator(y))

        frm = frame(self, TOP)
        button(frm, LEFT, 'cmd',  self.onMakeCommand) 
        button(frm, LEFT, 'dot',  lambda x=self: x.onOperand('.')) 
        button(frm, LEFT, 'help', self.help) 
        button(frm, LEFT, 'quit', self.quit)       # from guimixin

        frm = frame(self, BOTTOM)
        button(frm, LEFT, 'eval',  self.onEval)
        button(frm, LEFT, 'clear', self.onClear)