Closed peterbuxton closed 2 years ago
Looking at the actual source code for ALICE 1.3.13 and the Volt Meter tool the lines in question are actually:
if sys.version_info[0] == 2: default_font = tkFont.nametofont("TkDefaultFont") if sys.version_info[0] == 3: default_font = tkinter.font.nametofont("TkDefaultFont") default_font.configure(size=FontSize)
Not what you included above. Please confirm that you are actually using the correct versions of the source code. As you can see there is a test for which version of Python is running 2.X or 3.X and the appropriate syntax is used. The lines in question should look like these.
If fixing the line for the sys.version_info[0] == 3 case does not fix your issue then... Since we don't have access to the exact same OS version you are running we can't debug any differences in how default_font.configure works in your OS.
Whoops, my mistake. The real code in the 1.3.13 files is actually as you showed it. I'm messaging here using a Windows PC, while the apps were in a Linux PC, so I just hand-typed it (incorrectly) to show you the lines that I commented out to make it work. I "mistyped" the fourth line of the sample code from ALICE 1.3.13 in my message above (then copied that to the Volt Meter tool sample). Sorry.
At any rate, I didn't change any code other than commenting those five lines, and that made the error message go away and the modules open properly in my Linux distro. I don't know why the OS version would make a difference in the python app operation. My Linux is using a standard python3 version (with numpy3 added). I'm just reporting it to you in case you are interested.
First just to be clear the issue is with the config(ure) method of the tkinter default font. All the "packages" load it's just that the .configure method seems to be missing or misnamed.
One last thing you might try for me is to change the line: default_font.configure(size=FontSize) to: default_font.config(size=FontSize)
In my version of python (3.X and 2.X) either spelling seems to work. I've noticed that in Python the implementers are not consistent with this usage and sometimes only one or the other spelling works but not both / either.
Anyway, The tk interface documentation for Python online lists it as .config
I tested it for you on my Linux and either of those configure line spellings cause the same error: NameError: name 'tkinter' is not defined So it looks like the configure line is accepted in either spelling and isn't causing the error.
Since on my system commenting out all five lines made it work, I wondered what would happen with only the configure line present. So I commented out the four lines of the if statements and left the fifth line and it gave error: default_font.configure(size=FontSize) NameError: name 'default_font' is not defined
That same error happened with either 'configure' or 'config' spelling. It seems like the word tkinter above that configure line is the main problem but I can't imagine why because you import from tkinter starting at line 57 through 64. The only thing I can think (logically, but not by knowing python) is that at line 441 is the first time I found 'default_font' used, and with 'tkinter' so maybe that means something. Sorry I don't know much about python yet.
I also discovered that the Analog Meter app has the same problem, but also has one additional problem. The statement on line 712 is missing parentheses and causing an error too. I think that error should happen on any system because it violates the python syntax for print( ) statement.
Right the missing ( )'s are probably a hold over from conversion from Python 2.x to 3.x. Not every program example gets the same level of testing on both versions. Thanks for finding that last hold out.
As to why the Python in your OS distribution seems to be missing the font support parts of the tk interface is beyond me. You would think that any distribution of Linux would use all of the official released version.
Anyway, not much Analog Devices can do about that.
As a band-aid I've but an exception around that line in the code so the program will at least continue even if the default font size is not set to the user requested value. This will not prevent the GUI from working just that the text won't be scaled to the User's screen resolution.
I installed source code for libsmu-1.0.4 and Alice -1.3.13 in Slackware Linux version 15.0 with python3.9. I'm using an ADALM1000 with fw 2.17 : hw F. After I got things set up all the Alice modules open except the following two.
Running alice-desktop-1.3.pyw in term window shows: Python 3.x Windowing Sytem is x11 Traceback (most recent call last): File "/home/pete/alice-1.3.13/alice-desktop-1.3.pyw" line 441, in
default_font = tkinter.font.nametofont("tkDefaultFont")
NameError: name 'tkinter' is not defined
Running volt-meter-tool-1.3.pyw in term window shows: Windowing Sytem is x11 Traceback (most recent call last): File "/home/pete/alice-1.3.13/volt-meter-tool-1.3.pyw" line 154, in
default_font = tkinter.font.nametofont("tkDefaultFont")
NameError: name 'tkinter' is not defined
I'm not a python programmer but with some research I traced the trouble in both programs to the section where the code is:
if sys.version_info[0] == 2: default_font = tkFont.nametofont("TkDefaultFont") if sys.version_info[0] == 3: default_font = tkinter.nametofont("TkDefaultFont") default_font.configure(size=FontSize)
By commenting those five lines, both modules now open from the command line in a term window. I've also had this problem with previous versions of alice modules. Analog Devices Inc. supports Ubuntu, where it evidently works. There must be something different about my non-Ubuntu Linux system that causes the errors, but I would think you would want it to be made to work on all Linux systems if possible. Thank you.