def edit_tree_item(self):
        """
        if sender is self.tree_gui_settings this will open a filedialog and ask for a filepath
        this filepath will be updated in the field of self.tree_gui_settings that has been double clicked
        """

        def open_path_dialog_folder(path):
            """
            opens a file dialog to get the path to a file and
            """
            dialog = QtWidgets.QFileDialog()
            dialog.setFileMode(QtWidgets.QFileDialog.Directory)
            dialog.setOption(QtWidgets.QFileDialog.ShowDirsOnly, True)
            path = dialog.getExistingDirectory(self, 'Select a folder:', path)

            return path

        tree = self.sender()

        if tree == self.tree_gui_settings:

            index = tree.selectedIndexes()[0]
            model = index.model()

            if index.column() == 1:
                path = model.itemFromIndex(index).text()
                key = str(model.itemFromIndex(model.index(index.row(), 0)).text())
                if(key == 'gui_settings'):
                    path, _ = QtWidgets.QFileDialog.getSaveFileName(self, caption = 'Select a file:', directory = path, filter = '*.b26')
                    if path:
                        name, extension = os.path.splitext(path)
                        if extension != '.b26':
                            path = name + ".b26"
                else:
                    path = str(open_path_dialog_folder(path))

                if path != "":
                    self.gui_settings.update({key : str(os.path.normpath(path))})
                    self.fill_treeview(tree, self.gui_settings)
def edit_tree_item ( self ) : def open_path_dialog_folder ( path ) : dialog = QtWidgets . QFileDialog ( ) dialog . setFileMode ( QtWidgets . QFileDialog . Directory ) dialog . setOption ( QtWidgets . QFileDialog . ShowDirsOnly , True ) path = dialog . getExistingDirectory ( self , 'Select a folder:' , path ) return path tree = self . sender ( ) if tree == self . tree_gui_settings : index = tree . selectedIndexes ( ) [ 0 ] model = index . model ( ) if index . column ( ) == 1 : path = model . itemFromIndex ( index ) . text ( ) key = str ( model . itemFromIndex ( model . index ( index . row ( ) , 0 ) ) . text ( ) ) if ( key == 'gui_settings' ) : path , _ = QtWidgets . QFileDialog . getSaveFileName ( self , caption = 'Select a file:' , directory = path , filter = '*.b26' ) if path : name , extension = os . path . splitext ( path ) if extension != '.b26' : path = name + ".b26" else : path = str ( open_path_dialog_folder ( path ) ) if path != "" : self . gui_settings . update ( { key : str ( os . path . normpath ( path ) ) } ) self . fill_treeview ( tree , self . gui_settings )
if sender is self.tree_gui_settings this will open a filedialog and ask for a filepath
        this filepath will be updated in the field of self.tree_gui_settings that has been double clicked