Python Forum
Multiply function using Tkinter
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Multiply function using Tkinter
#7
(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.
Reply


Messages In This Thread
Multiply function using Tkinter - by ady1583 - Dec-20-2018, 07:59 PM
RE: Multiply function using Tkinter - by ichabod801 - Dec-20-2018, 08:05 PM
RE: Multiply function using Tkinter - by Larz60+ - Dec-20-2018, 11:48 PM
RE: Multiply function using Tkinter - by ady1583 - Dec-21-2018, 02:37 PM
RE: Multiply function using Tkinter - by ichabod801 - Dec-21-2018, 02:51 PM
RE: Multiply function using Tkinter - by buran - Dec-21-2018, 02:59 PM
RE: Multiply function using Tkinter - by frankjoesmith - Feb-09-2025, 08:25 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Using Tkinter inside function not working Ensaimadeta 5 8,854 Dec-03-2023, 01:50 PM
Last Post: deanhystad
  Tkinter won't run my simple function AthertonH 6 6,945 May-03-2022, 02:33 PM
Last Post: deanhystad
  [Tkinter] tkinter best way to pass parameters to a function Pedroski55 3 7,518 Nov-17-2021, 03:21 AM
Last Post: deanhystad
  Creating a function interrupt button tkinter AnotherSam 2 8,684 Oct-07-2021, 02:56 PM
Last Post: AnotherSam
  [Tkinter] Have tkinter button toggle on and off a continuously running function AnotherSam 5 7,920 Oct-01-2021, 05:00 PM
Last Post: Yoriz
  tkinter get function finndude 2 4,025 Mar-02-2021, 03:53 PM
Last Post: finndude
  tkinter -- after() method and return from function -- (python 3) Nick_tkinter 12 13,461 Feb-20-2021, 10:26 PM
Last Post: Nick_tkinter
  function in new window (tkinter) Dale22 7 8,615 Nov-24-2020, 11:28 PM
Last Post: Dale22
Star [Tkinter] How to perform math function in different page of Tkinter GUI ravaru 2 5,828 Oct-23-2020, 05:46 PM
Last Post: deanhystad
  Call local variable of previous function from another function with Python3 & tkinter Hannibal 5 6,126 Oct-12-2020, 09:16 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020