-
Notifications
You must be signed in to change notification settings - Fork 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
pyglet causes askdirectory dialog to not open #41
Comments
It has nothing to do with pyglet. |
What OS are you using and how are you creating the askdirectory? I will look into this tomorrow... |
I'm on Windows 10 Home 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 |
@h4xw4r I am not actually using pyglet, I said that because customtkinter itself is using it. |
@ertucode My bad, you are right İ come realize that later. |
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). |
Thanks a lot, works just fine now. |
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.
The text was updated successfully, but these errors were encountered: