0

Any ideas on why this doesnt print hey in terminal? Im trying to make a calculator, but first I have to know wether the person know the in game currency (credits) or the real life currency (danish crownes)

import tkinter as tk

root = tk.Tk()

root.geometry('400x400')

ent = tk.Entry(root, fg="blue")
ent.pack()

def submit():
    ent.get()
    

sbmt = tk.Button(root, text="Submit", fg="blue", command=submit)
sbmt.pack()


if sbmt == "credits":
    print("hey")


root.mainloop()
1
  • You aren't doing anything with the result when you do ent.get(). I think you should store that in a variable. Commented Feb 19, 2021 at 18:41

2 Answers 2

4

here: as Seth said:

import tkinter as tk

root = tk.Tk()

root.geometry('400x400')

ent = tk.Entry(root, fg="blue")
ent.pack()

def submit():
    something = ent.get()
    if  something == "credits":
        print("hey")


sbmt = tk.Button(root, text="Submit", fg="blue", command=submit)
sbmt.pack()



root.mainloop()
Sign up to request clarification or add additional context in comments.

Comments

3

sbmt is not the same as "credits". One is a Button, the other is a str. In fact, there is no possible way for the button to do or say anything relating to "credits".

Clarification: Are you trying to see if ent says "credits" inside of it? If so, you need to save ent.get() to a variable.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.