Пример #1
0
 def __init__(self):
     super(WizardPageBasicProperties, self).__init__()
     self.ui = Ui_WizardPageBasicProperties()
     self.ui.setupUi(self)
     self.ui.lineEditTargetDir.setText(
         os.path.normpath(QDir.home().absolutePath()))
     self.show()
Пример #2
0
    def go_home(self):
        list1 = QDir.drives()
        for l in list1:
            print(l.absolutePath())

        self.le_path.setText(QDir.home().absolutePath())
        self.on_pb_load_path_clicked()
Пример #3
0
 def instructionManual(self):
     manualPath = os.path.dirname(
         os.path.realpath(__file__)) + r'/InstructionManual.docx'
     instructionManual = QDir.home().filePath(manualPath)
     url = bytearray(
         QUrl.fromLocalFile(instructionManual).toEncoded()).decode()
     text = '<a href={}>Instruction Manual</a>'.format(url)
     return text
Пример #4
0
 def on_import_clicked(self):
     """
     Handle when the import button is clicked on the UI
     :return:
     """
     (filename, _) = QFileDialog.getOpenFileName(self, 'Open File', QDir.home().path(), "Image Files (*.jpg)")
     if filename:
         self.load_image(filename)
Пример #5
0
 def on_save_clicked(self):
     """
     Handle when the save button is clicked on the UI
     :return:
     """
     (filename, _) = QFileDialog.getSaveFileName(self, 'Save File', QDir.home().path(), "Image Files (*.jpg)")
     if filename:
         cv2.imwrite(filename, self._processed_img)
Пример #6
0
 def setText(self):
     text, ok = QInputDialog.getText(
         self,
         "QInputDialog.getText()",
         "User name:",
         QLineEdit.Normal,
         QDir.home().dirName(),
     )
     if ok and text != "":
         self.textLabel.setText(text)
Пример #7
0
 def read_settings(self):
     settings = QSettings('MyWallet')
     if system() == 'Windows':
         self.set_current_path(QDir.home().path() + '/MyWallet/')
         settings = QSettings(self.__current_path + 'mywallet.conf', QSettings.IniFormat)
     settings.beginGroup(self.MAIN_SETTINGS)
     if settings.value('size'):
         self.resize(settings.value('size', type=QSize))
     if settings.value('position'):
         self.move(settings.value('position', type=QPoint))
     if settings.value('path') and settings.value('wallet_name'):
         self.set_current_path(settings.value('path'))
         self.__wallet_name = settings.value('wallet_name')
     else:
         if system() == 'Windows':
             self.set_current_path(QDir.home().path() + '/MyWallet/')
         elif system() == 'Linux':
             self.set_current_path(QDir.home().path() + '/.MyWallet/')
         self.__wallet_name = None
     settings.endGroup()
    def exportLayerAsShp(self,
                         layer,
                         time,
                         name="Apis_Export",
                         groupName="Temp",
                         styleName=None,
                         parent=None):
        # check if layer has features to be exported
        if layer.hasFeatures():
            # get previous directory
            saveDir = self.settings.value("APIS/working_dir",
                                          QDir.home().dirName())
            # save file dialog
            layerName = QFileDialog.getSaveFileName(
                parent, u"SHP Datei Export Speichern",
                saveDir + "\\" + "{0}_{1}".format(name, time), "*.shp")[0]

            if layerName:
                check = QFile(layerName)
                if check.exists():
                    if not QgsVectorFileWriter.deleteShapeFile(layerName):
                        QMessageBox.warning(
                            parent, "SHP Datei Export",
                            u"Es ist nicht möglich die SHP Datei {0} zu überschreiben!"
                            .format(layerName))
                        return

                error = QgsVectorFileWriter.writeAsVectorFormat(
                    layer, layerName, "UTF-8", layer.crs(), "ESRI Shapefile")
                if error[0] == QgsVectorFileWriter.NoError:
                    fof = FileOrFolder(parent=parent)
                    if fof == 0 or fof == 2:
                        # Shp Datei in QGIS laden
                        if styleName:
                            stylePath = self.stylesDir + self.__layers[
                                styleName]["style"]
                        self.requestShapeFile(layerName,
                                              groupName=groupName,
                                              addToCanvas=True,
                                              stylePath=stylePath)
                    if fof == 1 or fof == 2:
                        # Ordner öffnen
                        OpenFileOrFolder(os.path.split(layerName)[0])
                else:
                    QMessageBox.warning(
                        self, "SHP Datei Export",
                        u"Beim erstellen der SHP Datei ist ein Fehler aufgetreten: {0}"
                        .format(error))
        else:
            QMessageBox.warning(
                parent, "SHP Datei Export",
                u"Der zu exportierende Layer ({0}) hat keine Features.".format(
                    layer.name()))
            return
    def __init__(self, *args, **kwargs):
        QMainWindow.__init__(self, *args, **kwargs)
        self.Current_Dir = QDir.home().absolutePath()
        #self.Current_Dir = Wk_Dir
        self.setWindowTitle("Select Imags")
        self.setWindowModality(Qt.ApplicationModal)
        self.Left_Dock_Code()
        self.Central_Frame_Code()
        self.Right_Dock_Code()
        self.connect_Signals()

        self.wb_nav_left.setEnabled(False)
        self.wb_nav_right.setEnabled(False)
        self.bkgd_nav_left.setEnabled(False)
        self.bkgd_nav_right.setEnabled(False)
Пример #10
0
    def on_setupButton_clicked(self):
        """
		Configures and starts the spider wizard
		"""
        self.configName = str(self.spiderConfigurationsComboBox.currentText())
        if self.configName == newconfig:
            self.configName = QDir.home().dirName() + "-Configuration-" + str(
                date.today())
            self.wiz = SpiderConfigWizard(db=self.base,
                                          config=self.configName,
                                          ng=self.groWindow.ng)
            spiderConfiguration.fillWiz("", self.wiz, True)
        if self.wiz.exec_():
            spiderConfiguration.saveWiz(self.wiz)
            self.listConfigs(str(self.wiz.configName.text()))
Пример #11
0
    def initUI(self):

        self.model = QFileSystemModel()
        #print os.path.expanduser('~')
        homedir = QDir.home().path()
        print(homedir)
        #homedir = os.getenv('HOME')
        self.model.setRootPath(homedir)

        tv = QTreeView(self)
        tv.setModel(self.model)

        layout = QVBoxLayout()
        layout.addWidget(tv)
        self.setLayout(layout)
Пример #12
0
    def on_toolButtonBrowseFilename_clicked(self):
        # open browse filename dialog
        options = QFileDialog.Options()
        options |= QFileDialog.DontUseNativeDialog
        options |= QFileDialog.ShowDirsOnly
        options |= QFileDialog.DontResolveSymlinks

        targetDir = QFileDialog.getExistingDirectory(
            self,
            "Select/enter target directory for FMU",
            QDir.home().absolutePath(),
            options=options)
        if targetDir:
            self.ui.lineEditTargetDir.setText(targetDir)
            self.on_lineEditModelName_editingFinished()
            return True
Пример #13
0
 def _get_file_dialog(self):
     self.file_dialog = QFileDialog()
     options = QFileDialog.Options()
     options |= QFileDialog.ShowDirsOnly
     options |= QFileDialog.DontUseNativeDialog
     self.file_dialog.setFileMode(QFileDialog.DirectoryOnly)
     self.file_dialog.setOptions(options)
     self.file_dialog.setWindowTitle("Select Folder")
     self.file_dialog.setDirectory(QDir.home())
     self.file_dialog.setWindowFlag(Qt.WindowContextHelpButtonHint, False)
     self.file_dialog.findChildren(QListView)[0].setSelectionMode(
         QAbstractItemView.ExtendedSelection)
     self.file_dialog.findChildren(QTreeView)[0].setSelectionMode(
         QAbstractItemView.ExtendedSelection)
     # self.file_dialog.setFixedSize(800, 600)
     if self.file_dialog.exec():
         self.selected_folders = self.file_dialog.selectedFiles()
Пример #14
0
    def __init__(self):
        super().__init__()
        loadUi(get_file_realpath("kdFileFinder.ui"), self)
        self.setWindowIcon(QIcon(get_file_realpath('data/kdFileFinder.png')))

        self.exception_handler = global_exception_hander()
        self.exception_handler.patch_excepthook()

        self.lw_main.clicked.connect(self.on_lw_main_clicked)
        self.lw_main.doubleClicked.connect(self.on_lw_main_dbclicked)
        self.lw_main.installEventFilter(self)
        self.fileSystemModel = QFileSystemModel(self.lw_main)
        self.fileSystemModel.setReadOnly(True)
        self.fileFilter = self.fileSystemModel.filter()
        self.fileFilter_hidden = None
        home_path = QDir.home().absolutePath()
        self.le_path.setText(home_path)
        root = self.fileSystemModel.setRootPath(home_path)
        self.lw_main.setModel(self.fileSystemModel)
        self.lw_main.setRootIndex(root)
        self.lw_main.setWrapping(True)

        self.le_path.returnPressed.connect(self.on_pb_load_path_clicked)

        self.init_toolbar()
        self.bookmark_list = bookmark.get_bookmark()
        self.init_bookmark()
        self.session_list = set()
        self.last_open_file = set()

        self.isWindowsOS = sys.platform == "win32"
        self.lw_sidebar.itemDoubleClicked.connect(self.on_lw_sidebar_dbclicked)

        self.main_menu = QMenu()
        self.file_menu = QMenu()
        self.folder_menu = QMenu()
        self.toolbar_menu = toolbar_menu()
        self.file_popup_menu = file_menu()

        self.script_manager = script_manager()
Пример #15
0
 def _init_settings(self):
     if os.path.exists(self.fileName()):
         self.addOption("showOSD", "show", True)
         return
     '''save the user's last choice of save directory'''
     self.setOption("save", "save_op", QVariant(0))
     self.setOption("save", "folder", QVariant(QDir.home().absolutePath()))
     '''save the user's last choice of toolbar directory'''
     self.setOption("common_color_linewidth", "color_index", QVariant(3))
     self.setOption("common_color_linewidth", "linewidth_index",
                    QVariant(2))
     self.setOption("rect", "color_index", QVariant(3))
     self.setOption("rect", "linewidth_index", QVariant(2))
     self.setOption("ellipse", "color_index", QVariant(3))
     self.setOption("ellipse", "linewidth_index", QVariant(2))
     self.setOption("arrow", "color_index", QVariant(3))
     self.setOption("arrow", "linewidth_index", QVariant(2))
     self.setOption("line", "color_index", QVariant(3))
     self.setOption("line", "linewidth_index", QVariant(2))
     self.setOption("text", "color_index", QVariant(3))
     self.setOption("text", "fontsize_index", QVariant(12))
     self.setOption("showOSD", "show", True)
Пример #16
0
    def _init_settings(self):
        if os.path.exists(self.fileName()):
            self.addOption("showOSD", "show", True)
            return

        '''save the user's last choice of save directory'''
        self.setOption("save", "save_op", QVariant(0))
        self.setOption("save", "folder", QVariant(QDir.home().absolutePath()))
        '''save the user's last choice of toolbar directory'''
        self.setOption("common_color_linewidth", "color_index", QVariant(3))
        self.setOption("common_color_linewidth", "linewidth_index", QVariant(2))
        self.setOption("rect", "color_index", QVariant(3))
        self.setOption("rect", "linewidth_index", QVariant(2))
        self.setOption("ellipse", "color_index", QVariant(3))
        self.setOption("ellipse", "linewidth_index", QVariant(2))
        self.setOption("arrow", "color_index", QVariant(3))
        self.setOption("arrow", "linewidth_index", QVariant(2))
        self.setOption("line", "color_index", QVariant(3))
        self.setOption("line", "linewidth_index", QVariant(2))
        self.setOption("text", "color_index", QVariant(3))
        self.setOption("text", "fontsize_index", QVariant(12))
        self.setOption("showOSD", "show", True)
Пример #17
0
 def setText(self):
     text, ok = QInputDialog.getText(self, "QInputDialog.getText()",
             "User name:", QLineEdit.Normal, QDir.home().dirName())
     if ok and text != '':
         self.textLabel.setText(text)
Пример #18
0
from PyQt5.QtCore import QDir
from PyQt5.QtGui import QColor

AXES_COLOR_KEY = 'axesColor'
DEFAULT_AXES_COLOR = QColor.fromRgb(255, 0, 0)

SAMPLES_COLOR_KEY = 'samplesColor'
DEFAULT_SAMPLES_COLOR = QColor.fromRgb(0, 0, 255)

LAST_DIRECTORY_KEY = 'lastDirectory'
DEFAULT_LAST_DIRECTORY = QDir.home().canonicalPath()

DRAW_LINES_BETWEEN_SAMPLES_KEY = 'drawLinesBetweenSamples'
DEFAULT_DRAW_LINES_BETWEEN_SAMPLES = True
Пример #19
0
def GetExportPath():
    return QSettings().value(
        "APIS/latest_export_dir",
        QSettings(QSettings().value("APIS/config_ini"),
                  QSettings.IniFormat).value("APIS/working_dir",
                                             QDir.home().dirName()))
Пример #20
0
class Ui(QtWidgets.QMainWindow):
    currentDir = QDir.home()
    connected = False

    def __init__(self):
        super(Ui, self).__init__()
        uic.loadUi('../src/mainwindow.ui', self)

        self.stackedWidget.setCurrentIndex(0)
        self.Log.setSelectionMode(
            QtWidgets.QAbstractItemView.ExtendedSelection)

        self.ftp = FtpConnection()

        self.Path.setText(self.currentDir.absolutePath())
        self.passInput.setText("lookatme")
        self.userInput.setText("meeseeks")
        self.serverInput.setText("vbustamante.xyz")
        self.on_execute_clicked()
        self.show()


# SLOTS

    def on_execute_clicked(self):
        self.Log.clear()
        it = QDirIterator(self.currentDir, QDirIterator.NoIteratorFlags)
        while it.hasNext():
            self.Log.addItem(it.next())
        self.Path.setText(self.currentDir.absolutePath())

    def on_path_change(self):
        self.currentDir.cd(self.Path.text())
        self.on_execute_clicked()

    def on_back_clicked(self):
        self.currentDir.cdUp()
        self.on_execute_clicked()
        self.Path.setText(self.currentDir.absolutePath())

    def show_context_menu(self, click):
        globalpos = self.Log.mapToGlobal(click)
        menu = QtWidgets.QMenu()
        menu.addAction("Delete", lambda: self.erase_item())
        menu.addAction("Create", lambda: self.create_item())
        menu.addAction("Upload", lambda: self.upload_item())
        menu.exec(globalpos)

    def erase_item(self):
        items = self.Log.selectedItems()
        for item in items:
            confirmation = QMessageBox.question(
                self, "RASP", "Are you sure you want to delete " + item.text(),
                QMessageBox.Yes | QMessageBox.No)

            if confirmation == QMessageBox.Yes:
                dirtodelete = QDir(item.text())
                dirtodelete.removeRecursively()
                self.on_execute_clicked()

    def create_item(self):
        dirname, ok = QInputDialog.getText(self, "RASP", "Directory Name:")
        if ok and dirname:
            if self.currentDir.mkdir(dirname):
                QMessageBox.information(self, "RASP",
                                        "Directory successfully created.")
                self.on_execute_clicked()
            else:
                QMessageBox.information(self, "RASP",
                                        "Directory could not be created.")

    def on_item_double_clicked(self, item):
        iteminfo = QFileInfo(item.text())

        if iteminfo.isDir():
            self.currentDir.cd(item.text())
            self.on_execute_clicked()
            self.Path.setText(self.currentDir.absolutePath())
        else:
            QtGui.QDesktopServices.openUrl(QUrl.fromLocalFile(item.text()))

    def on_workspace_item_double_clicked(self, item):
        if item.text() == "Local":
            self.stackedWidget.setCurrentIndex(0)
        elif item.text() == "Server" and self.connected:
            self.load_remote_log()
            self.stackedWidget.setCurrentIndex(1)
        elif item.text() == "Server" and not self.connected:
            self.stackedWidget.setCurrentIndex(2)

    def on_connect_clicked(self):
        url = self.serverInput.text()
        user = self.userInput.text()
        pwd = self.passInput.text()

        try:
            self.ftp.connect(url)
            self.ftp.login(user, pwd)
        except:
            QMessageBox.information(self, "RASP",
                                    "Error connecting to server.")
            self.stackedWidget.setCurrentIndex(0)
            return

        self.connected = True
        self.stackedWidget.setCurrentIndex(1)
        self.load_remote_log()

    def on_disconnect_clicked(self):
        self.ftp.close()
        self.connected = False
        self.stackedWidget.setCurrentIndex(2)

    def load_remote_log(self):
        self.Path_2.setText(self.ftp.pwd())
        self.Log_2.clear()
        self.ftp.ls()
        for item in self.ftp.objList:
            self.Log_2.addItem(item['name'])

    def on_remote_back_double_clicked(self):
        self.ftp.cd("..")
        self.load_remote_log()

    def on_remote_item_double_clicked(self, item):
        self.ftp.cd(item.text())
        self.load_remote_log()

    def show_remote_context_menu(self, click):
        globalpos = self.Log.mapToGlobal(click)
        menu = QtWidgets.QMenu()
        menu.addAction("Delete", lambda: self.erase_remote_item())
        menu.addAction("Create", lambda: self.create_remote_item())
        menu.addAction("Download", lambda: self.download_remote_item())
        menu.exec(globalpos)

    def erase_remote_item(self):
        items = self.Log.selectedItems()
        for item in items:
            self.ftp.exclude(item.getText())

        return

    def create_remote_item(self):
        return
        #CREATE DIRECTORY

    def download_remote_item(self):
        return
        #DOWNLOAD FILE

    def upload_item(self):
        itemNames = []
        if not self.connected:
            QMessageBox.information(self, "RASP",
                                    "Connect to server before uploading.")
            return

        items = self.Log.selectedItems()
        for item in items:
            itemNames.append(item.text())

        if len(itemNames) == 1:
            for item in items:
                self.ftp.upload(item.text())
        else:
            self.ftp.uploadPool(itemNames)