Tkinter path handling under Windows with `MessageCatalog.load`
See original GitHub issueDesktop (please complete the following information):
OS: Windows 10 64-bit Python: 3.9.7 tkinter: 8.6.9 ttkbootstrap: 1.7.4
Describe the bug
I used the load
method to load all translation files in a directory.
Under Windows atleast the load
method needs:
- An absolute-resolved path.
- All backslashes replaced with forward slashes
You can fix your implementation by just resolving the path and replacing any backslashes with forward slashes. I can drop a PR if you wish.
To Reproduce
No response
Expected behavior
No response
Screenshots
No response
Additional context
This is most probably a Tkinter bug, or might be a Tk bug as well.
Issue Analytics
- State:
- Created a year ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
How to get the absolute path of a file using tkFileDialog(Tkinter)?
This function will return the absolute path of the file which can be stored in a variable to display in the window or...
Read more >Getting file path for use by other function using Tkinter
I would change the button command to a function which does all of the file code: # update the button to call a...
Read more >Tkinter Dialogs — Python 3.11.1 documentation
The tkinter.simpledialog module contains convenience classes and functions for creating simple modal dialogs to get a value from the user. tkinter.simpledialog.
Read more >File Explorer in Python using Tkinter - GeeksforGeeks
The following steps are involved in creating a tkinter application: Importing the Tkinter module. Creation of the main window (container).
Read more >OpenCV with Tkinter - PyImageSearch
Tutorial: Read an image with OpenCV and then display it in a Tkinter window using Python.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@rdbende The
resolve()
method turns all forward slashes to backslashes on Windows. Tk doesn’t understand them and escapes them entirely. Also ttkbootstrap’s implementation is not what is recommended. The msgcat manual page recommends using this command:where msgs is the folder containing translations
I don’t know how ttkbootstrap’s implementation works, but when I tried using the same code in my own application it didn’t work, the above command worked.
@israel-dryer I agree, its a bug in Tk itself. Any Windows software should support backslashes in paths