└── calculator.py /calculator.py: -------------------------------------------------------------------------------- 1 | from tkinter import Tk, Entry, Button, StringVar 2 | 3 | class Calculator: 4 | def__init__(self,master): 5 | master.title("Calculator") 6 | master.geometry('357x420+0+0') 7 | master.config(bg='gray') 8 | master.resizable(False,False) 9 | 10 | 11 | self.equation=StringVar() 12 | self.entry_value='' 13 | Entry(width=17, bg='#fff', font=('Arial Bold', 28), textvariable=self.equation).place(x=0, y=0) 14 | 15 | Button(width=11, height=4, text='', relief='flat', bg='#fff', command=lambda:self.show('')).place(x= , y= ) 16 | Button(width=11, height=4, text='', relief='flat', bg='#fff', command=lambda:self.show('')).place(x= , y= ) 17 | Button(width=11, height=4, text='', relief='flat', bg='#fff', command=lambda:self.show('')).place(x= , y= ) 18 | Button(width=11, height=4, text='', relief='flat', bg='#fff', command=lambda:self.show('')).place(x= , y= ) 19 | Button(width=11, height=4, text='', relief='flat', bg='#fff', command=lambda:self.show('')).place(x= , y= ) 20 | Button(width=11, height=4, text='', relief='flat', bg='#fff', command=lambda:self.show('')).place(x= , y= ) 21 | Button(width=11, height=4, text='', relief='flat', bg='#fff', command=lambda:self.show('')).place(x= , y= ) 22 | Button(width=11, height=4, text='', relief='flat', bg='#fff', command=lambda:self.show('')).place(x= , y= ) 23 | Button(width=11, height=4, text='', relief='flat', bg='#fff', command=lambda:self.show('')).place(x= , y= ) 24 | Button(width=11, height=4, text='', relief='flat', bg='#fff', command=lambda:self.show('')).place(x= , y= ) 25 | Button(width=11, height=4, text='', relief='flat', bg='#fff', command=lambda:self.show('')).place(x= , y= ) 26 | Button(width=11, height=4, text='', relief='flat', bg='#fff', command=lambda:self.show('')).place(x= , y= ) 27 | Button(width=11, height=4, text='', relief='flat', bg='#fff', command=lambda:self.show('')).place(x= , y= ) 28 | Button(width=11, height=4, text='', relief='flat', bg='#fff', command=lambda:self.show('')).place(x= , y= ) 29 | Button(width=11, height=4, text='', relief='flat', bg='#fff', command=lambda:self.show('')).place(x= , y= ) 30 | Button(width=11, height=4, text='', relief='flat', bg='#fff', command=lambda:self.show('')).place(x= , y= ) 31 | 32 | def show(self, value): 33 | self.entry_value+=str(value) 34 | self.equation.set(self.entry_value) 35 | 36 | def clear(self): 37 | self.entry_value='' 38 | self.equation.set(self.entry_value) 39 | 40 | 41 | def solve(self): 42 | result=eval(self.entry-value) 43 | self.equation.set(result) 44 | 45 | root=Tk() 46 | calculator=Calculator(root) 47 | root.mainloop() --------------------------------------------------------------------------------