@@ -6,89 +6,93 @@ class calculate():
6
6
def __init__ (self ):
7
7
self .root = Tk ()
8
8
self .root .title ("Calculator" )
9
- self .root .geometry ("370x220 " )
9
+ self .root .geometry ("290x260 " )
10
10
11
- self .resultwindow = Entry (self .root )
12
- self .resultwindow .grid (row = 0 ,column = 0 ,columnspan = 6 )
11
+ self .root .maxsize (290 , 260 )
12
+ self .root .minsize (290 , 260 )
13
+ self .root .config (bg = "grey" )
14
+
15
+ self .resultwindow = Entry (self .root ,borderwidth = 5 , relief = SUNKEN )
16
+ self .resultwindow .grid (row = 0 ,column = 0 ,columnspan = 6 ,pady = 5 )
13
17
self .resultwindow .config (font = ("Arial" , 18 ))
14
18
self .resultwindow .focus_set () # Sets focus on the input text area
15
19
16
20
# Buttons
17
- self .button1 = Button (self .root , text = "1" , width = 3 , command = lambda :self .ins ('1' ))
21
+ self .button1 = Button (self .root , text = "1" , width = 3 , command = lambda :self .ins ('1' ), relief = RAISED , bg = 'light green' )
18
22
self .button1 .grid (row = 1 ,column = 0 , padx = 3 , pady = 3 )
19
23
self .button1 .config (font = ("Arial" , 18 ))
20
24
21
- self .button2 = Button (self .root , text = "2" , width = 3 , command = lambda :self .ins ('2' ))
25
+ self .button2 = Button (self .root , text = "2" , width = 3 , command = lambda :self .ins ('2' ), relief = RAISED , bg = 'light green' )
22
26
self .button2 .grid (row = 1 , column = 1 , padx = 3 , pady = 3 )
23
27
self .button2 .config (font = ("Arial" , 18 ))
24
28
25
- self .button3 = Button (self .root , text = "3" , width = 3 , command = lambda :self .ins ('3' ))
29
+ self .button3 = Button (self .root , text = "3" , width = 3 , command = lambda :self .ins ('3' ), relief = RAISED , bg = 'light green' )
26
30
self .button3 .grid (row = 1 , column = 2 , padx = 3 , pady = 3 )
27
31
self .button3 .config (font = ("Arial" , 18 ))
28
32
29
- self .button4 = Button (self .root , text = "4" , width = 3 , command = lambda :self .ins ('4' ))
33
+ self .button4 = Button (self .root , text = "4" , width = 3 , command = lambda :self .ins ('4' ), relief = RAISED , bg = 'light green' )
30
34
self .button4 .grid (row = 2 , column = 0 , padx = 3 , pady = 3 )
31
35
self .button4 .config (font = ("Arial" , 18 ))
32
36
33
- self .button5 = Button (self .root , text = "5" , width = 3 , command = lambda :self .ins ('5' ))
37
+ self .button5 = Button (self .root , text = "5" , width = 3 , command = lambda :self .ins ('5' ), relief = RAISED , bg = 'light green' )
34
38
self .button5 .grid (row = 2 , column = 1 , padx = 3 , pady = 3 )
35
39
self .button5 .config (font = ("Arial" , 18 ))
36
40
37
- self .button6 = Button (self .root , text = "6" , width = 3 , command = lambda :self .ins ('6' ))
41
+ self .button6 = Button (self .root , text = "6" , width = 3 , command = lambda :self .ins ('6' ), relief = RAISED , bg = 'light green' )
38
42
self .button6 .grid (row = 2 , column = 2 , padx = 3 , pady = 3 )
39
43
self .button6 .config (font = ("Arial" , 18 ))
40
44
41
- self .button7 = Button (self .root , text = "7" , width = 3 , command = lambda :self .ins ('7' ))
45
+ self .button7 = Button (self .root , text = "7" , width = 3 , command = lambda :self .ins ('7' ), relief = RAISED , bg = 'light green' )
42
46
self .button7 .grid (row = 3 , column = 0 , padx = 3 , pady = 3 )
43
47
self .button7 .config (font = ("Arial" , 18 ))
44
48
45
- self .button8 = Button (self .root , text = "8" , width = 3 , command = lambda :self .ins ('8' ))
49
+ self .button8 = Button (self .root , text = "8" , width = 3 , command = lambda :self .ins ('8' ), relief = RAISED , bg = 'light green' )
46
50
self .button8 .grid (row = 3 , column = 1 , padx = 3 , pady = 3 )
47
51
self .button8 .config (font = ("Arial" , 18 ))
48
52
49
- self .button9 = Button (self .root , text = "9" , width = 3 , command = lambda :self .ins ('9' ))
53
+ self .button9 = Button (self .root , text = "9" , width = 3 , command = lambda :self .ins ('9' ), relief = RAISED , bg = 'light green' )
50
54
self .button9 .grid (row = 3 , column = 2 , padx = 3 , pady = 3 )
51
55
self .button9 .config (font = ("Arial" , 18 ))
52
56
53
- self .button0 = Button (self .root , text = "0" , width = 3 , command = lambda : self .ins ('0' ))
57
+ self .button0 = Button (self .root , text = "0" , width = 3 , command = lambda : self .ins ('0' ), relief = RAISED , bg = 'light green' )
54
58
self .button0 .grid (row = 4 , column = 0 , padx = 3 , pady = 3 )
55
59
self .button0 .config (font = ("Arial" , 18 ))
56
60
57
- self .button_open = Button (self .root , text = "(" , width = 3 , command = lambda : self .ins ('(' ))
61
+ self .button_open = Button (self .root , text = "(" , width = 3 , command = lambda : self .ins ('(' ), relief = RAISED )
58
62
self .button_open .grid (row = 4 , column = 1 , padx = 3 , pady = 3 )
59
63
self .button_open .config (font = ("Arial" , 18 ))
60
64
61
- self .button_close = Button (self .root , text = ")" , width = 3 , command = lambda : self .ins (')' ))
65
+ self .button_close = Button (self .root , text = ")" , width = 3 , command = lambda : self .ins (')' ), relief = RAISED )
62
66
self .button_close .grid (row = 4 , column = 2 , padx = 3 , pady = 3 )
63
67
self .button_close .config (font = ("Arial" , 18 ))
64
68
65
69
# Operations Buttons
66
70
67
- self .buttonplus = Button (self .root , text = "+" , width = 3 , command = lambda :self .ins ('+' ))
71
+ self .buttonplus = Button (self .root , text = "+" , width = 3 , command = lambda :self .ins ('+' ), relief = RAISED )
68
72
self .buttonplus .grid (row = 1 , column = 3 , padx = 3 , pady = 3 )
69
73
self .buttonplus .config (font = ("Arial" , 18 ))
70
74
71
- self .buttonminus = Button (self .root , text = "-" , width = 3 , command = lambda :self .ins ('-' ))
75
+ self .buttonminus = Button (self .root , text = "-" , width = 3 , command = lambda :self .ins ('-' ), relief = RAISED )
72
76
self .buttonminus .grid (row = 1 , column = 4 , padx = 3 , pady = 3 )
73
77
self .buttonminus .config (font = ("Arial" , 18 ))
74
78
75
- self .buttondivide = Button (self .root , text = "/" , width = 3 , command = lambda :self .ins ('/' ))
79
+ self .buttondivide = Button (self .root , text = "/" , width = 3 , command = lambda :self .ins ('/' ), relief = RAISED )
76
80
self .buttondivide .grid (row = 2 , column = 3 , padx = 3 , pady = 3 )
77
81
self .buttondivide .config (font = ("Arial" , 18 ))
78
82
79
- self .buttonmultiply = Button (self .root , text = "*" , width = 3 , command = lambda :self .ins ('*' ))
83
+ self .buttonmultiply = Button (self .root , text = "*" , width = 3 , command = lambda :self .ins ('*' ), relief = RAISED )
80
84
self .buttonmultiply .grid (row = 2 , column = 4 , padx = 3 , pady = 3 )
81
85
self .buttonmultiply .config (font = ("Arial" , 18 ))
82
86
83
- self .buttoncancel = Button (self .root , text = "C" , width = 3 , command = lambda : self .cancel ())
87
+ self .buttoncancel = Button (self .root , text = "C" , width = 3 , command = lambda : self .cancel (), relief = RAISED , bg = '#EF5350' , fg = 'white' )
84
88
self .buttoncancel .grid (row = 3 , column = 4 , padx = 3 , pady = 3 )
85
89
self .buttoncancel .config (font = ("Arial" , 18 ))
86
90
87
- self .buttondeleteall = Button (self .root , text = "Del" , width = 3 , command = lambda : self .delete_all ())
91
+ self .buttondeleteall = Button (self .root , text = "Del" , width = 3 , command = lambda : self .delete_all (), relief = RAISED )
88
92
self .buttondeleteall .grid (row = 3 , column = 3 , padx = 3 , pady = 3 )
89
93
self .buttondeleteall .config (font = ("Arial" , 18 ))
90
94
91
- self .buttonresult = Button (self .root , text = "=" , width = 6 , command = lambda :self .calculate ())
95
+ self .buttonresult = Button (self .root , text = "=" , width = 7 , command = lambda :self .calculate (), relief = RAISED , bg = '#FFEE58' )
92
96
self .buttonresult .grid (row = 4 , column = 3 , padx = 3 , pady = 3 , columnspan = 2 )
93
97
self .buttonresult .config (font = ("Arial" , 18 ))
94
98
0 commit comments