I get a syntax error for "root = Tk()" and can't figure it out. I am running Python 3.12 under Windows 11. Here is the code:
Update!
I discovered that copying the program text and pasting it into the interpreter was causing the error. When I opened the file in a Python shell and ran it, the error does not occur. Duh!
>>> from tkinter import* >>> import tkinter.filedialog, os, time, socket, binascii >>> >>> UDP_PORT = 50000 >>> sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) >>> >>> # ---------------------------------- >>> # User Interface >>> #------------------------------------ >>> def close(): ... sock.close() ... root.destroy() ... root.quit() ... ... root = Tk() File "<stdin>", line 6 root = Tk() ^^^^ SyntaxError: invalid syntax >>> root.title('Bootloader 2.1') Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'root' is not definedI am not a Python programmer, so have looked around. All instances I found show root = Tk() working just fine. Help will be appreciated!
Update!
I discovered that copying the program text and pasting it into the interpreter was causing the error. When I opened the file in a Python shell and ran it, the error does not occur. Duh!
Larz60+ write Jan-25-2024, 11:31 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.
Code modified for you this time. please use BBCode tags on future posts.
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.
Code modified for you this time. please use BBCode tags on future posts.