pythonpython-3.xtkinterpyglettkinter-layout

Why tkinter filedialog is looking different after using pyglet?


I have used a tkinter.filedialog with the pyglet library. But an old file explorer pops up when I open that filedialog. Normally it opens the native/modern file explorer of windows, but it is showing this behavior after importing the pyglet module. Any solution to get back the new filedialog?

Here is a basic code to reproduce the issue:

from tkinter import Tk, Button, filedialog
import pyglet #Try commenting this import to test the filedialog
root= Tk()
root.geometry("200x100")
window = pyglet.window.Window(20, 20, "Pyglet_window") #Pyglet window
def open_file():
    file=filedialog.askopenfilename()
btn= Button(root, width=10,bg="#FFFFFF",fg="black", text="Open File",command=open_file)
btn.grid(padx=50,pady=20)
root.mainloop()

My results:

difference


Solution

  • Update: This issue was fixed after the new update of pyglet (v2.0.5+).

    So just update pyglet:

    pip install pyglet --upgrade