Answer the question
In order to leave comments, you need to log in
How to overcome the "name is not defined" error?
I am creating a program where there will be a window in which the user writes text, and then presses the "Enter" button, and everything that he wrote is sent to me in the cart.
The code:
#telegram
telegram_send.send( messages = ut )
#stiles
root = Tk()
root.title('Kontra')
root.wm_attributes('-alpha', 1.0)
root.geometry('1000x1000')
root.resizable(width=True, height=True)
root[ 'bg' ] = '#ccc'
#to-text
user_text = Entry( root, font = 'Consolas', relief = 'solid',
bg = 'silver')
#command
def conn():
ut = user_text.get()
btn = Button( text = 'Войти', command = conn )
user_text.pack()
btn.pack()
telegram_send.send( messages = ut )
NameError: name 'ut' is not defined
Answer the question
In order to leave comments, you need to log in
1. For the interface to work, you need to run a loop (mainloop)
...
btn.pack()
root.mainloop()
def conn():
ut = user_text.get()
root.destroy()
telegram_send.send( messages = ut )
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question