Feb-09-2025, 08:25 AM
(This post was last modified: Feb-09-2025, 08:42 AM by Gribouillis.)
(Dec-20-2018, 07:59 PM)ady1583 Wrote: Hello Everyone, i am stuck at the multiply function using Tkinter, any help is greatly appreciated. Addition seems to be fine.
for the multiplication, I have corrected the mistake you made.
see below the full working code.
from tkinter import * root=Tk() def calc_sum(event): num1 = float(num1Entry.get()) num2 = float(num2Entry.get()) sum = num1 + num2 sumTotalEntry.grid(row=0,column=4) sumTotalEntry.insert(0,sum) def multiply_num(event): num3= float(mul1Entry.get()) num4= float(mul2Entry.get()) mul= (num3) * (num4) #mulTotalEntry.delete(0,mul) mulTotalEntry.grid(row=1,column=4) mulTotalEntry.insert(0,mul) numm1 = DoubleVar() numm2 = DoubleVar() numm3 = DoubleVar() numm4 = DoubleVar() num1Entry = Entry(root,textvariable=numm1) num1Entry.grid(row=0) plusLabel = Label(root,text="+",font=("Verdana",8)) plusLabel.grid(row=0,column=1) num2Entry = Entry(root,textvariable=numm2) num2Entry.grid(row=0,column=2) equalButton=Button(root,text="=",font=("Verdana",8)) equalButton.bind('<Button-1>',calc_sum) equalButton.grid(row=0,column=3) sumTotalEntry=Entry(root) sumTotalEntry.grid(row=0,column=4) mul1Entry = Entry(root,textvariable=numm3) mul1Entry.grid(row=1) mulLabel = Label(root,text="*",font=("Verdana",8)) mulLabel.grid(row=1,column=1) mul2Entry = Entry(root,textvariable=numm4) mul2Entry.grid(row=1,column=2) equalButton2=Button(root,text="=",font=("Verdana",8)) equalButton2.bind('<Button-1>',multiply_num) equalButton2.grid(row=1,column=3) mulTotalEntry=Entry(root) mulTotalEntry.grid(row=1,column=4) root.mainloop()
Gribouillis write Feb-09-2025, 08:42 AM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.