Exemplo n.º 1
0
 def makeWidgets(self, *args):
     label(self, TOP, 'PyCalc Plus - Subclass')
     CalcGui.makeWidgets(self, *args)
     frm = frame(self, BOTTOM)
     extras = [('sqrt', 'sqrt(%s)'), ('x^2 ', '(%s)**2'),
               ('x^3 ', '(%s)**3'), ('1/x ', '1.0/(%s)')]
     for (lab, expr) in extras:
         button(frm, LEFT, lab, (lambda expr=expr: self.onExtra(expr)))
     button(frm, LEFT, ' pi ', self.onPi)
 def makeWidgets(self, *args):
     label(self, TOP, 'PyCalc Plus - Subclass')
     CalcGui.makeWidgets(self, *args)
     frm = frame(self, BOTTOM)
     extras = [('sqrt', 'sqrt(%s)'),
               ('x^2 ', '(%s)**2'),
               ('x^3 ', '(%s)**3'),
               ('1/x ', '1.0/(%s)')]
     for (lab, expr) in extras:
         button(frm, LEFT, lab, (lambda expr=expr: self.onExtra(expr)))
     button(frm, LEFT, ' pi ', self.onPi)
Exemplo n.º 3
0
def calcContainer(parent=None):
    frm = Frame(parent)
    frm.pack(expand=YES, fill=BOTH)
    Label(frm, text='Calc Container').pack(side=TOP)
    CalcGui(frm)
    Label(frm, text='Calc Container').pack(side=BOTTOM)
    return frm
Exemplo n.º 4
0
 def __init__(self, **args):
     Toplevel.__init__(self)
     label(self, TOP, 'PyCalc Plus - Container')
     self.calc = CalcGui(self, **args)
     frm = frame(self, BOTTOM)
     extras = [('sqrt', 'sqrt(%s)'), ('x^2 ', '(%s)**2'),
               ('x^3 ', '(%s)**3'), ('1/x ', '1.0/(%s)')]
     for (lab, expr) in extras:
         button(frm, LEFT, lab, (lambda expr=expr: self.onExtra(expr)))
     button(frm, LEFT, ' pi ', self.onPi)
Exemplo n.º 5
0
 def makeWidgets(self, fg, bg, font):
     Label(self, text='Calc Subclass').pack(side=TOP)
     Label(self, text='Calc Subclass').pack(side=BOTTOM)
     CalcGui.makeWidgets(self, fg, bg, font)
Exemplo n.º 6
0
    frm.pack(expand=YES, fill=BOTH)
    Label(frm, text='Calc Container').pack(side=TOP)
    CalcGui(frm)
    Label(frm, text='Calc Container').pack(side=BOTTOM)
    return frm


class calcSubclass(CalcGui):
    def makeWidgets(self, fg, bg, font):
        Label(self, text='Calc Subclass').pack(side=TOP)
        Label(self, text='Calc Subclass').pack(side=BOTTOM)
        CalcGui.makeWidgets(self, fg, bg, font)
        #Label(self, text='Calc Subclass').pack(side=BOTTOM)


if __name__ == '__main__':
    import sys
    if len(sys.argv) == 1:  # % calculator_test.py
        root = Tk()  # run 3 calcs in same process
        CalcGui(Toplevel())  # each in a new toplevel window
        calcContainer(Toplevel())
        calcSubclass(Toplevel())
        Button(root, text='quit', command=root.quit).pack()
        root.mainloop()
    if len(sys.argv) == 2:  # % calculator_testl.py -
        CalcGui().mainloop()  # as a standalone window (default root)
    elif len(sys.argv) == 3:  # % calculator_test.py - -
        calcContainer().mainloop()  # as an embedded component
    elif len(sys.argv) == 4:  # % calculator_test.py - - -
        calcSubclass().mainloop()  # as a customized superclass
 def makeWidgets(self, fg, bg, font):
     Label(self, text='Calc Subclass').pack(side=TOP)
     Label(self, text='Calc Subclass').pack(side=BOTTOM)
     CalcGui.makeWidgets(self, fg, bg, font)