python类askdirectory()的实例源码

appjar.py 文件源码 项目:Cryptokey_Generator 作者: 8BitCookie 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def directoryBox(self, title=None, dirName=None):
        self.topLevel.update_idletasks()
        options = {}
        options['initialdir'] = dirName
        options['title'] = title
        options['mustexist'] = False
        fileName = filedialog.askdirectory(**options)
        if fileName == "":
            return None
        else:
            return fileName
spe2fitsGUI.py 文件源码 项目:spe2fits 作者: jerryjiahaha 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def chooseDialogFiles(self):
        filenames = filedialog.askopenfilenames(
                defaultextension = '.SPE',
                filetypes = [('WinViewer Documents', '.SPE'), ('all files', '.*'),],
                parent = self,
                title = "Select .SPE files",
                multiple = True,
                )
        print(filenames)
        if len(filenames) == 0:
            return
        self.chooseFilePath = os.path.dirname(
                os.path.realpath(filenames[0])
                )
        print("select:", self.chooseFilePath)
        self.chooseFileOutDir = filedialog.askdirectory(
                initialdir = self.chooseFilePath,
                parent = self,
                title = "Select output Directory",
                mustexist = False,
                )
        print("out:", self.chooseFileOutDir)
        if not self.checkDir(self.chooseFileOutDir):
            return
        self.convertFiles(filenames, self.chooseFileOutDir)
MCS_Functions.py 文件源码 项目:HSL_Dev 作者: MaxJackson 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def get_dirname():
    Tk().withdraw()
    print("Initializing Dialogue...\nPlease select a directory.")
    dirname = askdirectory(initialdir=os.getcwd(),title='Please select a directory')
    if len(dirname) > 0:
        print ("You chose %s" % dirname)
        return dirname
    else: 
        dirname = os.getcwd()
        print ("\nNo directory selected - initializing with %s \n" % os.getcwd())
        return dirname
spe2fitsGUI.py 文件源码 项目:spe2fits 作者: jerryjiahaha 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def chooseDialogDir(self):
        self.chooseDirPath = filedialog.askdirectory(
                initialdir = self.chooseDirPath,
                parent = self,
                title = "Select Directory contains .SPE files",
                )
        print("select:", self.chooseDirPath)
        if len(self.chooseDirPath) == 0:
            return
        self.chooseDirOutDir = filedialog.askdirectory(
                initialdir = self.chooseDirPath,
                parent = self,
                title = "Select output Directory",
                mustexist = False,
                )
        # TODO check wirte permission first
        if not self.checkDir(self.chooseDirOutDir):
            return
        filenames = yieldFilesUnderDirectory(self.chooseDirPath,
                match = "*.SPE")
        if filenames is None:
            messagebox.showinfo("Convert result", "No .SPE files under this directory")
            return
        self.convertFiles(filenames, self.chooseDirOutDir,
                oldPrefix = self.chooseDirPath)
tkdialog.py 文件源码 项目:sc8pr 作者: dmaccarthy 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def __init__(self, response=str, text="", title=None, accept=0, **options):
        if response is bool:
            self.dialog = [askyesno, askokcancel, askretrycancel][accept]
        else: self.dialog = {None:showinfo, str:askstring, int:askinteger, float:askfloat,
            0:askopenfilename, 1:asksaveasfilename, 2:askdirectory}[response]
        self.options = options.copy()
        if "initialdir" in options:
            self.options["initialdir"] = abspath(options["initialdir"])
        if type(response) is int:
            self.args = tuple()
            if title: self.options["title"] = title
        else:
            if title is None:
                title = "Info" if response is None else "Confirm" if response is bool else "Input"
            self.args = title, text
start_window.py 文件源码 项目:Quiver 作者: DeflatedPickle 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def open_pack(self):
        pack = filedialog.askdirectory(initialdir=self.resourcepack_location)
        if os.path.isfile(pack + "/pack.mcmeta"):
            # messagebox.showinfo("Information", "Found 'pack.mcmeta'.")
            self.parent.directory = pack
            self.parent.cmd.tree_refresh()
            self.destroy()
        else:
            messagebox.showerror("Error", "Could not find 'pack.mcmeta'.")
start_window.py 文件源码 项目:Quiver 作者: DeflatedPickle 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def install_pack(self):
        pack = filedialog.askdirectory()
        if os.path.isfile(pack + "/pack.mcmeta"):
            # messagebox.showinfo("Information", "Found 'pack.mcmeta'.")
            try:
                shutil.move(pack, self.resourcepack_location)
            except shutil.Error:
                messagebox.showerror("Error", "This pack is already installed.")
        else:
            messagebox.showerror("Error", "Could not find 'pack.mcmeta'.")
desert_mirage_gui.py 文件源码 项目:desert-mirage 作者: valentour 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def select_folder():
    from tkinter import filedialog

    selected = filedialog.askdirectory(initialdir=getcwd(),
                                       title='Select IVS Data Folder')
    _folderVar.set(selected)
    print('Selected data folder: {}'.format(_folderVar.get()))
desert_mirage_gui.py 文件源码 项目:desert-mirage 作者: valentour 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def select_export():
    selected = filedialog.askdirectory(initialdir=getcwd(),
                                       title='Select Export Tables Folder')
    _tableFolderVar.set(selected)
    print('Selected export table folder: {}'.format(_tableFolderVar.get()))
iOSAppIconGenerator.py 文件源码 项目:iOSAppIconGenerator 作者: dorukgezici 项目源码 文件源码 阅读 39 收藏 0 点赞 0 评论 0
def get_save_path():
    Data.save_path = askdirectory()
    chosen_save_path_label["text"] = Data.save_path
    return Data.save_path
spe2fitsGUI.py 文件源码 项目:spe2fits 作者: jerryjiahaha 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def addListenDir(self):
        listenDirPath = filedialog.askdirectory(
                parent = self,
                title = "Auto convert (listen) .spe under this directory",
                initialdir = self.listenDirPath.get(),
                )
        if not self.checkDir(listenDirPath, autocreate = False, poperror = False):
            return
        print("listen:", listenDirPath)
        if os.path.abspath(listenDirPath) != self.listenDirPath.get():
            self.listenDirPath.set(os.path.abspath(listenDirPath))
            self.checkListenTask()
spe2fitsGUI.py 文件源码 项目:spe2fits 作者: jerryjiahaha 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def bindListenDir(self):
        newOutDir = filedialog.askdirectory(
                parent = self,
                title = "Auto convert .spe into this directory",
                initialdir = self.listenDirPath.get(),
                )
        if not self.checkDir(newOutDir, autocreate = False, poperror = False):
            return
        print("bind to:", newOutDir)
        self.listenDirOutputPath.set(os.path.abspath(newOutDir))
directorypicker.py 文件源码 项目:pkinter 作者: DeflatedPickle 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def _browse(self):
        """Opens a directory browser."""
        directory = filedialog.askdirectory(initialdir=self._directory)
        self._variable.set(directory)
main_tk_setup.py 文件源码 项目:of 作者: OptimalBPM 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def on_select_plugins_folder(self, *args):
        _plugin_folder = filedialog.askdirectory(title="Choose plugin folder (usually in the ")
        if _plugin_folder is not None or _plugin_folder != "":
            self.plugins_folder.set(_plugin_folder)
main_tk_setup.py 文件源码 项目:of 作者: OptimalBPM 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def on_select_install_folder(self, *args):
        _install_folder = filedialog.askdirectory(title="Choose install folder (usually in the \"~of\"-folder)")
        if _install_folder is not None or _install_folder != "":
            self.install_location.set(_install_folder)
main_tk_setup.py 文件源码 项目:of 作者: OptimalBPM 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def on_select_installation(self, *args):
        _install_folder = filedialog.askdirectory(title="Select existing installation")
        if _install_folder is not None or _install_folder != "":
            self.install_location.set(_install_folder)
            self.setup.load_install(_install_folder=_install_folder)
            self.setup_to_gui()
easygui.py 文件源码 项目:rapidpythonprogramming 作者: thecount12 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
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
#-------------------------------------------------------------------
gui.py 文件源码 项目:FunKii-UI 作者: dojafoja 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def get_output_directory(self):
        out_dir=filedialog.askdirectory()
        self.out_dir_box.delete('0',tk.END)
        self.out_dir_box.insert('end',out_dir)
appjar.py 文件源码 项目:BeachedWhale 作者: southpaw5271 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def directoryBox(self, title=None, dirName=None):
        self.topLevel.update_idletasks()
        options = {}
        options['initialdir'] = dirName
        options['title'] = title
        options['mustexist'] = False
        fileName = filedialog.askdirectory(**options)
        if fileName == "":
            return None
        else:
            return fileName
main.py 文件源码 项目:Jtemplate.py 作者: MasonChi 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def select_path(self):
        file_path = askdirectory()
        self.file_path_var.set(file_path)
gui_widgets.py 文件源码 项目:SVPV 作者: VCCRI 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def asksaveasfilename(self):
        if not self.parent.filename:
            self.parent.set_info_box(message='Error: No figure has been created yet.')
        else:
            file_options = {}
            file_options['initialdir'] = self.parent.par.run.out_dir
            file_options['initialfile'] = re.sub('/.+/', '', self.parent.filename)
            file_options['filetypes'] = [('pdf files', '.pdf')]
            file_options['parent'] = self.parent
            file_options['title'] = 'save figure as'
            filename = tkFileDialog.askdirectory(**file_options)
            if filename:
                copyfile(self.parent.filename, filename)
gui.py 文件源码 项目:SVPV 作者: VCCRI 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def set_plot_all_dir(self):
        dir_options = {}
        dir_options['initialdir'] = self.par.run.out_dir
        dir_options['parent'] = self
        dir_options['title'] = 'select existing or type new directory'
        dir_options['mustexist'] = False
        path = tkFileDialog.askdirectory(**dir_options)
        if path == '':
            return None
        else:
            return path
allexe_block_py.py 文件源码 项目:AllExe-BlockPy 作者: kaz89 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def browse(self):
        filename= askdirectory()
        #print (filename)
        for exe in os.listdir(filename):
            if exe.endswith(".exe"):
             executabile=exe
             print (executabile)
             command='netsh advfirewall firewall add rule name="Block {}" dir=in action=block program="{}" enable=yes'.format(executabile,executabile)
             subprocess.call(command,shell=True)
N_A_editor.py 文件源码 项目:Nier-Automata-editor 作者: CensoredUsername 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def main():
    user_folder = os.getenv("USERPROFILE")
    nier_automata_folder = path.join(user_folder, "Documents", "My Games", "NieR_Automata")
    if not path.isdir(nier_automata_folder):
        messagebox.showerror("Error", "Could not find Nier;Automata's save folder location. Please select the save folder location")
        nier_automata_folder = filedialog.askdirectory()

    gamedata_path = path.join(nier_automata_folder, "GameData.dat")
    if not path.isfile(gamedata_path):
        raise Exception("Could not find NieR_Automata/GameData.dat. Please run Nier;Automata at least once before using this tool.")

    # read the gamedata header.
    with open(gamedata_path, "rb") as f:
        gamedata_header = f.read(12)

    locations = ("SlotData_0.dat", "SlotData_1.dat", "SlotData_2.dat")
    import collections
    saves = collections.OrderedDict()

    for location in locations:
        savedata_path = path.join(nier_automata_folder, location)
        if path.isfile(savedata_path):
            saves[location] = SaveGame(savedata_path)

    interface = Interface(saves, gamedata_header)
    interface.master.title("NieR;Automata Save Editor")
    interface.mainloop()
ListPanel.py 文件源码 项目:Python-Media-Player 作者: surajsinghbisht054 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def ask_for_directory(self):
            path=tkFileDialog.askdirectory(title='Select Directory For Playlist')
            if path:
                    self.directory.set(path)
                    print (path)
                    return self.update_list_box_songs(dirs=path)
gui.py 文件源码 项目:foldercompare 作者: rocheio 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def set_directory(self, variable):
        """Return a selected directory name.

        ARGS:
            variable (tk.Variable): The tkinter variable to save selection as.
        """

        selection = filedialog.askdirectory(**self.directory_options)
        variable.set(selection)
install_examples.py 文件源码 项目:SFC_models 作者: brianr747 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def install_examples(): # pragma: no cover
    """
    Pops up windows to allow the user to choose a directory for installation
    of sfc_models examples.

    Uses tkinter, which is installed in base Python (modern versions).
    :return:
    """
    if not mbox.askokcancel(title='sfc_models Example Installation',
                            message=validate_str):
        return
    target = fdog.askdirectory(title='Choose directory to for sfc_models examples installation')
    if target == () or target == '':
        return
    install_example_scripts.install(target)
tkgui.py 文件源码 项目:sorter 作者: giantas 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def _show_diag(self, text):
        dir_ = filedialog.askdirectory()
        if dir_:
            if text == 'source':
                self.source_entry.delete(0, END)
                self.source_entry.insert(0, dir_)
            if text == 'destination':
                self.dst_entry.delete(0, END)
                self.dst_entry.config(state='normal')
                self.dst_entry.insert(0, dir_)
guiwin.py 文件源码 项目:pysaf 作者: cstarcher 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def bit_dir_open(self, gs):
        """Open filedialog when Select Location of Files button selected."""
        self.bit_dir_path = filedialog.askdirectory()
        gs.bit_path = self.bit_dir_path
        self.bit_dir_var.set(self.bit_dir_path)
guiwin.py 文件源码 项目:pysaf 作者: cstarcher 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def archive_dir_open(self, gs):
        """Open filedialog when Select Archive Destination button selected."""
        self.archive_dir_path = filedialog.askdirectory()
        gs.archive_path = self.archive_dir_path
        self.archive_dir_var.set(self.archive_dir_path)


问题


面经


文章

微信
公众号

扫码关注公众号