Python Forum

Full Version: Can a windows file be 'remapped' in Linux ?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Looking through some of the examples at https://github.com/flatplanet/Intro-To-T...ube-Course , tried running one and

Quote:$ python3 listbox.py
Traceback (most recent call last):
File "/home/***********/Downloads/python/flatplanet/Intro-To-TKinter-Youtube-Course/Intro-To-TKinter-Youtube-Course-master/listbox.py", line 5, in <module>
root.iconbitmap('c:/gui/codemy.ico')
File "/usr/lib/python3.12/tkinter/__init__.py", line 2155, in wm_iconbitmap
return self.tk.call('wm', 'iconbitmap', self._w, bitmap)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

As there are a few hundred Python scripts, I don't want to be changing the code. Can Python look for a file based on the PATH variable, or maybe a mount command to point , or some sort of remapping involved ?

C;/ equates to ??
I generally use pathlib for creating paths. System doesn't matter then.
from pathlib import Path

# will be path of the executing script
path = Path(__file__).parent
Great example of why you should never use absolute paths. You could make a windows virtual machine to run windows on your Linux machine. How about using a script to process the files, changing c:gui to some other folder.
(Dec-07-2024, 02:42 AM)menator01 Wrote: [ -> ]I generally use pathlib for creating paths. System doesn't matter then.
from pathlib import Path

# will be path of the executing script
path = Path(__file__).parent

Thanks yes, a hard coded pathname is not a good idea.


(Dec-07-2024, 02:59 AM)deanhystad Wrote: [ -> ]Great example of why you should never use absolute paths. You could make a windows virtual machine to run windows on your Linux machine. How about using a script to process the files, changing c:gui to some other folder.

Yes, certainly a script will be easier, .. modify on mass. Something like "How to replace a string in multiple files in linux command line" at https://stackoverflow.com/questions/1139...e#11392505