Page 50 - Phyton_GUIprogrammingwithTkinter
P. 50
P a ge | 41
labelResultSub = tk.Label(root, text= float(v1)-float(v2),font=('helvetica', 10, 'bold'),bg='white')
canvas.create_window(210, 240, window=labelResultSub)
buttonSub = tk.Button(text='–', command=sub, bg='blue', fg='white', font=('helvetica', 9, 'bold'),
width = 5)
canvas.create_window(140, 190, window=buttonSub)
def mul ():
v1 = entry1.get ()
v2 = entry2.get ()
labelResultMul = tk.Label(root, text= float(v1)*float(v2),font=('helvetica', 10, 'bold'),bg='white')
canvas.create_window(210, 240, window=labelResultMul)
buttonMul = tk.Button(text='x', command=mul, bg='blue', fg='white', font=('helvetica', 9, 'bold'),
width = 5)
canvas.create_window(190, 190, window=buttonMul)
def div ():
v1 = entry1.get ()
v2 = entry2.get ()
labelResultDiv = tk.Label(root, text= float(v1)/float(v2),font=('helvetica', 10, 'bold'),bg='white')
canvas.create_window(210, 240, window=labelResultDiv)
buttonDiv = tk.Button(text='/', command=div, bg='blue', fg='white', font=('helvetica', 9, 'bold'), width
= 5)
canvas.create_window(240, 190, window=buttonDiv)
root.mainloop()