-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tkinter.TclError: bad screen distance "200.0" #571
tkinter.TclError: bad screen distance "200.0" #571
Comments
Can you send a minimal reproducible example? P.S. Looking at the widgets, might it be a problem in the |
Yeah, i got the problem, here is a minimal reproducible example:
The problem is, when using the locale package, then the integer values get converted to floats. |
@snoo-snoo I tried your code, and it works without any problem on my machine. |
@TheFallen-Cat try changing your OS language to German. Then you should be able to replicate the error. sorry, forgot about that. |
Ah okay, lemme try that in a bit. |
@snoo-snoo I did. And if i leave the |
I'm having the same problem. I've turned off the locale change as a workaround, but I'm wondering if there might be a fix for it. import locale root = ctk.CTk() locale.setlocale(locale.LC_ALL, 'pt_BR.UTF-8') |
It would be nice to have a better error message for this bug. |
After reducing the example given by @snoo-snoo even more to import customtkinter
import locale
locale.setlocale(locale.LC_ALL, '')
app = customtkinter.CTk()
customtkinter.CTkFrame(master=app) I can still reproduce the issue on a German Win10 (customtkinter-5.1.2, Python 3.11.1):
|
I will have a look. |
I have the same problem. It seems to be a bug in tkinter when converting the float to string for tk.
I found this discussion in the Python forum about float in tkinter and German locale |
During migration of one of my projects to customertkinter i steped into the same problem again. I'm on Winbdows 10, Python 3.11.6 and newest custometkinter. The problem occurs when using a locale (for eample locale.setlocale(locale.LC_ALL, "DE-de")).
|
I found that you need the float value, otherwise scrollbars arn't working. I changed the code above to:
|
Had no problems since writing my program over half a year ago. But today the error "bad screen distance" suddenly appeared, even after disabling setlocale. Your solution fixed it, thanks. |
Can confirm this. Just ran into the same issue on german locale. Changed the above things in scaling_base_class.py. No errors afterwards. |
I just ran into the same issue, your solution fixed it thanks a lot! |
Prevents triggering a bug on Tk canvas, where float parameters use locally-aware parsing and thus might expect a different decimal point character Fixes TomSchimansky#571
Python 3.10
Windows 11
When i init a CtkFrame like this:
i always get
_tkinter.TclError: bad screen distance "200.0"
The error is located at
ctk_frame.py line 41:
self.canvas = CTkCanvas(master=self, highlightthickness=0, width=self.apply_widget_scaling(self._current_width), height=self.apply_widget_scaling(self._current_height))
when changing to:
it works, but then next "TclError: bad screen distance" is located in ctk_label.py, line 47.
Tried it on several computers, but error is always the same.
Any idea what this might cause? looks it somehow receives a float instead of an int, but width and height are default values.
The text was updated successfully, but these errors were encountered: