def __init__(self, parent=None):  # an extended frame
        Frame.__init__(self, parent)  # on default top-level
        self.pack(expand=YES, fill=BOTH)  # all parts expandable

        self.names = {}  # namespace for variables
        text = StringVar()
        entry(self, TOP, text)

        rows = ["abcd", "0123", "4567", "89()"]
        for row in rows:
            frm = frame(self, TOP)
            for char in row:
                button(frm,
                       LEFT,
                       char,
                       lambda x=text, y=char: x.set(x.get() + y))

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

        frm = frame(self, BOTTOM)
        button(frm, LEFT, 'eval', lambda x=self, y=text: x.eval(y))
        button(frm, LEFT, 'clear', lambda x=text: x.set(''))
    def __init__(self):                                # an extended frame
        Frame.__init__(self)                           # on default top-level
        self.pack(expand=YES, fill=BOTH)               # all parts expandable
        self.master.title('Python Calculator 0.1')     # 6 frames plus entry
        self.master.iconname("pcalc1")

        self.names = {}                                # namespace for variables
        text = StringVar()
        entry(self, TOP, text)

        rows = ["abcd", "0123", "4567", "89()"]
        for row in rows:
            frm = frame(self, TOP)
            for char in row: OperandButton(frm, text, char)

        frm = frame(self, TOP)
        for char in "+-*/=": OperandButton(frm, text, char)

        frm = frame(self, BOTTOM)
        button(frm, LEFT, 'eval',  lambda x=self, y=text: x.eval(y) )
        button(frm, LEFT, 'clear', lambda x=text: x.set('') )
Beispiel #3
0
    def __init__(self):  # an extended frame
        Frame.__init__(self)  # on default top-level
        self.pack(expand=YES, fill=BOTH)  # all parts expandable
        self.master.title('Python Calculator 0.1')  # 6 frames plus entry
        self.master.iconname("pcalc1")

        self.names = {}  # namespace for variables
        text = StringVar()
        entry(self, TOP, text)

        rows = ["abcd", "0123", "4567", "89()"]
        for row in rows:
            frm = frame(self, TOP)
            for char in row:
                OperandButton(frm, text, char)

        frm = frame(self, TOP)
        for char in "+-*/=":
            OperandButton(frm, text, char)

        frm = frame(self, BOTTOM)
        button(frm, LEFT, 'eval', lambda x=self, y=text: x.eval(y))
        button(frm, LEFT, 'clear', lambda x=text: x.set(''))
    def __init__(self, parent=None):                   # an extended frame
        Frame.__init__(self, parent)                   # on default top-level
        self.pack(expand=YES, fill=BOTH)               # all parts expandable

        self.names = {}                                # namespace for variables
        text = StringVar()
        entry(self, TOP, text)

        rows = ["abcd", "0123", "4567", "89()"]
        for row in rows:
            frm = frame(self, TOP)
            for char in row: button(frm, LEFT, char, 
                               lambda x=text, y=char: x.set(x.get() + y))

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

        frm = frame(self, BOTTOM)
        button(frm, LEFT, 'eval',  lambda x=self, y=text: x.eval(y) )
        button(frm, LEFT, 'clear', lambda x=text: x.set('') )
    def __init__(self):  # an extended frame
        Frame.__init__(self)  # on default top-level
        self.pack(expand=YES, fill=BOTH)  # all parts expandable
        self.master.title("Python Calculator 0.1")  # 6 frames plus entry
        self.master.iconname("pcalc1")

        self.names = {}  # namespace for variables
        text = StringVar()
        entry(self, TOP, text)
        rows = ["abcd", "0123", "4567", "89()"]
        for row in rows:
            frm = frame(self, TOP)
            for char in row:
                button(frm, LEFT, char, lambda x=text, y=char: x.set(x.get() + y))

        frm = frame(self, RIGHT)
        for char in "+-*/=":
            button(frm, TOP, char, lambda x=text, y=char: x.set(x.get() + " " + y + " "))

        frm = frame(self, BOTTOM)
        button(frm, LEFT, "eval", lambda x=self, y=text: x.eval(y))
        button(frm, RIGHT, "clear", lambda x=text: x.set(""))
 def makeMainBox(self):
     frm = frame(self, TOP)
     frm.config(bd=2)
     button(frm, LEFT, 'next',  self.onNext)       # next in list
     button(frm, LEFT, 'prev',  self.onPrev)       # backup in list
     button(frm, LEFT, 'find',  self.onFind)       # find from key
     frm = frame(self, TOP)
     self.keytext = StringVar()                    # current record's key
     label(frm, LEFT, 'KEY=>')                     # change before 'find'
     entry(frm, LEFT,  self.keytext)             
     frm = frame(self, TOP)
     frm.config(bd=2)
     button(frm,  LEFT,  'store',  self.onStore)     # updated entry data
     button(frm,  LEFT,  'new',    self.onNew)       # clear fields
     button(frm,  LEFT,  'index',  self.onMakeList)  # show key list
     button(frm,  LEFT,  'delete', self.onDelete)    # show key list
     button(self, BOTTOM,'quit',   self.quit)        # from guimixin
 def makeMainBox(self):
     frm = frame(self, TOP)
     frm.config(bd=2)
     button(frm, LEFT, 'next', self.onNext)  # next in list
     button(frm, LEFT, 'prev', self.onPrev)  # backup in list
     button(frm, LEFT, 'find', self.onFind)  # find from key
     frm = frame(self, TOP)
     self.keytext = StringVar()  # current record's key
     label(frm, LEFT, 'KEY=>')  # change before 'find'
     entry(frm, LEFT, self.keytext)
     frm = frame(self, TOP)
     frm.config(bd=2)
     button(frm, LEFT, 'store', self.onStore)  # updated entry data
     button(frm, LEFT, 'new', self.onNew)  # clear fields
     button(frm, LEFT, 'index', self.onMakeList)  # show key list
     button(frm, LEFT, 'delete', self.onDelete)  # show key list
     button(self, BOTTOM, 'quit', self.quit)  # from guimixin