Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problems with windows paths
#1
Hello,
i try to create a button with an image. Problem: The correct Path is not interpreted correctly.
When i try this code
        image_path = os.path.join(self.cwd, "OpenFolder.png")
        print(image_path)
        open_button = Button(frame1, image=image_path)
with "print(image_path) it is printing correctly (Windows):
Output:
C:\SVN\Python\Trunk\Projects\PhotoViewer\OpenFolder.png
but gives the exception:
Error:
_tkinter.TclError: image "C:SVNPythonTrunkProjectsPhotoViewerOpenFolder.png" doesn't exist
So somehow the slashes are removed or ignored.

Generally:
How to get, join and retreive pathes correctly, if possible, platform independent?
I tried with os.getcwd() and os.path.join but somehow there's always a problem...
Reply


Messages In This Thread
Problems with windows paths - by delphinis - Jul-21-2020, 11:03 AM
RE: Problems with windows paths - by deanhystad - Jul-21-2020, 02:38 PM
RE: Problems with windows paths - by delphinis - Jul-21-2020, 03:17 PM
RE: Problems with windows paths - by deanhystad - Jul-21-2020, 03:24 PM
RE: Problems with windows paths - by delphinis - Jul-21-2020, 04:17 PM
RE: Problems with windows paths - by deanhystad - Jul-21-2020, 05:56 PM
RE: Problems with windows paths - by Gribouillis - Jul-21-2020, 06:11 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  pdf2image, poppler and paths jehoshua 18 15,199 Jun-14-2022, 06:38 AM
Last Post: jehoshua
  Windows paths issue otalado 3 1,529 May-29-2022, 09:11 AM
Last Post: snippsat
  automatically get absolute paths oclmedyb 1 2,148 Mar-11-2021, 04:31 PM
Last Post: deanhystad
  chkFile with absolute paths JarredAwesome 7 3,057 Sep-21-2020, 03:51 AM
Last Post: bowlofred
  Paths millpond 12 5,340 Jul-30-2020, 01:16 PM
Last Post: snippsat
  Shortest paths to win snake and ladder sandaab 5 4,326 Jun-30-2019, 03:20 PM
Last Post: sandaab
  How to handle paths with spaces in the name? zBernie 1 6,800 Nov-22-2018, 04:04 AM
Last Post: ichabod801
  Question: Paths and writing to a file mwmaw 6 6,613 Dec-20-2016, 03:44 PM
Last Post: wavic

Forum Jump:

User Panel Messages

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