Skip to content
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

pyglet causes askdirectory dialog to not open #41

Closed
ertucode opened this issue Apr 2, 2022 · 7 comments
Closed

pyglet causes askdirectory dialog to not open #41

ertucode opened this issue Apr 2, 2022 · 7 comments
Labels
bug Something isn't working

Comments

@ertucode
Copy link

ertucode commented Apr 2, 2022

I've been having some trouble using tkinter's askdirectory() for a while. But i've finally found the problem. Apparently something about pyglet causes this problem. I tried to comment out the relevant parts from customtkinter's init.py and it fixed my problem but now the shapes are really weird.

There is also this thread but I am nowhere near qualified to understand what that guy is doing.
https://stackoverflow.com/questions/65716631/using-filedialog-askdirectory-with-tkinter-and-pyglet-freezes-the-application

Can you fix this problem or give any advice.

@h4xw4r
Copy link

h4xw4r commented Apr 3, 2022

It has nothing to do with pyglet.
I have the same problem without using pyglet. Try just using tkinter, os and customtkinter and the problem is still there
This happened after I updated my customtkinter to latest version.

@TomSchimansky
Copy link
Owner

What OS are you using and how are you creating the askdirectory? I will look into this tomorrow...

@h4xw4r
Copy link

h4xw4r commented Apr 3, 2022

I'm on Windows 10 Home
this is a cleaned up version of my code

        from tkinter.constants import CENTER, LEFT
        import tkinter
        import tkinter.messagebox
        from tkinter import filedialog as fd 
        import customtkinter  # <- import the CustomTkinter module
        import os

        class App(customtkinter.CTk):
            customtkinter.set_appearance_mode("dark")
            APP_NAME = "Bulk Barcode Generator"
            WIDTH = 600
            HEIGHT = 450

            MAIN_COLOR = "#5ea886"
            MAIN_COLOR_DARK = "#2D5862"
            MAIN_HOVER = "#05f4b7"


            def __init__(self, *args, **kwargs):
                super().__init__(*args, **kwargs)

                self.title(App.APP_NAME)
                self.geometry(str(App.WIDTH) + "x" + str(App.HEIGHT))
                self.minsize(App.WIDTH, App.HEIGHT)

                self.protocol("WM_DELETE_WINDOW", self.on_closing)
                # ============ create two CTkFrames ============

                #1
                self.frame_left = customtkinter.CTkFrame(master=self,
                                                        width=220,
                                                        height=App.HEIGHT-40,
                                                        corner_radius=5)
                self.frame_left.place(relx=0.38, rely=0.5, anchor=tkinter.E)

                #2
                self.frame_right = customtkinter.CTkFrame(master=self,
                                                        width=350,
                                                        height=App.HEIGHT-40,
                                                        corner_radius=5)
                self.frame_right.place(relx=0.40, rely=0.5, anchor=tkinter.W)

        #        # ============ frame_right ============

                self.button_output = customtkinter.CTkButton(master=self.frame_right, border_color=App.MAIN_COLOR,
                                                        fg_color=None, hover_color=App.MAIN_HOVER,
                                                        height=28, text="Output Folder", command=self.button_outputFunc,
                                                        border_width=3, corner_radius=10, text_font=('Calibri',16))
                self.button_output.place(relx=0.05, rely=0.06, anchor=tkinter.NW)
                self.entry_output = customtkinter.CTkEntry(master=self.frame_right, width=320, height=38, corner_radius=5)
                self.entry_output.place(relx=0.05, rely=0.18, anchor=tkinter.NW)


            def button_outputFunc(self):
                self.entry_output.delete(0, 'end')
                filename = fd.askdirectory()
                self.entry_output.insert(0,str(filename))
                pass

            def on_closing(self, event=0):
                self.destroy()

            def start(self):
                self.mainloop()




        if __name__ == "__main__":
            app = App()
            app.start()

edit: no idea how to add code block

@ertucode
Copy link
Author

ertucode commented Apr 4, 2022

@h4xw4r I am not actually using pyglet, I said that because customtkinter itself is using it.
I am on Windows 10 Home also.

@h4xw4r
Copy link

h4xw4r commented Apr 4, 2022

@ertucode My bad, you are right İ come realize that later.

@TomSchimansky TomSchimansky added the bug Something isn't working label Apr 5, 2022
@TomSchimansky
Copy link
Owner

TomSchimansky commented Apr 5, 2022

I don't know what exactly is causing the problem, but now I removed pyglet from CustomTkinter and the dialogs should work fine. I uploaded version 3.9 to pip, maybe you can report if it's now working for you, or if there are any errors. Because now I load the necessary fonts with a custom function, which was done by pyglet before. And I only tested it on two Windows machines (Windows 10, 11).

@h4xw4r
Copy link

h4xw4r commented Apr 6, 2022

Thanks a lot, works just fine now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants