Python Forum
Syntax error for "root = Tk()"
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Syntax error for "root = Tk()"
#7
(Jan-26-2024, 06:10 PM)deanhystad Wrote: Can you post the code? What evidence do you have leading you to think it does not work? How do you run the code normally?

On windows, a .pyw file is usually run by double clicking on the file. The "w" in the extension tells python to not open a shell window. Remove the "w" and your program will open two windows (cmd or powershell and the tkinter window). As you discovered, you can also run the program by passing the program file name as an argument when starting python (python myprogram.py).

I remove Python 2 from my computer and reinstalled Python 3.12.1. The converted program will now run from command line and from double-click, but will not talk to the radio.

To shorten this story a bit, after you started asking about why I was typing into the interpreter, I looked around a bit more and found the IDLE. That brought up a shell. Using the shell to open the file, rather than copy and paste from Notepad, the program will run, just still will not talk to the radio. The shell does not report any errors until I click the "Test" button to verify connectivity with the radio. When the "Test" button is clicked, the shell reports an error:

Error:
Exception in Tkinter callback Traceback (most recent call last): File "C:\Program Files\Python312\Lib\tkinter\__init__.py", line 1962, in __call__ return self.func(*args) ^^^^^^^^^^^^^^^^ File "E:\HamStuff\Odyssey\BL2.1\BootLoader_2_1.pyw", line 133, in test_button_clicked MESSAGE = bytearray(b'MAC' + chr(0)*29) # Preparing the message ~~~~~~~^~~~~~~~~~~ TypeError: can't concat str to bytes
This will not mean much without the code.

I have attempted to attach the file. If that did not work, I can post it in a reply or as an e-mail.
.pyw   BootLoader_2_1.pyw (Size: 16.53 KB / Downloads: 23)
Reply


Messages In This Thread
Syntax error for "root = Tk()" - by dlwaddel - Jan-25-2024, 02:40 AM
RE: Syntax error for "root = Tk()" - by deanhystad - Jan-25-2024, 05:41 AM
RE: Syntax error for "root = Tk()" - by dlwaddel - Jan-25-2024, 01:25 PM
RE: Syntax error for "root = Tk()" - by deanhystad - Jan-25-2024, 03:43 PM
RE: Syntax error for "root = Tk()" - by dlwaddel - Jan-26-2024, 01:07 PM
RE: Syntax error for "root = Tk()" - by deanhystad - Jan-26-2024, 06:10 PM
RE: Syntax error for "root = Tk()" - by dlwaddel - Jan-27-2024, 02:06 PM
RE: Syntax error for "root = Tk()" - by deanhystad - Jan-27-2024, 03:51 PM
RE: Syntax error for "root = Tk()" - by dlwaddel - Jan-27-2024, 06:42 PM
RE: Syntax error for "root = Tk()" - by deanhystad - Jan-27-2024, 11:37 PM
RE: Syntax error for "root = Tk()" - by dlwaddel - Jan-28-2024, 05:39 PM
RE: Syntax error for "root = Tk()" - by deanhystad - Jan-28-2024, 06:07 PM
RE: Syntax error for "root = Tk()" - by menator01 - Jan-28-2024, 06:47 PM
RE: Syntax error for "root = Tk()" - by dlwaddel - Jan-28-2024, 07:51 PM
RE: Syntax error for "root = Tk()" - by deanhystad - Jan-28-2024, 11:03 PM
RE: Syntax error for "root = Tk()" - by dlwaddel - Jan-29-2024, 12:07 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  is this really a syntax error? Skaperen 4 316 May-25-2024, 07:31 AM
Last Post: snippsat
  World Clock syntax error OscarBoots 1 292 May-03-2024, 05:20 AM
Last Post: snippsat
Photo SYNTAX ERROR Yannko 3 528 Jan-19-2024, 01:20 PM
Last Post: rob101
  Syntax error while executing the Python code in Linux DivAsh 8 1,882 Jul-19-2023, 06:27 PM
Last Post: Lahearle
  Code is returning the incorrect values. syntax error 007sonic 6 1,391 Jun-19-2023, 03:35 AM
Last Post: 007sonic
  syntax error question - string mgallotti 5 1,454 Feb-03-2023, 05:10 PM
Last Post: mgallotti
  Syntax error? I don't see it KenHorse 4 1,412 Jan-15-2023, 07:49 PM
Last Post: Gribouillis
  Syntax error tibbj001 2 1,016 Dec-05-2022, 06:38 PM
Last Post: deanhystad
  Python-for-Android:p4a: syntax error in main.py while compiling apk jttolleson 2 2,023 Sep-17-2022, 04:09 AM
Last Post: jttolleson
  Mysql Syntax error in pymysql ilknurg 4 2,513 May-18-2022, 06:50 AM
Last Post: ibreeden

Forum Jump:

User Panel Messages

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