Problem when using Tkinter in Python

Thread Starter

ErnieM

Joined Apr 24, 2011
8,346
Using a Raspberry Pi, I have a Python program using Tkinter so it has a nice GUI interface. All works fine when I run it from within the Thoney interface.

However, it really needs to run from a shortcut. However, when I do so the program does it's best to run, but it cannot find some bitmaps I use which completely messes up the display. I have no idea why, as the paths to the bitmap files is fully qualified.

Anyone have any ideas?
 

Ya’akov

Joined Jan 27, 2019
6,856
I can only make an educated guess, but my first impulse would be to check the environment in each of the cases and see what is different between them.
 

MrSalts

Joined Apr 2, 2020
2,620
Using a Raspberry Pi, I have a Python program using Tkinter so it has a nice GUI interface. All works fine when I run it from within the Thoney interface.

However, it really needs to run from a shortcut. However, when I do so the program does it's best to run, but it cannot find some bitmaps I use which completely messes up the display. I have no idea why, as the paths to the bitmap files is fully qualified.

Anyone have any ideas?
Fully qualified from root
/user/Ernie/bitmaps/image1.bmp
or relative
../bitmaps/image1.bmp
Or from home
~/bitmaps/image1.bmp

your Current directory is whichever directory you are in when launching the script. If your calling fromyour home directory as
$ pycode/myscript.py
Any referenced bitmaps in the code will need to be ../Ernie/bitmaps/image1.bmp
The "~" reference is not defined as home in some situations within py references.
Any, you may need to escape the / with a \ or put your string file reference in triple quotes ''' /user/Ernie/bitmaps/image1.bmp '''

not all py is the same - which version are you running of py?
are you calling as python3 myScript,py
Pr just as python myScript.py

likely that Thorny is running Python3.x and you are launching with "python" which still calls Python 2. Try launching with python3 myScript.py
 
Last edited:

Thread Starter

ErnieM

Joined Apr 24, 2011
8,346
Thanks MrSalts, now I have a direction to look into.

That will take me a while as I don't have good access to the system with this code. Hopefully I can make up a similar system to debug.
 
Top