is there anyway to make this shorter? i hate having these big blocks
of similar-looking code, very unaesthetic.
maybe doesnt matter good-code-wise?
anyway can i make some function that makes this shorter?
like put the etiquettes on the button froma string of
'123+456-789*0Cr/' ?
problem is the command and lambda-func for each button is different.
self.btnDisplay = Button(self,tex t='1',command=l ambda
n="1":self.Disp lay(n),width=2, height=2)
self.btnDisplay .grid(row=3, column=0)
self.btnDisplay = Button(self,tex t='2',command=l ambda
n="2":self.Disp lay(n),width=2, height=2)
self.btnDisplay .grid(row=3, column=1)
self.btnDisplay = Button(self,tex t='3',command=l ambda
n="3":self.Disp lay(n),width=2, height=2)
self.btnDisplay .grid(row=3, column=2)
self.btnDisplay = Button(self,tex t='+',command=l ambda
n="+":self.Disp lay(n),width=2, height=2)
self.btnDisplay .grid(row=3, column=3)
self.btnDisplay = Button(self,tex t='4',command=l ambda
n="4":self.Disp lay(n),width=2, height=2)
self.btnDisplay .grid(row=4, column=0)
self.btnDisplay = Button(self,tex t='5',command=l ambda
n="5":self.Disp lay(n),width=2, height=2)
self.btnDisplay .grid(row=4, column=1)
self.btnDisplay = Button(self,tex t='6',command=l ambda
n="6":self.Disp lay(n),width=2, height=2)
self.btnDisplay .grid(row=4, column=2)
self.btnDisplay = Button(self,tex t='-',command=lambd a
n="-":self.Display( n),width=2,heig ht=2)
self.btnDisplay .grid(row=4, column=3)
self.btnDisplay = Button(self,tex t='7',command=l ambda
n="7":self.Disp lay(n),width=2, height=2)
self.btnDisplay .grid(row=5, column=0)
self.btnDisplay = Button(self,tex t='8',command=l ambda
n="8":self.Disp lay(n),width=2, height=2)
self.btnDisplay .grid(row=5, column=1)
self.btnDisplay = Button(self,tex t='9',command=l ambda
n="9":self.Disp lay(n),width=2, height=2)
self.btnDisplay .grid(row=5, column=2)
self.btnDisplay = Button(self,tex t='*',command=l ambda
n="*":self.Disp lay(n),width=2, height=2)
self.btnDisplay .grid(row=5, column=3)
self.btnDisplay = Button(self,tex t='0',command=l ambda
n="0":self.Disp lay(n),width=2, height=2)
self.btnDisplay .grid(row=6, column=0)
self.btnDisplay =
Button(self,tex t='C',command=s elf.Clean,width =2,height=2)
self.btnDisplay .grid(row=6, column=1)
self.btnDisplay = Button(self,tex t='r',command=l ambda
n="r":self.Disp lay(n),width=2, height=2)
self.btnDisplay .grid(row=6, column=2)
self.btnDisplay = Button(self,tex t='/',command=lambd a
n="/":self.Display( n),width=2,heig ht=2)
self.btnDisplay .grid(row=6, column=3)
of similar-looking code, very unaesthetic.
maybe doesnt matter good-code-wise?
anyway can i make some function that makes this shorter?
like put the etiquettes on the button froma string of
'123+456-789*0Cr/' ?
problem is the command and lambda-func for each button is different.
self.btnDisplay = Button(self,tex t='1',command=l ambda
n="1":self.Disp lay(n),width=2, height=2)
self.btnDisplay .grid(row=3, column=0)
self.btnDisplay = Button(self,tex t='2',command=l ambda
n="2":self.Disp lay(n),width=2, height=2)
self.btnDisplay .grid(row=3, column=1)
self.btnDisplay = Button(self,tex t='3',command=l ambda
n="3":self.Disp lay(n),width=2, height=2)
self.btnDisplay .grid(row=3, column=2)
self.btnDisplay = Button(self,tex t='+',command=l ambda
n="+":self.Disp lay(n),width=2, height=2)
self.btnDisplay .grid(row=3, column=3)
self.btnDisplay = Button(self,tex t='4',command=l ambda
n="4":self.Disp lay(n),width=2, height=2)
self.btnDisplay .grid(row=4, column=0)
self.btnDisplay = Button(self,tex t='5',command=l ambda
n="5":self.Disp lay(n),width=2, height=2)
self.btnDisplay .grid(row=4, column=1)
self.btnDisplay = Button(self,tex t='6',command=l ambda
n="6":self.Disp lay(n),width=2, height=2)
self.btnDisplay .grid(row=4, column=2)
self.btnDisplay = Button(self,tex t='-',command=lambd a
n="-":self.Display( n),width=2,heig ht=2)
self.btnDisplay .grid(row=4, column=3)
self.btnDisplay = Button(self,tex t='7',command=l ambda
n="7":self.Disp lay(n),width=2, height=2)
self.btnDisplay .grid(row=5, column=0)
self.btnDisplay = Button(self,tex t='8',command=l ambda
n="8":self.Disp lay(n),width=2, height=2)
self.btnDisplay .grid(row=5, column=1)
self.btnDisplay = Button(self,tex t='9',command=l ambda
n="9":self.Disp lay(n),width=2, height=2)
self.btnDisplay .grid(row=5, column=2)
self.btnDisplay = Button(self,tex t='*',command=l ambda
n="*":self.Disp lay(n),width=2, height=2)
self.btnDisplay .grid(row=5, column=3)
self.btnDisplay = Button(self,tex t='0',command=l ambda
n="0":self.Disp lay(n),width=2, height=2)
self.btnDisplay .grid(row=6, column=0)
self.btnDisplay =
Button(self,tex t='C',command=s elf.Clean,width =2,height=2)
self.btnDisplay .grid(row=6, column=1)
self.btnDisplay = Button(self,tex t='r',command=l ambda
n="r":self.Disp lay(n),width=2, height=2)
self.btnDisplay .grid(row=6, column=2)
self.btnDisplay = Button(self,tex t='/',command=lambd a
n="/":self.Display( n),width=2,heig ht=2)
self.btnDisplay .grid(row=6, column=3)
Comment