Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Better looking Tkinter File Dialogs for Python 2.7

In my application, the user needs to browse for files. However, the askdirectory from tkFileDialog isn't really comfortable for using and browsing files since it's somewhat outdated. It looks like this:

enter image description here

What I want to achieve should look like the "default" windows browse dialog. Like this:

enter image description here

(Source https://www.pythontutorial.net/tkinter/tkinter-open-file-dialog/)

I am not sure (since I couldn't find proof) but I remember someone telling me that it looks like this because I am using Python 2.7 and not 3+. Is that true? Does an alternative exist?

like image 366
Royi Levy Avatar asked Aug 18 '26 04:08

Royi Levy


1 Answers

It seems it has something to do with your version, as I have done a bit of research and I am using python 3 with the included tkinter and it shows a normal windows explorer popup. So, if you are using one of the up-to-date versions, it should be the OS' default. (I am unable to test that as python 2 will not work properly on my machine although I can confirm since you are using an older one) I recreated your case with this code:

from tkinter import *

root = Tk()

filedialog.askdirectory()

root.mainloop()
like image 135
AntXD Avatar answered Aug 20 '26 20:08

AntXD



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!