Python wx.DirDialog() Examples

The following are 26 code examples of wx.DirDialog(). 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 wx , or try the search function .
Example #1
Source File: ProjectController.py    From OpenPLC_Editor with GNU General Public License v3.0 6 votes vote down vote up
def SaveProjectAs(self):
        # Ask user to choose a path with write permissions
        if wx.Platform == '__WXMSW__':
            path = os.getenv("USERPROFILE")
        else:
            path = os.getenv("HOME")
        dirdialog = wx.DirDialog(
            self.AppFrame, _("Choose a directory to save project"), path, wx.DD_NEW_DIR_BUTTON)
        answer = dirdialog.ShowModal()
        dirdialog.Destroy()
        if answer == wx.ID_OK:
            newprojectpath = dirdialog.GetPath()
            if os.path.isdir(newprojectpath):
                if self.CheckNewProjectPath(self.ProjectPath, newprojectpath):
                    self.ProjectPath, old_project_path = newprojectpath, self.ProjectPath
                    self.SaveProject(old_project_path)
                    self._setBuildPath(self.BuildPath)
                return True
        return False 
Example #2
Source File: esafenet_gui.py    From E-Safenet with GNU General Public License v2.0 6 votes vote down vote up
def of(self, event):  # wxGlade: MainFrame.<event_handler>
        filename = ""  # Use  filename as a flag
        dlg = wx.DirDialog(self, message="Choose a folder")
 
        if dlg.ShowModal() == wx.ID_OK:
            dirname = dlg.GetPath()
        dlg.Destroy()
        self.texts.append("")
        if dirname:
           for(root, dirs, files) in os.walk(dirname):
               for f in files:
                   with open(root + "/" + f, "rb") as fh:
                       fi = fh.read()[512:]
                       l_off = len(fi) % 512
                       self.texts[0] += fi + "\x00"*(512-l_off)
                       #self.texts.append(fh.read()) 
Example #3
Source File: wxgui.py    From pyshortcuts with MIT License 6 votes vote down vote up
def onBrowseFolder(self, event=None):
        defdir = self.txt_folder.GetValue()
        if defdir in ('', 'Desktop'):
            defdir = DESKTOP
        dlg = wx.DirDialog(self,
                           message='Select Folder for Shortcut',
                           defaultPath=defdir,
                           style = wx.DD_DEFAULT_STYLE)

        if dlg.ShowModal() == wx.ID_OK:
            folder = os.path.abspath(dlg.GetPath())
            desktop = DESKTOP
            if folder.startswith(desktop):
                folder.replace(desktop, '')
                if folder.startswith('/'):
                    folder = folder[1:]
            self.txt_folder.SetValue(folder)
        dlg.Destroy() 
Example #4
Source File: chronolapse.py    From chronolapse with MIT License 6 votes vote down vote up
def dirBrowser(self, message, defaultpath):
        # show dir dialog
        dlg = wx.DirDialog(
            self, message=message,
            defaultPath= defaultpath,
            style=wx.DD_DEFAULT_STYLE)

        # Show the dialog and retrieve the user response.
        if dlg.ShowModal() == wx.ID_OK:
            # load directory
            path = dlg.GetPath()

        else:
            path = ''

        # Destroy the dialog.
        dlg.Destroy()
        return path 
Example #5
Source File: archiveplayer.py    From webarchiveplayer with GNU General Public License v3.0 6 votes vote down vote up
def select_file(self):
        style = wx.FD_OPEN | wx.FD_FILE_MUST_EXIST | wx.FD_MULTIPLE
        #dialog = wx.DirDialog(top, 'Please select a directory containing archive files (WARC or ARC)', style=style)
        dialog = wx.FileDialog(parent=self,
                               message='Please select a web archive (WARC or ARC) file',
                               wildcard='WARC or ARC (*.gz; *.warc; *.arc)|*.gz;*.warc;*.arc',
                               #wildcard='WARC or ARC (*.gz; *.warc; *.arc)|*.gz; *.warc; *.arc',
                               style=style)

        if dialog.ShowModal() == wx.ID_OK:
            paths = dialog.GetPaths()
        else:
            paths = None

        dialog.Destroy()
        return paths


#================================================================= 
Example #6
Source File: create_new_project.py    From DeepLabCut with GNU Lesser General Public License v3.0 5 votes vote down vote up
def select_working_dir(self, event):
        cwd = os.getcwd()
        dlg = wx.DirDialog(
            self,
            "Choose the directory where your project will be saved:",
            cwd,
            style=wx.DD_DEFAULT_STYLE,
        )
        if dlg.ShowModal() == wx.ID_OK:
            self.dir = dlg.GetPath() 
Example #7
Source File: frame_scan.py    From bookhub with MIT License 5 votes vote down vote up
def OnStartScan(self, event):
        # clear log if too big
        if len(self.scan_log.GetValue()) > 1024:
            self.scan_log.SetValue('')
        dlg = wx.DirDialog(self, "Choose a directory:")
        if dlg.ShowModal() == wx.ID_OK:
            self.startBtn.Disable()
            self.stopBtn.Enable()
            scan_thread = FileScan(dlg.GetPath(), self)
            self.threads.append(scan_thread)
            scan_thread.start() 
Example #8
Source File: Beremiz_service.py    From OpenPLC_Editor with GNU General Public License v3.0 5 votes vote down vote up
def OnTaskBarChangeWorkingDir(self, evt):
                dlg = wx.DirDialog(None, _("Choose a working directory "), self.pyroserver.workdir, wx.DD_NEW_DIR_BUTTON)
                if dlg.ShowModal() == wx.ID_OK:
                    self.pyroserver.workdir = dlg.GetPath()
                    self.pyroserver.Restart() 
Example #9
Source File: DirBrowseButton.py    From EventGhost with GNU General Public License v2.0 5 votes vote down vote up
def __init__(
        self,
        parent,
        id=-1,
        pos = wx.DefaultPosition,
        size = wx.DefaultSize,
        style = wx.TAB_TRAVERSAL,
        labelText = 'Select a directory:',
        buttonText = 'Browse',
        toolTip = 'Type directory name or browse to select',
        dialogTitle = '',
        startDirectory = '.',
        changeCallback = None,
        dialogClass = wx.DirDialog,
        newDirectory = False,
        name = 'dirBrowseButton'
    ):
        eg.FileBrowseButton.__init__(
            self,
            parent,
            id,
            pos,
            size,
            style,
            labelText,
            buttonText,
            toolTip,
            dialogTitle,
            startDirectory,
            changeCallback = changeCallback,
            name = name
        )
        self.dialogClass = dialogClass
        self.newDirectory = newDirectory 
Example #10
Source File: GUI_utils.py    From topoflow with MIT License 5 votes vote down vote up
def Get_Directory():

    dialog = wx.DirDialog(None, "Choose a directory:", \
                          style=wx.DD_DEFAULT_STYLE | wx.DD_NEW_DIR_BUTTON)
    if (dialog.ShowModal() == wx.ID_OK):
        directory = dialog.GetPath()
    else:
        directory = None
    dialog.Destroy()
    
    return directory
    
#   Get_Directory()
#---------------------------------------------------------------- 
Example #11
Source File: dialog_settings.py    From iqiyi-parser with MIT License 5 votes vote down vote up
def event_button_path(self, event):
        dlg = wx.DirDialog(self, style=wx.FD_DEFAULT_STYLE)
        if dlg.ShowModal() == wx.ID_OK:
            self.textctrl_path.SetValue(dlg.GetPath()) 
Example #12
Source File: SettingsWindow.py    From BitTorrent with GNU General Public License v3.0 5 votes vote down vote up
def get_save_in(self, *e):
        d = wx.DirDialog(self, "", style=wx.DD_DEFAULT_STYLE|wx.DD_NEW_DIR_BUTTON)
        d.SetPath(self.config['save_in'])
        if d.ShowModal() == wx.ID_OK:
            path = d.GetPath()
            self.saving_panel.save_in_button.SetLabel(path)
            self.setfunc('save_in', path) 
Example #13
Source File: __init__.py    From BitTorrent with GNU General Public License v3.0 5 votes vote down vote up
def directory_dialog(self):
        dialog = wx.DirDialog(self.parent,
                              message=self.directory_dialog_title,
                              style=wx.DD_DEFAULT_STYLE|wx.DD_NEW_DIR_BUTTON)
        dialog.SetPath(self.get_choice())
        return dialog 
Example #14
Source File: __init__.py    From BitTorrent with GNU General Public License v3.0 5 votes vote down vote up
def dialog(self):
        dialog = wx.DirDialog(self.parent,
                              message=self.dialog_title,
                              style=wx.DD_DEFAULT_STYLE|wx.DD_NEW_DIR_BUTTON)
        dialog.SetPath(self.get_choice())
        return dialog 
Example #15
Source File: librian_panel.py    From Librian with Mozilla Public License 2.0 5 votes vote down vote up
def 開啓工程(self, 工程路徑=None):
        if 工程路徑:
            self.同調(工程路徑)
        else:
            with wx.DirDialog(self.窗口, "选择文件夹") as dlg:
                dlg.SetPath(str(Path('./Librian本體/project').resolve()))
                if dlg.ShowModal() == wx.ID_OK:
                    self.同調(dlg.GetPath()) 
Example #16
Source File: widget_pack.py    From me-ica with GNU Lesser General Public License v2.1 5 votes vote down vote up
def __init__(self, parent, *args, **kwargs):
    wx.DirDialog.__init__(self, parent, 'Select Directory', style=wx.DD_DEFAULT_STYLE) 
Example #17
Source File: networkedit.py    From CANFestivino with GNU Lesser General Public License v2.1 5 votes vote down vote up
def OnOpenProjectMenu(self, event):
        if self.NodeList:
            defaultpath = os.path.dirname(self.NodeList.GetRoot())
        else:
            defaultpath = os.getcwd()
        dialog = wx.DirDialog(self , _("Choose a project"), defaultpath, 0)
        if dialog.ShowModal() == wx.ID_OK:
            projectpath = dialog.GetPath()
            if os.path.isdir(projectpath):
                manager = NodeManager()
                nodelist = NodeList(manager)
                result = nodelist.LoadProject(projectpath)
                if not result:
                    self.Manager = manager
                    self.NodeList = nodelist
                    self.NodeList.SetCurrentSelected(0)
                    
                    self.RefreshNetworkNodes()
                    self.RefreshBufferState()
                    self.RefreshTitle()
                    self.RefreshProfileMenu()
                    self.RefreshMainMenu()
                else:
                    message = wx.MessageDialog(self, result, _("Error"), wx.OK|wx.ICON_ERROR)
                    message.ShowModal()
                    message.Destroy()
        dialog.Destroy() 
Example #18
Source File: networkedit.py    From CANFestivino with GNU Lesser General Public License v2.1 5 votes vote down vote up
def OnNewProjectMenu(self, event):
        if self.NodeList:
            defaultpath = os.path.dirname(self.NodeList.GetRoot())
        else:
            defaultpath = os.getcwd()
        dialog = wx.DirDialog(self , _("Choose a project"), defaultpath, wx.DD_NEW_DIR_BUTTON)
        if dialog.ShowModal() == wx.ID_OK:
            projectpath = dialog.GetPath()
            if os.path.isdir(projectpath) and len(os.listdir(projectpath)) == 0:
                manager = NodeManager()
                nodelist = NodeList(manager)
                result = nodelist.LoadProject(projectpath)
                if not result:
                    self.Manager = manager
                    self.NodeList = nodelist
                    self.NodeList.SetCurrentSelected(0)
                                        
                    self.RefreshNetworkNodes()
                    self.RefreshBufferState()
                    self.RefreshTitle()
                    self.RefreshProfileMenu()
                    self.RefreshMainMenu()
                else:
                    message = wx.MessageDialog(self, result, _("ERROR"), wx.OK|wx.ICON_ERROR)
                    message.ShowModal()
                    message.Destroy() 
Example #19
Source File: mainframe.py    From youtube-dl-gui with The Unlicense 5 votes vote down vote up
def _on_savepath(self, event):
        dlg = wx.DirDialog(self, self.CHOOSE_DIRECTORY, self._path_combobox.GetStringSelection())

        if dlg.ShowModal() == wx.ID_OK:
            path = dlg.GetPath()

            self._path_combobox.Append(path)
            self._path_combobox.SetValue(path)
            self._update_savepath(None)

        dlg.Destroy() 
Example #20
Source File: chooser.py    From Gooey with MIT License 5 votes vote down vote up
def getDialog(self):
        options = self.Parent._options
        return wx.DirDialog(self, message=options.get('message', _('choose_folder')),
                            defaultPath=options.get('default_path', os.getcwd())) 
Example #21
Source File: choosers.py    From pyFileFixity with MIT License 5 votes vote down vote up
def on_button(self, evt):
    dlg = wx.DirDialog(self.panel, 'Select directory', style=wx.DD_DEFAULT_STYLE)
    result = (dlg.GetPath()
              if dlg.ShowModal() == wx.ID_OK
              else None)
    if result:
      self.text_box.SetLabelText(result) 
Example #22
Source File: guiminer.py    From poclbm with GNU General Public License v3.0 5 votes vote down vote up
def set_blockchain_directory(self, event):
        """Set the path to the blockchain data directory."""
        defaultPath = os.path.join(os.getenv("APPDATA"), "Bitcoin")
        dialog = wx.DirDialog(self,
                              _("Select path to blockchain"),
                              defaultPath=defaultPath,
                              style=wx.DD_DIR_MUST_EXIST)
        if dialog.ShowModal() == wx.ID_OK:
            path = dialog.GetPath()
            if os.path.exists(path):
                self.blockchain_directory = path
        dialog.Destroy() 
Example #23
Source File: GoSyncSettingPage.py    From gosync with GNU General Public License v2.0 5 votes vote down vote up
def OnChangeMirror(self, event):
        new_dir_help = "Your new local mirror directory is set. This will take effect after GoSync restart.\n\nPlease note that GoSync hasn't moved your files from old location. You would need to copy or move your current directory to new location before restarting GoSync."

        dlg = wx.DirDialog(None, "Choose target directory", "",
                           wx.DD_DEFAULT_STYLE | wx.DD_DIR_MUST_EXIST)

        if dlg.ShowModal() == wx.ID_OK:
            self.sync_model.SetLocalMirrorDirectory(dlg.GetPath())
            resp = wx.MessageBox(new_dir_help, "IMPORTANT INFORMATION", (wx.OK | wx.ICON_WARNING))
            self.md.SetLabel(self.sync_model.GetLocalMirrorDirectory())

        dlg.Destroy() 
Example #24
Source File: cfgdlg.py    From trelby with GNU General Public License v2.0 5 votes vote down vote up
def OnBrowse(self, event):
        dlg = wx.DirDialog(
            cfgFrame, defaultPath = self.cfg.scriptDir,
            style = wx.DD_NEW_DIR_BUTTON)

        if dlg.ShowModal() == wx.ID_OK:
            self.scriptDirEntry.SetValue(dlg.GetPath())

        dlg.Destroy() 
Example #25
Source File: watermarkdlg.py    From trelby with GNU General Public License v2.0 5 votes vote down vote up
def OnBrowse(self, event):
        dlg = wx.DirDialog(
            self.frame, style = wx.DD_NEW_DIR_BUTTON)

        if dlg.ShowModal() == wx.ID_OK:
            self.dirEntry.SetValue(dlg.GetPath())

        dlg.Destroy() 
Example #26
Source File: widget_pack.py    From pyFileFixity with MIT License 4 votes vote down vote up
def get_path(self, dlg):
    if isinstance(dlg, wx.DirDialog):
      return maybe_quote(dlg.GetPath())
    else:
      paths = dlg.GetPaths()
      return maybe_quote(paths[0]) if len(paths) < 2 else ' '.join(map(maybe_quote, paths))