Python Forum
[Tkinter] Finishing GUI calculator project
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] Finishing GUI calculator project
#2
you should use buttons for entry. You've already got tkinter installed, and buttons will solve a lot of issues.
Also, if you use a class, you won't have to worry about callbacks.
There's a lot missing in your code, and structure isn't correct.
You should look at the docs at least for the widgets that you are using here: https://docs.python.org/3/library/tk.html
for example, you must use either a 'command' attribute, or a bind instruction in order for the button to execute a command.
And you need to 'get' the text value of the Entry widget.

Here's a simple Button example
import tkinter as tk

root = tk.Tk()
root.geometry('100x100+50+50')

def clicked():
    print('Button clicked')

def make_button():
    # notice there is no () after clicked because we want reference to clicked routine,
    # and if () were added, it would be executed immediately
    btn = tk.Button(root, text='Push Me', command=clicked)
    btn.pack()

make_button()

root.mainloop()
Reply


Messages In This Thread
Finishing GUI calculator project - by benybeastboy - Mar-28-2019, 10:12 PM
RE: Finishing GUI calculator project - by Larz60+ - Mar-29-2019, 02:20 AM
RE: Finishing GUI calculator project - by 4096 - Apr-02-2019, 12:05 PM
RE: Finishing GUI calculator project - by kkaur - Feb-26-2021, 04:54 PM

Forum Jump:

User Panel Messages

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