open dialog box for choosing a working directory
490046
def get_DIR(self, WD=None):
        

        if "-WD" in sys.argv and FIRST_RUN:
            ind = sys.argv.index('-WD')
            self.WD = sys.argv[ind + 1]
        elif not WD:  # if no arg was passed in for WD, make a dialog to choose one
            dialog = wx.DirDialog(None, "Choose a directory:", defaultPath=self.currentDirectory,
                                  style=wx.DD_DEFAULT_STYLE | wx.DD_NEW_DIR_BUTTON | wx.DD_CHANGE_DIR)
            ok = self.show_dlg(dialog)
            if ok == wx.ID_OK:
                self.WD = dialog.GetPath()
            else:
                self.WD = os.getcwd()
            dialog.Destroy()
        self.WD = os.path.realpath(self.WD)
        # name measurement file
        if self.data_model == 3:
            meas_file = 'measurements.txt'
        else:
            meas_file = 'magic_measurements.txt'
        self.magic_file = os.path.join(self.WD, meas_file)
        # intialize GUI_log
        self.GUI_log = open(os.path.join(self.WD, "thellier_GUI.log"), 'w+')
        self.GUI_log.write("starting...\n")
        self.GUI_log.close()
        self.GUI_log = open(os.path.join(self.WD, "thellier_GUI.log"), 'a')
        os.chdir(self.WD)
        self.WD = os.getcwd()
423971
def open_in_browser(file_location):
    """"""

    # If just the name of the file was given, check if it's in the Current
    # Working Directory.
    if not os.path.isfile(file_location):
        file_location = os.path.join(os.getcwd(), file_location)
    if not os.path.isfile(file_location):
        raise IOError("\n\nFile not found.")

    #  For some reason OSX requires this adjustment (tested on 10.10.4)
    if sys.platform == "darwin":
        file_location = "file:///"+file_location

    new = 2  # open in a new tab, if possible
    webbrowser.get().open(file_location, new=new)
252878
def onFolderTreeClicked(self, proxyIndex):
        """"""
        if not proxyIndex.isValid():
            return

        index = self.proxyFileModel.mapToSource(proxyIndex)
        settings = QSettings()
        folder_path = self.fileModel.filePath(index)
        settings.setValue('mainwindow/workingDirectory', folder_path)
959225
static File openDirectoryDialog(Frame frame, File initialDir) {
    return openFileDialog(frame, null, initialDir, JFileChooser.DIRECTORIES_ONLY);
  }
618521
private void promptForFiles() {
        DialogProperties properties = new DialogProperties();
        properties.selection_mode = DialogConfigs.MULTI_MODE;
        properties.selection_type = DialogConfigs.FILE_SELECT;
        properties.root = new File(DialogConfigs.DEFAULT_DIR);
        properties.error_dir = new File(DialogConfigs.DEFAULT_DIR);
        properties.offset = new File(DialogConfigs.DEFAULT_DIR);

        Set<String> registeredExtensions = ArchiveFileFactory.getRegisteredExtensions();
        //api check
        if (Build.VERSION.SDK_INT >= 14)
            registeredExtensions.add("gpkg");
        registeredExtensions.add("map");

        String[] ret = new String[registeredExtensions.size()];
        ret = registeredExtensions.toArray(ret);
        properties.extensions = ret;

        FilePickerDialog dialog = new FilePickerDialog(getContext(), properties);
        dialog.setTitle("Select a File");
        dialog.setDialogSelectionListener(new DialogSelectionListener() {
            @Override
            public void onSelectedFilePaths(String[] files) {
                //files is the array of the paths of files selected by the Application User.
                setProviderConfig(files);
            }

        });
        dialog.show();
    }
974990
def setup_dir(self):
        """"""
        cd = self.opts.cd or self.config['crony'].get('directory')
        if cd:
            self.logger.debug(f'Adding cd to {cd}')
            self.cmd = f'cd {cd} && {self.cmd}'
1115927
def open_user_directory_path(self):
        """"""
        # noinspection PyCallByClass,PyTypeChecker
        directory_name = QFileDialog.getExistingDirectory(
            self,
            self.tr('Results directory'),
            self.leUserDirectoryPath.text(),
            QFileDialog.ShowDirsOnly)
        if directory_name:
            self.leUserDirectoryPath.setText(directory_name)
502073
def step_use_curdir_as_working_directory(context):
    
    context.workdir = os.path.abspath(".")
    command_util.ensure_workdir_exists(context)
1233877
def on_scenario_directory_radio_toggled(self, flag):
        
        if flag:
            self.output_directory.setText(self.source_directory.text())
        self.output_directory_chooser.setEnabled(not flag)
1359275
def _interact_with_folder(self, output_folder, action):
        
        if not action in ('r', 'w'):
            raise ValueError("action must be either 'r' or 'w'.")
        for key, item in self.__dict__.items():
            if isinstance(item, dict):
                for side in ("left", "right"):
                    filename = os.path.join(output_folder,
                                            "{}_{}.npy".format(key, side))
                    if action == 'w':
                        np.save(filename, self.__dict__[key][side])
                    else:
                        self.__dict__[key][side] = np.load(filename)
            else:
                filename = os.path.join(output_folder, "{}.npy".format(key))
                if action == 'w':
                    np.save(filename, self.__dict__[key])
                else:
                    self.__dict__[key] = np.load(filename)
203454
def open_file_dialog(self):
        
        dialog = QtWidgets.QFileDialog
        sender = self.sender()
        if sender == self.btn_open_source:
            textbox = self.source_path
        elif sender == self.btn_open_target:
            textbox = self.target_path
        folder = dialog.getExistingDirectory(self, 'Select a file:', textbox.text(), options = QtWidgets.QFileDialog.ShowDirsOnly)
        if str(folder) != '':
            textbox.setText(folder)
            # load elements from file and display in tree
            if sender == self.btn_open_source:
                self.reset_avaliable(folder)
197875
def get_DIR(self):
        
        dlg = wx.DirDialog(self, "Choose a directory:", defaultPath=self.currentDirectory,
                           style=wx.DD_DEFAULT_STYLE | wx.DD_NEW_DIR_BUTTON | wx.DD_CHANGE_DIR)
        ok = self.show_dlg(dlg)
        if ok == wx.ID_OK:
            new_WD = dlg.GetPath()
            dlg.Destroy()
        else:
            new_WD = os.getcwd()
            dlg.Destroy()
        return new_WD
996001
def load(filters="*.*", text='Select a file, FACEFACE!', default_directory='default_directory'):
    
    # make sure the filters contains "*.*" as an option!
    if not '*' in filters.split(';'): filters = filters + ";;All files (*)"
    
    # if this type of pref doesn't exist, we need to make a new one
    if default_directory in _settings.keys(): default = _settings[default_directory]
    else:                                     default = ""
    
    # pop up the dialog
    result = _qtw.QFileDialog.getOpenFileName(None,text,default,filters)
    
    # If Qt5, take the zeroth element
    if _s._qt.VERSION_INFO[0:5] == "PyQt5": result = result[0]
    
    # Make sure it's a string
    result = str(result)    
    
    if result == '': return None
    else:
        _settings[default_directory] = _os.path.split(result)[0]
        return result
78868
def popup(self, title, callfn, initialdir=None):
        """"""
        super(DirectorySelection, self).popup(title, callfn, initialdir)
945091
def askForFolder(parent, msg = None):
    '''
    
    '''
    msg = msg or 'Select folder'
    caller = _callerName().split(".")
    name = "/".join([LAST_PATH, caller[-1]])
    namespace = caller[0]
    path = pluginSetting(name, namespace)
    folder =  QtWidgets.QFileDialog.getExistingDirectory(parent, msg, path)
    if folder:
        setPluginSetting(name, folder, namespace)
    return folder
686865
def filesavebox(msg=None, title=None, argInitialFile=None):
    
    return psidialogs.ask_file(message=msg, title=title, default=argInitialFile, save=True)
214462
def set_current_client_working_directory(self, directory):
        """"""
        shellwidget = self.get_current_shellwidget()
        if shellwidget is not None:
            shellwidget.set_cwd(directory)