예제 #1
0
 def _edit_path_button_clicked(self):
     path = str(
         QFileDialog.getExistingDirectory(
             self, "Choose a directory of text files."))
     if path != "":
         path = f"{path}/*.txt"
         self.path.setText(path)
예제 #2
0
 def inclusions_add(self):
     path = QFileDialog.getExistingDirectory()
     if path and not self.inclusions_list_widget.findItems(
         path, Qt.MatchFlag.MatchExactly
     ):
         self.inclusions_list_widget.addItem(path)
         self.logger.info("Inclusion added.")
예제 #3
0
파일: app.py 프로젝트: Z-zxQ/yt-downloader
 def setOutputPath(self):
     # update the output path
     path = str(QFileDialog.getExistingDirectory(self, "Select Output Directory"))
     if path:
         self.outputPath = path
         # update tooltip
         self.outputBtn.setToolTip(path)
예제 #4
0
 def set_download_path(self):
     """设置下载路径"""
     dl_path = QFileDialog.getExistingDirectory(self, "选择文件下载保存文件夹", self.cwd)
     dl_path = os.path.normpath(dl_path)  # windows backslash
     if dl_path == self.dl_path or dl_path == ".":
         return None
     self.dl_path_var.setText(dl_path)
     self.dl_path = dl_path
예제 #5
0
    def open_path_selection_dialog(self) -> None:
        file_path: str = str(pathlib.Path(__file__).parent.resolve())
        file_path = file_path[:file_path.find('src') - 1]

        self.header_output_path_input.setText(
            QFileDialog.getExistingDirectory(
                self, "Open Directory", file_path,
                QFileDialog.Option.ShowDirsOnly
                | QFileDialog.Option.DontResolveSymlinks))
예제 #6
0
 def getFileDirectory(self, filename):
     dirlist = QFileDialog.getExistingDirectory()
     if filename == 'path1files':
         self.lineEdit.setText(dirlist)
     else:
         self.lineEdit_2.setText(dirlist)
     with open(filename + '.ini', 'w') as f:
         f.write(dirlist)
     print(dirlist)
예제 #7
0
 def slot_choose_folder(self):
     dir_choose = QFileDialog.getExistingDirectory(self, "选择文件夹",
                                                   self.cwd)  # 起始路径
     if dir_choose == "":
         return
     self.selected = dir_choose
     self.choose_folder.setText(self.selected)
     self.status.setText("")
     self.cwd = os.path.dirname(dir_choose)
예제 #8
0
 def slot_btn_chooseDir(self):
     dir_choose = QFileDialog.getExistingDirectory(self, "选择文件夹",
                                                   self.cwd)  # 起始路径
     if dir_choose == "":
         return
     if dir_choose not in self.selected:
         self.selected.append(dir_choose)
         self.cwd = os.path.dirname(dir_choose)
     self.show_selected()
예제 #9
0
 def getPassDirectory(self):
     # Сам выбор папки, да знаю, что немного косой, и можно было бы убрать из этого файла в другой
     self.inst = QtWidgets.QWidget()
     ui_drctry = Ui_drctryChoice()
     ui_drctry.setupUi(self.inst)
     dirlist = QFileDialog.getExistingDirectory(self)
     ui_drctry.lineEdit.setText(dirlist)
     with open('pathpass.ini', 'w') as f:
         f.write(dirlist)
     self.inst.show()
     print(dirlist)
예제 #10
0
 def on_click(self):
     print('BrowseButton clicked {}'.format(self.input.text()))
     # self.input.setText('{} - Bar'.format(self.input.text()))
     folder = QFileDialog.getExistingDirectory(
         self, "Select Folder", "", QFileDialog.Options.ShowDirsOnly
         | QFileDialog.Options.DontUseNativeDialog)
     if folder:
         self.input.setText(folder)
         self.input.setStyleSheet("background-color:#ffff80")
         self.top.setEdited()
     self.input.setFocus()
예제 #11
0
    def open_project(self):
        ''' open a decomp project, initialize ui accordingly
        '''

        dlg = QFileDialog()
        project_dir = dlg.getExistingDirectory()

        if project_dir:
            self.root = project_dir
            self.load_project()
            self.mainwindow.tabWidget.setEnabled(True)

        pass
예제 #12
0
    def openDirectory(self):
        """Open a QFileDialog for selecting a local directory. Only display 
        image and GIF files."""
        directory = QFileDialog.getExistingDirectory(
            self, "Choose Directory", "", QFileDialog.Option.ShowDirsOnly
        )  # Specify the file mode to only select directories

        if directory:
            self.movie.setFileName(directory)
            # Check if image data is valid before playing
            if self.movie.isValid():
                # Use setMovie() to set the label's contents as the selected GIF
                self.media_label.setMovie(self.movie)
                self.startMovie()  # Call method to begin playing
    def select_folder_prompt(self):
        #  Clear self.image_list and QListWidget to prepare for newly selected folder.
        self.image_list.clear()
        self.image_paths_list_widget.clear()

        # Append a "/" otherwise it will mix the folder name and containing image file together
        directory = str(QFileDialog.getExistingDirectory(self, "Select Directory")) + "/"
        # Update QLabel to new directory, and store it in self for future use
        self.directory_label.setText(directory)
        self.directory_path_name = directory

        # Update self.image_list field
        image_list = self.scan_for_jpg_file_paths()
        self.image_list = image_list

        # Populated the QListWindow() with the update self.image_list field
        self.image_paths_list_widget.addItems(self.image_list)
    def openDirectory(self):
        """Open a QFileDialog for selecting a local directory. Only display 
        image and GIF files.""" 
        directory = QFileDialog.getExistingDirectory(self, "Choose Directory", "", 
            QFileDialog.Option.ShowDirsOnly) # Specify the file mode to only select directories

        if directory:
            # Display the selected folder text in the QLineEdit. There are other, and 
            # possibly better, ways to handle displaying the text, but for simplicity, 
            # this is the method used in this GUI
            self.folder_line.setText(directory)

            # Get the contents of the directory and only display files with
            # specified extensions
            file_dir = QDir(directory)
            filters = ["*.gif", "*.png", "*.jpg", "*.jpeg"]
            files_info = file_dir.entryInfoList(filters, QDir.Filter.Files)

            # Clear the contents of the QTreeWidget
            if self.files_tree.model().rowCount() > 0:         
                # NOTE: Since files_tree is connected to the itemSelectionChanged signal,
                # using the clear() method below will also cause the signal to be emitted. 
                # This causes an undesired issue because of how the items are deleted. To avoid
                # the signal being called, QObject.blockSignals() will halt files_tree from 
                # emitting signals while removing items
                self.files_tree.blockSignals(True)
                # Use the convenience method clear() provided by QTreeWidget to remove 
                # all items and selections
                self.files_tree.clear() 
                self.files_tree.blockSignals(False)

                # Reset the QLabel and its image, and disable the movie buttons (in case the 
                # last item selected was a GIF)
                self.media_label.clear()
                self.media_label.setPixmap(QPixmap("icons/image_label.png"))
                self.disableMovieButtons()

            # Create items for each file and add them to the tree
            for file in files_info:
                item = QTreeWidgetItem()
                item.setText(0, file.fileName())
                self.files_tree.addTopLevelItem(item)
예제 #15
0
    def export_log(self):
        folder = QFileDialog.getExistingDirectory(
            None, caption=self.lang.menu_export_log)
        if folder is not None:
            log = Log.extract_log()
            err = Log.extract_err()

            for f in Config._protect_fields:
                v = getattr(Config, f, '')
                if v != '':
                    log = log.replace(v, Const.protector)
                    err = err.replace(v, Const.protector)

            if log != '':
                with open('%s/%s' % (folder, '%s.log' % Const.app_name),
                          'w') as io:
                    io.write(log)

            if err != '':
                with open('%s/%s' % (folder, '%s.err' % Const.app_name),
                          'w') as io:
                    io.write(err)
예제 #16
0
 def restore(self):
     path = QFileDialog.getExistingDirectory()
     if path:
         reply = QMessageBox.information(
             self,
             "Start Restore?",
             f"You are about to restore to {path}. Blobbackup will OVERWRITE any conflicting files. Continue?",
             QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No,
             QMessageBox.StandardButton.No,
         )
         if reply == QMessageBox.StandardButton.Yes:
             snapshot_id = self.snapshots_combo_box.currentData()
             self.restoring_gui_state()
             self.restore_thread = RestoreThread(
                 self.email,
                 self.password,
                 self.computer_id,
                 snapshot_id,
                 path,
                 self.snapshot_tree_widget,
             )
             self.restore_thread.restored.connect(self.restored)
             self.restore_thread.failed.connect(self.restore_failed)
             self.restore_thread.start()
예제 #17
0
class MainWindow(Ui_MainWindow, QMainWindow):
    def __init__(self, **kwargs):
        super().__init__()
        self.setupUi(self)

        self.events = kwargs.get('events')  # type: dict

        self.config = self.events['get_config']()  # type:Config

        self.f_dialog = QFileDialog()
        self.t_sync = TSync()

        self._event_connect()
        self.load_language()

        self.init_languages_menu()
        self.load_data()

    @property
    def lang(self):
        language = self.events['get_language']()  # type: English
        return language

    def load_language(self):
        self.setWindowTitle(Const.app_name)

        lang_keys = dir(self.lang)
        for k in dir(self):
            item = getattr(self, k)
            set_text = getattr(item, 'setText', None)
            if callable(set_text) and k in lang_keys:
                set_text(getattr(self.lang, k))

    def load_data(self):
        self.le_sync_dir.setText(self.config.sync_dir)
        self.le_bucket.setText(self.config.bucket)
        self.le_access_key.setText(self.config.access_key)
        self.le_secret_key.setText(self.config.secret_key)

    def _event_connect(self):
        self.tb_browser.clicked.connect(self._event_tb_browser_clicked)
        self.pb_sync.clicked.connect(self._event_pb_sync_clicked)

        self.t_sync.sig_progress.connect(self._callback_progress)

    def _event_tb_browser_clicked(self, p):
        path = self.f_dialog.getExistingDirectory(self,
                                                  'Select sync directory.')
        self.le_sync_dir.setText(path)

    def _event_pb_sync_clicked(self, p):
        self.config.bucket = self.le_bucket.text()
        self.config.sync_dir = self.le_sync_dir.text()
        self.config.access_key = self.le_access_key.text()
        self.config.secret_key = self.le_secret_key.text()
        self.config.save()

        self.t_sync.set_params(self.config.bucket, self.config.sync_dir,
                               self.config.access_key, self.config.secret_key)
        self.t_sync.start()

    def _callback_progress(self, now, max):
        self.pb_progress.setMaximum(max)
        self.pb_progress.setValue(now)

    def set_language(self, language):
        self.events['set_language'](language)
        self.load_language()

    def init_languages_menu(self):
        for k in LANGUAGES:
            a_lang = QAction(self)
            a_lang.setText(LANGUAGES[k].l_this)
            a_lang.triggered.connect((lambda x:
                                      (lambda _: self.set_language(x)))(k))
            self.m_languages.addAction(a_lang)
예제 #18
0
 def selectDataDirectory(self):
     filePath = str(
         QFileDialog.getExistingDirectory(self, "Select data directory"))
     self.data_directory = filePath
     self.data_directory_display.setText('..' + self.data_directory[-24:])
예제 #19
0
	def get_existing_directory(self) -> str:
		return QFileDialog.getExistingDirectory(
			self, self._tr("pyCppGui", "Open project folder"),
			"/", options=QFileDialog.Option.DontConfirmOverwrite)