TomSchimansky / CustomTkinter

A modern and customizable python UI-library based on Tkinter
MIT License
11.63k stars 1.09k forks source link

Bad screen distance error when i try to change the locale language #2503

Open HawKen147 opened 4 months ago

HawKen147 commented 4 months ago

Hello,

I needed to change the locale variable to get the french format days, but i get a "bad screen distance "250.0"". This error happen when i try to open or create a new window. I use this code from the Documentation :

import locale
import customtkinter

class MyFrame(customtkinter.CTkFrame):
    def __init__(self, master, **kwargs):
        super().__init__(master, **kwargs)

        # add widgets onto the frame, for example:
        self.label = customtkinter.CTkLabel(self)
        self.label.grid(row=0, column=0, padx=20)

class App(customtkinter.CTk):
    def __init__(self):
        super().__init__()
        self.geometry("400x200")
        self.grid_rowconfigure(0, weight=1)  # configure grid system
        self.grid_columnconfigure(0, weight=1)
        self.my_frame = MyFrame(master=self)
        self.my_frame.grid(row=0, column=0, padx=20, pady=20, sticky="nsew")

app = App()
app.mainloop()

But when i try to change the language with the locale.setlocale(locale.LC_ALL, 'fr_FR.UTF-8') before creating the window, it doesn't work anymore

import locale
import customtkinter

locale.setlocale(locale.LC_ALL, 'fr_FR.UTF-8')

class MyFrame(customtkinter.CTkFrame):
    def __init__(self, master, **kwargs):
        super().__init__(master, **kwargs)

        # add widgets onto the frame, for example:
        self.label = customtkinter.CTkLabel(self)
        self.label.grid(row=0, column=0, padx=20)

class App(customtkinter.CTk):
    def __init__(self):
        super().__init__()
        self.geometry("400x200")
        self.grid_rowconfigure(0, weight=1)  # configure grid system
        self.grid_columnconfigure(0, weight=1)
        self.my_frame = MyFrame(master=self)
        self.my_frame.grid(row=0, column=0, padx=20, pady=20, sticky="nsew")

app = App()
app.mainloop()

i don't really know why it doesn't work and how i can by pass it