Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make new folder in askdirectory dialog?

Tags:

python

tkinter

In tkinter in python 3.4, how to create folder using askdirectory dialog?

from tkinter import filedialog

filedialog.askdirectory(initialdir="/tmp/test")

This shows choos directory window, but cant see option to create new folder. For example, /tmp/test/new_folder. usually choose directory window have button to make new folder, but cant find option in tkinter.

enter image description here

like image 355
user3654650 Avatar asked May 29 '14 07:05

user3654650


1 Answers

I wish Tkinter included a New Folder button on the Linux platform, but it doesn't seem to. The best I could do was to just type the new folder name in the text field, and then create the new folder after the dialog box closes.

def process_files(self):
    savedir = tkFileDialog.askdirectory(title='Select folder to save results')
    os.makedirs(savedir)
    # Now write some files into savedir.
like image 68
Don Kirkby Avatar answered Sep 19 '22 21:09

Don Kirkby