question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Tkinter path handling under Windows with `MessageCatalog.load`

See original GitHub issue

Desktop (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:

  1. An absolute-resolved path.
  2. 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:closed
  • Created a year ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
dembertocommented, Apr 14, 2022

@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:

::msgcat::mcload [file join [file dirname [info script]] msgs]

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.

0reactions
dembertocommented, Apr 22, 2022

@israel-dryer I agree, its a bug in Tk itself. Any Windows software should support backslashes in paths

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found