python类askdirectory()的实例源码

gui.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)
gui.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)
easygui.py 文件源码 项目:Snakepit 作者: K4lium 项目源码 文件源码 阅读 17 收藏 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)
    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
#-------------------------------------------------------------------
test_path.py 文件源码 项目:tfc 作者: maqp 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def setUp(self):
        self.o_aof    = filedialog.askopenfilename
        self.o_ad     = filedialog.askdirectory
        self.o_input  = builtins.input
        self.settings = Settings()
test_path.py 文件源码 项目:tfc 作者: maqp 项目源码 文件源码 阅读 36 收藏 0 点赞 0 评论 0
def tearDown(self):
        filedialog.askopenfilename = self.o_aof
        filedialog.askdirectory    = self.o_ad
        builtins.input             = self.o_input
test_path.py 文件源码 项目:tfc 作者: maqp 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def test_get_path_gui(self):
        # Setup
        filedialog.askdirectory = lambda title: 'test_path'

        # Test
        self.assertEqual(ask_path_gui('test message', self.settings, get_file=False), 'test_path')
test_path.py 文件源码 项目:tfc 作者: maqp 项目源码 文件源码 阅读 34 收藏 0 点赞 0 评论 0
def test_no_path_raises_fr(self):
        # Setup
        filedialog.askdirectory = lambda title: ''

        # Test
        self.assertFR("Path selection aborted.", ask_path_gui, 'test message', self.settings, False)
path.py 文件源码 项目:tfc 作者: maqp 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def ask_path_gui(prompt_msg: str,
                 settings:   Union['Settings', 'nhSettings'],
                 get_file:   bool = False) -> str:
    """Prompt (file) path with Tkinter / CLI prompt.

    :param prompt_msg: Directory selection prompt
    :param settings:   Settings object
    :param get_file:   When True, prompts for path to file instead of directory
    :return:           Selected directory / file
    """
    try:
        if settings.disable_gui_dialog:
            raise _tkinter.TclError

        root = Tk()
        root.withdraw()

        if get_file:
            file_path = filedialog.askopenfilename(title=prompt_msg)
        else:
            file_path = filedialog.askdirectory(title=prompt_msg)

        root.destroy()

        if not file_path:
            raise FunctionReturn(("File" if get_file else "Path") + " selection aborted.")

        return file_path

    except _tkinter.TclError:
        return ask_path_cli(prompt_msg, get_file)
Guetzli-R.py 文件源码 项目:guetzli-recursively-gui 作者: tanrax 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def open_folder(self):
        self.button_run['state'] = 'disabled'
        self.top_dir = filedialog.askdirectory(initialdir='.')
        self.label_path['text'] = 'Looking for images to optimize... Please, wait'
        self._start_count_images()
Guetzli-R.py 文件源码 项目:guetzli-recursively-gui 作者: tanrax 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def open_folder(self):
        self.button_run['state'] = 'disabled'
        self.top_dir = filedialog.askdirectory(initialdir='.')
        self.label_path['text'] = 'Looking for images to optimize... Please, wait'
        self._start_count_images()
easygui.py 文件源码 项目:mini_rpg 作者: paolo-perfahl 项目源码 文件源码 阅读 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
#-------------------------------------------------------------------
guiscrape.py 文件源码 项目:Python-Journey-from-Novice-to-Expert 作者: PacktPublishing 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def save():
    if not config.get('images'):
        _alert('No images to save')
        return

    if _save_method.get() == 'img':
        dirname = filedialog.askdirectory(mustexist=True)
        _save_images(dirname)
    else:
        filename = filedialog.asksaveasfilename(
            initialfile='images.json',
            filetypes=[('JSON', '.json')])
        _save_json(filename)
open_GUI.py 文件源码 项目:bruker2nifti 作者: SebastianoF 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def button_browse_callback_pfo_input(self):
        filename = tkFileDialog.askdirectory()
        self.entry_pfo_input.delete(0, tk.END)
        self.entry_pfo_input.insert(0, filename)
open_GUI.py 文件源码 项目:bruker2nifti 作者: SebastianoF 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def button_browse_callback_pfo_output(self):
        filename = tkFileDialog.askdirectory()
        self.entry_pfo_output.delete(0, tk.END)
        self.entry_pfo_output.insert(0, filename)
appjar.py 文件源码 项目:SceneDensity 作者: ImOmid 项目源码 文件源码 阅读 21 收藏 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
airscript-old-stable.py 文件源码 项目:Airscript-ng 作者: Sh3llcod3 项目源码 文件源码 阅读 38 收藏 0 点赞 0 评论 0
def hashcatdownloadfunc(): #GIT CLONES AND MAKE-BUILDs HASHCAT!
    import os, webbrowser, time
    from tkinter import filedialog
    from tkinter import Tk
    os.system("clear")
    print("""\033[0;33;48m

              a          a
             aaa        aaa
            aaaaaaaaaaaaaaaa
           aaaaaaaaaaaaaaaaaa
          aaaaafaaaaaaafaaaaaa
          aaaaaaaaaaaaaaaaaaaa
           aaaaaaaaaaaaaaaaaa
            aaaaaaa  aaaaaaa
             aaaaaaaaaaaaaa
  a         aaaaaaaaaaaaaaaa
 aaa       aaaaaaaaaaaaaaaaaa
 aaa      aaaaaaaaaaaaaaaaaaaa
 aaa     aaaaaaaaaaaaaaaaaaaaaa
 aaa    aaaaaaaaaaaaaaaaaaaaaaaa
  aaa   aaaaaaaaaaaaaaaaaaaaaaaa
  aaa   aaaaaaaaaaaaaaaaaaaaaaaa
  aaa    aaaaaaaaaaaaaaaaaaaaaa
   aaa    aaaaaaaaaaaaaaaaaaaa
    aaaaaaaaaaaaaaaaaaaaaaaaaa
     aaaaaaaaaaaaaaaaaaaaaaaaa

???  ??? ?????? ???????????  ??? ??????? ?????? ?????????    
???  ??????????????????????  ????????????????????????????       
???????????????????????????????????     ????????   ???       
???????????????????????????????????     ????????   ???       
???  ??????  ??????????????  ??????????????  ???   ???       
???  ??????  ??????????????  ??? ??????????  ???   ???                                                                   
\033[0;39;48m
""")
    if input("\033[1;39;48mDownload and setup hashcat for GPU-WPA cracking? [y/n] >> ").lower().startswith("y"):
        os.system("clear")
        print("\nWhere would you like hashcat installed?")
        input("\n|MENU|POST_CRACK|GPU|HASHCAT_DOWNLOAD|(Please delete any older versions and press enter to choose directory) >>")
        global hashpath
        Tk().withdraw()
        hashpath = filedialog.askdirectory()
        hashpath = str(hashpath)
        print("\nA browser window will now open. ALT+TAB back to the terminal")
        time.sleep(3)
        webbrowser.open("https://hashcat.net/")
        #print("Please right-click and copy/paste link location on the button next to hashcat binaries")
        downloadpath = input("\nPlease paste the URL/ADDRESS/LINK-LOCATION of the hashcat binaries download button EG:https://hashcat.net/files/hashcat-3.6.0.7z \033[1;31;48m~# \033[0;39;48m")
        os.system("sudo apt install p7zip p7zip-full -y;cd %s;wget %s;7z x hashcat-*;git clone https://github.com/hashcat/hashcat-utils.git;cd hashcat-utils/src/;make" %(hashpath, downloadpath))
        #os.system("cd %s;git clone https://github.com/hashcat/hashcat.git;cd hashcat/;git submodule update --init;make;cd ..;git clone https://github.com/hashcat/hashcat-utils.git;cd hashcat-utils/src/;make" %(hashpath))
        os.system("\necho '\033[1;32;48m[+] \033[1;39;48mHashcat is now ready to use, it will be inside the folder you chose \033[0;39;48m' ")
        os._exit(1)
    else:
        title()
airscript-old-stable.py 文件源码 项目:Airscript-ng 作者: Sh3llcod3 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def drifunc(): #Installs downloaded drivers
    import os
    from tkinter.filedialog import askopenfilename, Tk as snak
    snak().withdraw()
    def Nvidia():
        os.system("clear")
        global nvenc
        path = input("Please select where the NVIDIA driver file is located. Press enter (you may have to answer yes to some options) \033[1;31;48m~# \033[0;39;48m")
        nvenc = askopenfilename()
        nvenc = str(nvenc)
        os.system("clear")
        input("\n|MENU|POST_CRACK|GPU|DRIVER_INSTALL|NVIDIA|(Please remove any previous drivers/driver downloads and hit enter) \033[1;31;48m~# \033[0;39;48m")
        os.system("cd %s;sudo ./NVIDIA-Linux*" %(nvenc))
        print("echo NVIDIA driver is installed!")
        print("now reboot, if you see any error, please head to: 'https://goo.gl/f1GU1F'")
    def AMD():
        os.system("clear")
        from tkinter import filedialog
        from tkinter import Tk
        global AMDlol 
        AMDlol = input("Please select the folder where the AMD driver tar.xz file is located. Press enter \033[1;31;48m~# \033[0;39;48m")
        AMDlol = filedialog.askdirectory()
        AMDlol = str(AMDlol)
        os.system("clear")
        input("\n|MENU|POST_CRACK|GPU|DRIVER_INSTALL|AMD|(Please remove any previous drivers/driver downloads and hit enter) \033[1;31;48m~# \033[0;39;48m")
        os.system("cd %s;tar -Jxvf amdgpu-pro*;cd amdgpu-pro*;./amdgpu-pro-install -y" %(AMDlol))
        print("echo AMD driver is installed!")
        print("now reboot, if you see any error, type: 'amdgpu-pro-uninstall' and reboot.")
    print("""

???????   ???????????????????? ?????? ???     ???         ??????? ??????? ??????   ?????????????????? ????????
????????  ???????????????????????????????     ???         ??????????????????????   ???????????????????????????
????????? ???????????   ???   ???????????     ???         ???  ?????????????????   ?????????  ????????????????
?????????????????????   ???   ???????????     ???         ???  ?????????????????? ??????????  ????????????????
?????? ??????????????   ???   ???  ???????????????????    ???????????  ?????? ??????? ???????????  ???????????
??????  ?????????????   ???   ???  ???????????????????    ??????? ???  ??????  ?????  ???????????  ???????????


""")
    print("This is the driver installation screen. Your options are:")
    print("\n\n\033[1;35;48mType [1] - Install the NVIDIA-LINUX driver for Hashcat (NVIDIA GTX 900,10 Series)")
    print("\033[1;34;48mType [2] - Install the AMDGPU-PRO driver to use Hashcat with an AMD gpu (MOST GPUs, check hashcat.net)")
    sel = input("\n|MENU|POST_CRACK|GPU|DRIVER_INSTALL|(Type number) >>")
    if sel == "":
        drifunc()
    if sel == "1":
        Nvidia()
    if sel == "2":
        AMD()
no-color-airscript-ng.py 文件源码 项目:Airscript-ng 作者: Sh3llcod3 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def hashcatdownloadfunc(): #GIT CLONES AND MAKE-BUILDs HASHCAT!
    import os, webbrowser, time
    from tkinter import filedialog
    from tkinter import Tk
    os.system("clear")
    print("""

              a          a
             aaa        aaa
            aaaaaaaaaaaaaaaa
           aaaaaaaaaaaaaaaaaa
          aaaaafaaaaaaafaaaaaa
          aaaaaaaaaaaaaaaaaaaa
           aaaaaaaaaaaaaaaaaa
            aaaaaaa  aaaaaaa
             aaaaaaaaaaaaaa
  a         aaaaaaaaaaaaaaaa
 aaa       aaaaaaaaaaaaaaaaaa
 aaa      aaaaaaaaaaaaaaaaaaaa
 aaa     aaaaaaaaaaaaaaaaaaaaaa
 aaa    aaaaaaaaaaaaaaaaaaaaaaaa
  aaa   aaaaaaaaaaaaaaaaaaaaaaaa
  aaa   aaaaaaaaaaaaaaaaaaaaaaaa
  aaa    aaaaaaaaaaaaaaaaaaaaaa
   aaa    aaaaaaaaaaaaaaaaaaaa
    aaaaaaaaaaaaaaaaaaaaaaaaaa
     aaaaaaaaaaaaaaaaaaaaaaaaa

???  ??? ?????? ???????????  ??? ??????? ?????? ?????????    
???  ??????????????????????  ????????????????????????????       
???????????????????????????????????     ????????   ???       
???????????????????????????????????     ????????   ???       
???  ??????  ??????????????  ??????????????  ???   ???       
???  ??????  ??????????????  ??? ??????????  ???   ???                                                                   

""")
    if input("Download and setup hashcat for GPU-WPA cracking? [y/n] >> ").lower().startswith("y"):
        os.system("clear")
        print("\nWhere would you like hashcat installed?")
        input("\n|MENU|POST_CRACK|GPU|HASHCAT_DOWNLOAD|(Please delete any older versions and press enter to choose directory) >>")
        global hashpath
        Tk().withdraw()
        hashpath = filedialog.askdirectory()
        hashpath = str(hashpath)
        print("\nA browser window will now open. ALT+TAB back to the terminal")
        time.sleep(3)
        webbrowser.open("https://hashcat.net/")
        #print("Please right-click and copy/paste link location on the button next to hashcat binaries")
        downloadpath = input("\nPlease paste the URL/ADDRESS/LINK-LOCATION of the hashcat binaries download button EG:https://hashcat.net/files/hashcat-3.6.0.7z ~# ")
        os.system("sudo apt install p7zip p7zip-full -y;cd %s;wget %s;7z x hashcat-*;git clone https://github.com/hashcat/hashcat-utils.git;cd hashcat-utils/src/;make" %(hashpath, downloadpath))
        #os.system("cd %s;git clone https://github.com/hashcat/hashcat.git;cd hashcat/;git submodule update --init;make;cd ..;git clone https://github.com/hashcat/hashcat-utils.git;cd hashcat-utils/src/;make" %(hashpath))
        os.system("\necho '[+] Hashcat is now ready to use, it will be inside the folder you chose ' ")
        os._exit(1)
    else:
        title()
no-color-airscript-ng.py 文件源码 项目:Airscript-ng 作者: Sh3llcod3 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def drifunc(): #Installs downloaded drivers
    import os
    from tkinter.filedialog import askopenfilename, Tk as snak
    snak().withdraw()
    def Nvidia():
        os.system("clear")
        global nvenc
        path = input("Please select where the NVIDIA driver file is located. Press enter (you may have to answer yes to some options) ~# ")
        nvenc = askopenfilename()
        nvenc = str(nvenc)
        os.system("clear")
        input("\n|MENU|POST_CRACK|GPU|DRIVER_INSTALL|NVIDIA|(Please remove any previous drivers/driver downloads and hit enter) ~# ")
        os.system("cd %s;sudo ./NVIDIA-Linux*" %(nvenc))
        print("echo NVIDIA driver is installed!")
        print("now reboot, if you see any error, please head to: 'https://goo.gl/f1GU1F'")
    def AMD():
        os.system("clear")
        from tkinter import filedialog
        from tkinter import Tk
        global AMDlol 
        AMDlol = input("Please select the folder where the AMD driver tar.xz file is located. Press enter ~# ")
        AMDlol = filedialog.askdirectory()
        AMDlol = str(AMDlol)
        os.system("clear")
        input("\n|MENU|POST_CRACK|GPU|DRIVER_INSTALL|AMD|(Please remove any previous drivers/driver downloads and hit enter) ~# ")
        os.system("cd %s;tar -Jxvf amdgpu-pro*;cd amdgpu-pro*;./amdgpu-pro-install -y" %(AMDlol))
        print("echo AMD driver is installed!")
        print("now reboot, if you see any error, type: 'amdgpu-pro-uninstall' and reboot.")
    print("""

???????   ???????????????????? ?????? ???     ???         ??????? ??????? ??????   ?????????????????? ????????
????????  ???????????????????????????????     ???         ??????????????????????   ???????????????????????????
????????? ???????????   ???   ???????????     ???         ???  ?????????????????   ?????????  ????????????????
?????????????????????   ???   ???????????     ???         ???  ?????????????????? ??????????  ????????????????
?????? ??????????????   ???   ???  ???????????????????    ???????????  ?????? ??????? ???????????  ???????????
??????  ?????????????   ???   ???  ???????????????????    ??????? ???  ??????  ?????  ???????????  ???????????


""")
    print("This is the driver installation screen. Your options are:")
    print("\n\nType [1] - Install the NVIDIA-LINUX driver for Hashcat (NVIDIA GTX 900,10 Series)")
    print("Type [2] - Install the AMDGPU-PRO driver to use Hashcat with an AMD gpu (MOST GPUs, check hashcat.net)")
    sel = input("\n|MENU|POST_CRACK|GPU|DRIVER_INSTALL|(Type number) >>")
    if sel == "":
        drifunc()
    if sel == "1":
        Nvidia()
    if sel == "2":
        AMD()
airscript-ng.py 文件源码 项目:Airscript-ng 作者: Sh3llcod3 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def hashcatdownloadfunc(): #GIT CLONES AND MAKE-BUILDs HASHCAT!
    import os, webbrowser, time
    from tkinter import filedialog
    from tkinter import Tk
    os.system("clear")
    print("""\033[0;33;48m

              a          a
             aaa        aaa
            aaaaaaaaaaaaaaaa
           aaaaaaaaaaaaaaaaaa
          aaaaafaaaaaaafaaaaaa
          aaaaaaaaaaaaaaaaaaaa
           aaaaaaaaaaaaaaaaaa
            aaaaaaa  aaaaaaa
             aaaaaaaaaaaaaa
  a         aaaaaaaaaaaaaaaa
 aaa       aaaaaaaaaaaaaaaaaa
 aaa      aaaaaaaaaaaaaaaaaaaa
 aaa     aaaaaaaaaaaaaaaaaaaaaa
 aaa    aaaaaaaaaaaaaaaaaaaaaaaa
  aaa   aaaaaaaaaaaaaaaaaaaaaaaa
  aaa   aaaaaaaaaaaaaaaaaaaaaaaa
  aaa    aaaaaaaaaaaaaaaaaaaaaa
   aaa    aaaaaaaaaaaaaaaaaaaa
    aaaaaaaaaaaaaaaaaaaaaaaaaa
     aaaaaaaaaaaaaaaaaaaaaaaaa

???  ??? ?????? ???????????  ??? ??????? ?????? ?????????    
???  ??????????????????????  ????????????????????????????       
???????????????????????????????????     ????????   ???       
???????????????????????????????????     ????????   ???       
???  ??????  ??????????????  ??????????????  ???   ???       
???  ??????  ??????????????  ??? ??????????  ???   ???                                                                   
\033[0;39;48m
""")
    if input("\033[1;39;48mDownload and setup hashcat for GPU-WPA cracking? [y/n] >> ").lower().startswith("y"):
        os.system("clear")
        print("\nWhere would you like hashcat installed?")
        input("\n|MENU|POST_CRACK|GPU|HASHCAT_DOWNLOAD|(Please delete any older versions and press enter to choose directory) >>")
        global hashpath
        Tk().withdraw()
        hashpath = filedialog.askdirectory()
        hashpath = str(hashpath)
        print("\nA browser window will now open. ALT+TAB back to the terminal")
        time.sleep(3)
        webbrowser.open("https://hashcat.net/")
        #print("Please right-click and copy/paste link location on the button next to hashcat binaries")
        downloadpath = input("\nPlease paste the URL/ADDRESS/LINK-LOCATION of the hashcat binaries download button EG:https://hashcat.net/files/hashcat-3.6.0.7z \033[1;31;48m~# \033[0;39;48m")
        os.system("sudo apt install p7zip p7zip-full -y;cd %s;wget %s;7z x hashcat-*;git clone https://github.com/hashcat/hashcat-utils.git;cd hashcat-utils/src/;make" %(hashpath, downloadpath))
        #os.system("cd %s;git clone https://github.com/hashcat/hashcat.git;cd hashcat/;git submodule update --init;make;cd ..;git clone https://github.com/hashcat/hashcat-utils.git;cd hashcat-utils/src/;make" %(hashpath))
        os.system("\necho '\033[1;32;48m[+] \033[1;39;48mHashcat is now ready to use, it will be inside the folder you chose \033[0;39;48m' ")
        os._exit(1)
    else:
        title()


问题


面经


文章

微信
公众号

扫码关注公众号