from Tkinter import class SimpleCalc Frame def __init__ self master Fr

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
from Tkinter import *
class SimpleCalc( Frame ):
def __init__( self, master ):
Frame.__init__( self, master )
self.grid()
self.create_widgets()
def create_widgets( self ):
# Create three buttons. Note how each one is setup slightly different.
# Create the first button...
self.bttn1 = Button( self, text = "Button #1", command = c_bttn)
self.bttn1.grid()
# Create the second button...
self.bttn2 = Button( self,text= "Button #2")
self.bttn2.grid_configure(column=1,row=0)
# Create the third button...
self.bttn3 = Button( self,text= "Button #3")
self.bttn3.grid_configure(column=2,row=0)
#self.bttn3["text"] = "Button #3"
self.bttn4 = Button( self,text= "Button #4")
self.bttn4.grid_configure(column=0,row=1)
self.bttn5 = Button( self,text= "Button #5")
self.bttn5.grid_configure(column=1,row=1)
self.bttn6 = Button( self,text= "Button #6")
self.bttn6.grid_configure(column=2,row=1)
self.bttn7 = Button( self,text= "Button #7")
self.bttn7.grid_configure(column=0,row=2)
self.bttn8 = Button( self,text= "Button #8")
self.bttn8.grid_configure(column=1,row=2)
self.bttn9 = Button( self,text= "Button #9")
self.bttn9.grid_configure(column=2,row=2)
self.bttn0 = Button( self,text= "Button #0")
self.bttn0.grid_configure(column=1,row=3)
myLabel = Label( root, text = "0" )
myLabel.grid()
myText = Text(width=20,height=1)
myText.grid()
def c_bttn():
SimpleCalc.create_widgets.myText.insert(END, '1')
if __name__ == '__main__':
root = Tk()
root.title( "SimpleCalc" )
root.geometry( "300x300" )
myApp = SimpleCalc( root )
root.mainloop()