[Tkinter] Default Paths - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: GUI (https://python-forum.io/forum-10.html) +--- Thread: [Tkinter] Default Paths (/thread-17752.html) Pages:
1
2
|
Default Paths - francisco_neves2020 - Apr-22-2019 Ok, guys. Major stupidity on my part. I have mad an exe file and post it on sourceforge.net, but the program will not work. This, because the main file and secondary ones required extensions (images, audio, etc), which are indicate by window path (C:/Users/Desktop/"My name"/Project/image.png) I totally forgot the part, when it goes to another computer it will never work, because the computer path will not be the same one as mine. Anyway to fix this, to a default path or something, so all the files call be called and work? Any replies much appreciated. Again major error and stupidity of my part, i totally forgot about that. RE: Default Paths - SheeppOSU - Apr-22-2019 import os from pathlib import Path d = Path(__file__).parent sound = os.path.join(d, 'Folder', 'Keep adding folders/files till you get to the file') RE: Default Paths - Gribouillis - Apr-22-2019 I think you want package data. See also the module importlib.resources for accessing package data from the code (starting with 3.7, before that it was pkg_resources )
RE: Default Paths - francisco_neves2020 - Apr-22-2019 But, for example, if i change it only C:\Project will not work? RE: Default Paths - SheeppOSU - Apr-22-2019 Linux users do not have "C:" And I'm also pretty sure someone on Linux has regular slashes - / RE: Default Paths - francisco_neves2020 - Apr-22-2019 (Apr-22-2019, 07:37 PM)SheeppOSU Wrote: Linux users do not have "C:" Ok, right now, just for windows, then for others. i would love to get this to work. and see what portuguese people think about it and improve it based on the feedback i hope to receive RE: Default Paths - SheeppOSU - Apr-22-2019 (Apr-22-2019, 07:12 PM)francisco_neves2020 Wrote: But, for example, if i change it only C:\Project will not work?I guess that is fine. If I'm correct, you mean to put all the pictures and stuff there, if so, that will work. RE: Default Paths - francisco_neves2020 - Apr-22-2019 (Apr-22-2019, 07:05 PM)SheeppOSU Wrote:import os from pathlib import Path d = Path(__file__).parent sound = os.path.join(d, 'Folder', 'Keep adding folders/files till you get to the file') Man i didn't get the part until i get the file. There is one major pyw file, within this major pyw file there is from subprocess call others pyw. This major file has attached to it one png, then there are 2 or 3 secondary with png attached also and one with 10 png images(slideshow). The one with that code will be the major one, where i will indicate all the other files, except itself)? RE: Default Paths - SheeppOSU - Apr-22-2019 I don't exactly get the question, but if you're asking but with a lot of pictures you could just do this - import os from pathlib import Path d = Path(__file__).parent x = 0 picList = ['file.png', 'file.png', 'file.png', 'file.png'] for i in picList: picList[x] = os.path.join(d, 'Pic Folder', i) x += 1Hope i didn't make any mistakes on there Oh! I just remembered - If they are in the same directory as the file you just have to put the name of the picture RE: Default Paths - francisco_neves2020 - Apr-22-2019 (Apr-22-2019, 08:04 PM)SheeppOSU Wrote: I don't exactly get the question, but if you're asking but with a lot of pictures you could just do this - Based on this picture you may get an ideia |