Python tkfiledialog.askdirectory() Examples

The following are 30 code examples of tkfiledialog.askdirectory(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module tkFileDialog , or try the search function .
Example #1
Source File: examdownloader-gui.py    From nus-exams-downloader with MIT License 5 votes vote down vote up
def askForDestination(self):
        self.destination = tkFileDialog.askdirectory(mustexist=False, parent=self.top, title='Choose a destination')
        self.destField.delete(0, END)
        self.destField.insert(0, self.destination) 
Example #2
Source File: dataSelector.py    From universalSmashSystem with GNU General Public License v3.0 5 votes vote down vote up
def loadDir(self):
        if self.target_object:
            directory = askdirectory(initialdir=self.target_object.base_dir)
            self.dir_data.set(os.path.relpath(directory, self.target_object.base_dir)) 
Example #3
Source File: fileintegrity.py    From darkc0de-old-stuff with GNU General Public License v3.0 5 votes vote down vote up
def opendirectory():
    try:
        entry.delete(0, END)
        fileopen = tkFileDialog.askdirectory()
        entry.insert(END, fileopen)
    except:
        textbox.insert(END, "There was an error opening ")
        textbox.insert(END, fileopen)
        textbox.insert(END, "\n") 
Example #4
Source File: aniGUI.py    From EdwardsLab with MIT License 5 votes vote down vote up
def askAllFnaDirectory(self):
     askAllFnaDirectoryLocation = tkFileDialog.askdirectory()
     if askAllFnaDirectoryLocation:
        self.allFnaEntry.delete(0, 'end')
        self.allFnaEntry.insert(0, str(askAllFnaDirectoryLocation))
     return
   # Queries directory containing files respective to BLAST 
Example #5
Source File: aniGUI.py    From EdwardsLab with MIT License 5 votes vote down vote up
def askBlastDirectory(self):
     blastDirectoryLocation = tkFileDialog.askdirectory()
     if blastDirectoryLocation:
        self.blastEntry.delete(0, 'end')
        self.blastEntry.insert(0, str(blastDirectoryLocation))
     return
   # Queries directory containing files respective to MUMmer
       # Returns directory containing files to dump Delta files 
Example #6
Source File: aniGUI.py    From EdwardsLab with MIT License 5 votes vote down vote up
def askOutFilesOutputDirectory(self):
     outFilesDirectoryLocation = tkFileDialog.askdirectory()
     if outFilesDirectoryLocation:
        self.outEntry.delete(0, 'end')
        self.outEntry.insert(0, str(outFilesDirectoryLocation))
     return 
Example #7
Source File: aniGUI.py    From EdwardsLab with MIT License 5 votes vote down vote up
def askMummerDirectory(self):
     mummerDirectoryLocation = tkFileDialog.askdirectory()
     if mummerDirectoryLocation:
        self.mummerEntry.delete(0, 'end')
        self.mummerEntry.insert(0, str(mummerDirectoryLocation))
     return
 	 # Queries directory containing files to dump Delta files 
Example #8
Source File: aniGUI.py    From EdwardsLab with MIT License 5 votes vote down vote up
def askDeltaFilesOutputDirectory(self):
     deltaFilesDirectoryLocation = tkFileDialog.askdirectory()
     if deltaFilesDirectoryLocation:
        self.deltaEntry.delete(0, 'end')
        self.deltaEntry.insert(0, str(deltaFilesDirectoryLocation))
     return
   #  Queries directory containing files to dump output files 
Example #9
Source File: gui_batchdownload.py    From grab_huaban_board with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def selectPath(self):
        path_ = askdirectory(title=u"请选择或新建一个目录以存储将要下载的图片")
        if path_:
            self.Label2.configure(text=path_) 
Example #10
Source File: guiClass.py    From Video-Downloader with GNU General Public License v2.0 5 votes vote down vote up
def __chooseCfgFolder (self) :
		path = tkFileDialog.askdirectory(initialdir="/",title='请选择文件夹')
		self.filePath.set(path.strip()) 
Example #11
Source File: tkinter.py    From peniot with MIT License 5 votes vote down vote up
def download_file(self, file_name):
        """
        This methods is used to export the selected packets file.
        """
        # Get the directory
        directory_name = tkFileDialog.askdirectory(initialdir=os.getcwd(), title="Select directory to download packets")

        try:
            # Read the file
            packets_file = os.open(os.path.dirname(os.path.abspath(__file__))[:-4] + "/captured_packets/" + file_name,
                                   os.O_RDONLY)
            # Open a file
            new_file = os.open(directory_name + "/" + file_name, os.O_RDWR | os.O_CREAT)
            # Copy the file content
            while True:
                data = os.read(packets_file, 2048)
                if not data:
                    break
                os.write(new_file, data)
            # Close the files
            os.close(packets_file)
            os.close(new_file)
            # Create pop-up
            pop_up_window(root, None, "Downloaded successfully")
        except Exception as e:
            if len(directory_name) == 0:
                return
            else:
                pop_up_window(root, None, "Download operation is failed because of\n{0}".format(e), justify=CENTER) 
Example #12
Source File: tkinter.py    From peniot with MIT License 5 votes vote down vote up
def report_generator(self):
        directory = tkFileDialog.askdirectory()
        try:
            if type(directory) == str and len(directory) > 0:
                directory = directory if directory.endswith('/') else directory + '/'
                GenerateReport.generate_pdf_from_text(
                    self.protocol['protocol'].get_protocol_name(),
                    self.attack.get_attack_name(),
                    self.console.get("1.0", END),
                    directory
                )
                pop_up_window(root, None, 'Report is successfully generated.', justify=CENTER)
        except Exception as e:
            pop_up_window(root, None, 'Report cannot be generated properly.\nPlease check given directory path.',
                          justify=CENTER) 
Example #13
Source File: subactionSelector.py    From universalSmashSystem with GNU General Public License v3.0 5 votes vote down vote up
def pickFile(self,_resultVar, _filetype='file', _extensions=[]):
        if _filetype == 'file':
            loaded_file = askopenfile(mode="r",
                               initialdir=settingsManager.createPath('fighters'),
                               filetypes=_extensions)
            loaded_name = loaded_file.name
        elif _filetype == 'dir':
            loaded_name = askdirectory(initialdir=settingsManager.createPath(''))
        res = os.path.relpath(loaded_name,os.path.dirname(self.root.root.fighter_file.name))
        _resultVar.set(res) 
Example #14
Source File: app.py    From subfinder with MIT License 5 votes vote down vote up
def _open(self, file_or_directory='file'):
        if file_or_directory == 'file':
            self.videofile = filedialog.askopenfilename(initialdir='~/Downloads/test',
                                                        filetypes=(
                                                            ('Video files', '*.mkv *.avi *.mp4 *'), ),
                                                        title="选择一个视频文件")
        elif file_or_directory == 'dir':
            self.videofile = filedialog.askdirectory(initialdir='~/Downloads/test',
                                                     title="选择一个目录")
        self.label_selected['text'] = self.videofile 
Example #15
Source File: download_utils.py    From MobOff with MIT License 5 votes vote down vote up
def select_directory():
    root = Tk()
    root.withdraw()
    current_directory = filedialog.askdirectory()
    return current_directory 
Example #16
Source File: GUI.py    From Scoary with GNU General Public License v3.0 5 votes vote down vote up
def BrowseButtonClickOutput(self):
        """
        Browse button for choosing output dir
        """
        mydir = tkFileDialog.askdirectory(mustexist=True)
        self.Outputdir.set(mydir) 
Example #17
Source File: shutterscrape.py    From shutterscrape with MIT License 5 votes vote down vote up
def askDialog():
   return tkFileDialog.askdirectory() 
Example #18
Source File: shutterscrape.py    From shutterscrape with MIT License 5 votes vote down vote up
def inp(text):
   return raw_input(text)

# For python3
# from urllib.request import urlretrieve
# import tkinter, tkinter.constants, tkinter.filedialog

# def askDialog():
#     return tkinter.filedialog.askdirectory()

# def inp(text):
#     return input(text) 
Example #19
Source File: easygui.py    From python-examples with MIT License 5 votes vote down vote up
def diropenbox(msg=None
    , title=None
    , default=None
    ):
    """
    A dialog to get a directory name.
    Note that the msg argument, if specified, is ignored.

    Returns the name of a directory, or None if user chose to cancel.

    If the "default" argument specifies a directory name, and that
    directory exists, then the dialog box will start with that directory.
    """
    title=getFileDialogTitle(msg,title)
    localRoot = Tk()
    localRoot.withdraw()
    if not default: default = None
    f = tk_FileDialog.askdirectory(
          parent=localRoot
        , title=title
        , initialdir=default
        , initialfile=None
        )
    localRoot.destroy()
    if not f: return None
    return os.path.normpath(f)



#-------------------------------------------------------------------
# getFileDialogTitle
#------------------------------------------------------------------- 
Example #20
Source File: main-gui.py    From Tkinter-Projects with MIT License 5 votes vote down vote up
def add_dir(self):
		path = tkFileDialog.askdirectory()
		if path:
			tfileList = []
			for (dirpath, dirnames, filenames) in os.walk(path):
				for tfile in filenames:
					if tfile.endswith(".mp3") or tfile.endswith(".wav") or tfile.endswith("ogg"):
						tfileList.append(dirpath+"/"+tfile)
			for item in tfileList:
				self.listbox.insert(END, item)
			self.alltracks = list(self.listbox.get(0, END)) 
Example #21
Source File: ScribusGenerator.py    From ScribusGenerator with MIT License 5 votes vote down vote up
def outputDirectoryEntryVariableHandler(self):
        result = tkFileDialog.askdirectory(initialdir=self.__outputDirectoryEntryVariable.get())
        if result:
            self.__outputDirectoryEntryVariable.set(result) 
Example #22
Source File: menotexport-gui.py    From Menotexport with GNU General Public License v3.0 5 votes vote down vote up
def openDir(self):
        self.out_entry.delete(0,tk.END)
        dirname=askdirectory()
        self.out_entry.insert(tk.END,dirname)
        if len(dirname)>0:
            print('# <Menotexport>: Output folder: %s' %dirname)
            self.hasout=True
            self.checkReady() 
Example #23
Source File: rasGUI.py    From CIS-ESP with Apache License 2.0 5 votes vote down vote up
def askdirectory():
	"""Returns a selected directoryname."""
	global outputDir
	outputDir = tkFileDialog.askdirectory()
	outputDirVar.set(outputDir) 
Example #24
Source File: pcap_tools.py    From ProcDOT-Plugins with MIT License 5 votes vote down vote up
def callback(path):
    folder = tkFileDialog.askdirectory(initialdir='C:/', title='Extract files from pcap') 
    path.set(folder)

#exit gui 
Example #25
Source File: easygui.py    From mantaray with GNU General Public License v3.0 5 votes vote down vote up
def diropenbox(msg=None
    , title=None
    , default=None
    ):
    """
    A dialog to get a directory name.
    Note that the msg argument, if specified, is ignored.

    Returns the name of a directory, or None if user chose to cancel.

    If the "default" argument specifies a directory name, and that
    directory exists, then the dialog box will start with that directory.
    """
    title=getFileDialogTitle(msg,title)
    boxRoot = Tk()
    boxRoot.withdraw()
    if not default: default = None
    f = tk_FileDialog.askdirectory(
          parent=boxRoot
        , title=title
        , initialdir=default
        , initialfile=None
        )
    boxRoot.destroy()
    if not f: return None
    return os.path.normpath(f)



#-------------------------------------------------------------------
# getFileDialogTitle
#------------------------------------------------------------------- 
Example #26
Source File: dicom_anonymizer_frame.py    From DICAT with GNU General Public License v3.0 5 votes vote down vote up
def askdirectory(self):

        # removes the message from the grid
        self.messageView.grid_forget()

        """Returns a selected directory name."""
        self.dirname = tkFileDialog.askdirectory(**self.dir_opt)
        self.entryVariable.set(self.dirname)
        self.buttonView.configure(state=NORMAL)
        return self.dirname 
Example #27
Source File: user_interface.py    From PcapXray with GNU General Public License v2.0 5 votes vote down vote up
def browse_directory(self, option):
        if option == "pcap":
            # Reference: http://effbot.org/tkinterbook/tkinter-dialog-windows.htm
            self.pcap_file.set(fd.askopenfilename(initialdir = sys.path[0],title = "Select Packet Capture File!",filetypes = (("All","*.pcap *.pcapng"),("pcap files","*.pcap"),("pcapng files","*.pcapng"))))
            self.filename = self.pcap_file.get().replace(".pcap","")
            if "/" in self.filename:
                self.filename = self.filename.split("/")[-1]
            #,("all files","*.*")
            #self.filename_field.delete(0, END)
            #self.filename_field.insert(0, self.pcap_file)
            print(self.filename)
            print(self.pcap_file)
        else:
            self.destination_report.set(fd.askdirectory())
            if self.destination_report.get():
                if not os.access(self.destination_report.get(), os.W_OK):
                    mb.showerror("Error","Permission denied to create report! Run with higher privilege.")
            else:
                mb.showerror("Error", "Enter a output directory!") 
Example #28
Source File: gui.py    From GreenMachine with MIT License 5 votes vote down vote up
def askDir(self):
        dirname = filedialog.askdirectory()
        self.dir_name.set(dirname)
        self.loadDir(dirname) 
Example #29
Source File: main.py    From aurora-sdk-mac with Apache License 2.0 5 votes vote down vote up
def get_plugin_dir(self):
        self.plugin_dir_path.set(tkFileDialog.askdirectory()) 
Example #30
Source File: __init__.py    From PyKinectTk with GNU General Public License v3.0 5 votes vote down vote up
def select_folder():
    root = Tk()
    root.withdraw()
    path = realpath(askdirectory(parent=root))  
    root.destroy()
    return path