コード例 #1
0
 def Upload(self):
     file = QFileDialog()
     file, trash = file.getOpenFileUrls()
     if file:
         print(file)
         self.player.setMedia(QMediaContent(file[0]))
         self.PlayBt.setEnabled(True)
         #self.FullScreenBt.setEnabled(True)
         self.player.setPosition(0)
         self.slider.setValue(0)
         self.player.play()
         self.player.pause()
コード例 #2
0
 def load_files(self):
     files = QFileDialog.getOpenFileUrls(None, "Select .jpg files")
     files = [file.path() for file in files[0]]
     if not files:
         return
     images = []
     for file in files:
         if file.lower().endswith((".jpg", ".jpeg")):
             meta = ImageMetaData(file, "", "")
             images.append(meta)
     self.reset_model()
     self._model.images = images
     self._model.predict_images()
コード例 #3
0
 def loadFilesFunction(self):
     self.ConsoleOutput("File(s) will be add")
     filter = "TXT (*.txt);;CSV (*.csv);;DAT (*.dat);; ANY file (*.*)"
     file_name = QFileDialog()
     file_name.setFileMode(QFileDialog.ExistingFiles)
     names = file_name.getOpenFileUrls(self, "Open files", "/home/", filter)
     for i in names[0]:
         self.ConsoleOutput(str(i.path()))
     # MAIN LOADER:
     for i in names[0]:
         file_path = i
         self.FillFiles(file_path)
     pass
コード例 #4
0
 def on_pushButton_2_clicked(self):
     #选取被打标图
     file_path_obj, type = QFileDialog.getOpenFileUrls(self, '选取文件', './')
     if file_path_obj:
         raw_file_path = [file.path()[1:] for file in file_path_obj]
         pic_type = ['jpg', 'gif', 'jpeg', 'tiff', 'svg', 'png', 'ico']
         global FILE_LIST
         FILE_LIST = []
         file_list_tmp = []
         for file in raw_file_path:
             if os.path.isfile(file):
                 f_s = file.split('.')
                 if len(f_s) >= 2:
                     suffix = f_s[-1].lower()
                     if suffix in pic_type:
                         file_list_tmp.append(file)
         if len(file_list_tmp) > 0:
             self.textBrowser.setText('')
             # self.textBrowser.acceptDrops()
             # self.textBrowser.close()
             # self.textBrowser.clearMask()
         for f_name in file_list_tmp:
             self.textBrowser.append(f_name)
         FILE_LIST = file_list_tmp
コード例 #5
0
 def on_bTest_clicked(self):
     """
     Private method to test the selected options.
     """
     if self.rOpenFile.isChecked() or self.rfOpenFile.isChecked():
         if not self.cSymlinks.isChecked():
             options = QFileDialog.Options(QFileDialog.DontResolveSymlinks)
         else:
             options = QFileDialog.Options()
         options = self.__adjustOptions(options)
         QFileDialog.getOpenFileName(None, self.eCaption.text(),
                                     self.eStartWith.text(),
                                     self.eFilters.text(),
                                     self.eInitialFilter.text(), options)
     elif self.rOpenFileUrl.isChecked():
         if not self.cSymlinks.isChecked():
             options = QFileDialog.Options(QFileDialog.DontResolveSymlinks)
         else:
             options = QFileDialog.Options()
         options = self.__adjustOptions(options)
         try:
             QFileDialog.getOpenFileUrl(None, self.eCaption.text(),
                                        QUrl(self.eStartWith.text()),
                                        self.eFilters.text(),
                                        self.eInitialFilter.text(), options,
                                        self.schemesEdit.text().split())
         except TypeError:
             # PyQt5 < 5.13.0 contains an error
             QFileDialog.getOpenFileUrl(None, self.eCaption.text(),
                                        self.eStartWith.text(),
                                        self.eFilters.text(),
                                        self.eInitialFilter.text(), options,
                                        self.schemesEdit.text().split())
     elif self.rOpenFiles.isChecked() or self.rfOpenFiles.isChecked():
         if not self.cSymlinks.isChecked():
             options = QFileDialog.Options(QFileDialog.DontResolveSymlinks)
         else:
             options = QFileDialog.Options()
         options = self.__adjustOptions(options)
         QFileDialog.getOpenFileNames(None, self.eCaption.text(),
                                      self.eStartWith.text(),
                                      self.eFilters.text(),
                                      self.eInitialFilter.text(), options)
     elif self.rOpenFileUrls.isChecked():
         if not self.cSymlinks.isChecked():
             options = QFileDialog.Options(QFileDialog.DontResolveSymlinks)
         else:
             options = QFileDialog.Options()
         options = self.__adjustOptions(options)
         try:
             QFileDialog.getOpenFileUrls(None, self.eCaption.text(),
                                         QUrl(self.eStartWith.text()),
                                         self.eFilters.text(),
                                         self.eInitialFilter.text(),
                                         options,
                                         self.schemesEdit.text().split())
         except TypeError:
             # PyQt5 < 5.13.0 contains an error
             QFileDialog.getOpenFileUrls(None, self.eCaption.text(),
                                         self.eStartWith.text(),
                                         self.eFilters.text(),
                                         self.eInitialFilter.text(),
                                         options,
                                         self.schemesEdit.text().split())
     elif self.rSaveFile.isChecked() or self.rfSaveFile.isChecked():
         if not self.cSymlinks.isChecked():
             options = QFileDialog.Options(QFileDialog.DontResolveSymlinks)
         else:
             options = QFileDialog.Options()
         options = self.__adjustOptions(options)
         QFileDialog.getSaveFileName(None, self.eCaption.text(),
                                     self.eStartWith.text(),
                                     self.eFilters.text(),
                                     self.eInitialFilter.text(), options)
     elif self.rSaveFileUrl.isChecked():
         if not self.cSymlinks.isChecked():
             options = QFileDialog.Options(QFileDialog.DontResolveSymlinks)
         else:
             options = QFileDialog.Options()
         options = self.__adjustOptions(options)
         try:
             QFileDialog.getSaveFileUrl(None, self.eCaption.text(),
                                        QUrl(self.eStartWith.text()),
                                        self.eFilters.text(),
                                        self.eInitialFilter.text(), options,
                                        self.schemesEdit.text().split())
         except TypeError:
             # PyQt5 < 5.13.0 contains an error
             QFileDialog.getSaveFileUrl(None, self.eCaption.text(),
                                        self.eStartWith.text(),
                                        self.eFilters.text(),
                                        self.eInitialFilter.text(), options,
                                        self.schemesEdit.text().split())
     elif self.rDirectory.isChecked():
         options = QFileDialog.Options()
         if not self.cSymlinks.isChecked():
             options |= QFileDialog.Options(QFileDialog.DontResolveSymlinks)
         if self.cDirOnly.isChecked():
             options |= QFileDialog.Options(QFileDialog.ShowDirsOnly)
         else:
             options |= QFileDialog.Options(QFileDialog.Option(0))
         options = self.__adjustOptions(options)
         QFileDialog.getExistingDirectory(None, self.eCaption.text(),
                                          self.eWorkDir.text(), options)
     elif self.rDirectoryUrl.isChecked():
         options = QFileDialog.Options()
         if not self.cSymlinks.isChecked():
             options |= QFileDialog.Options(QFileDialog.DontResolveSymlinks)
         if self.cDirOnly.isChecked():
             options |= QFileDialog.Options(QFileDialog.ShowDirsOnly)
         else:
             options |= QFileDialog.Options(QFileDialog.Option(0))
         options = self.__adjustOptions(options)
         try:
             QFileDialog.getExistingDirectoryUrl(
                 None, self.eCaption.text(), QUrl(self.eWorkDir.text()),
                 options,
                 self.schemesEdit.text().split())
         except TypeError:
             # PyQt5 < 5.13.0 contains an error
             QFileDialog.getExistingDirectoryUrl(
                 None, self.eCaption.text(), self.eWorkDir.text(), options,
                 self.schemesEdit.text().split())
コード例 #6
0
ファイル: main_app.py プロジェクト: DieNice/musictagger
 def __load_files_mp3(self) -> None:
     '''Open dialog for choosing mp3 files and load them to table'''
     urls = QFileDialog.getOpenFileUrls(self,
                                        'Open mp3 files',
                                        filter='*.mp3')
     return self.__load_urls_to_table(urls[0])
コード例 #7
0
ファイル: pydialog.py プロジェクト: blackPantherOS/playground
         dialog = QFileDialog(None, pydialog_title, directory, filters)
         if dialog.exec_() == QDialog.Accepted:
             print(dialog.selectedFiles()[0])
             sys.exit(0)
 elif arguments.getsavefilename:
     from os.path import relpath
     savefilename = relpath(QFileDialog.getSaveFileName(None, pydialog_title, directory, filters)[0])
     print(savefilename)
     sys.exit(0)
 elif arguments.getexistingdirectory:
     existingdirectory = QFileDialog.getExistingDirectory(None, pydialog_title, directory)
     print(existingdirectory)
     sys.exit(0)
 elif arguments.getopenurl:
     if arguments.multiple:
         r = [e.toString() for e in QFileDialog.getOpenFileUrls(None, pydialog_title, directory, filters)[0]]
         urls = " ".join(r)
         print(urls)
     else:
         url = QFileDialog.getOpenFileUrl(None, pydialog_title, directory, filters)[0].toString()
         print(url)
         sys.exit(0)
 elif arguments.getsaveurl:
     url = QFileDialog.getSaveFileUrl(None, pydialog_title, directory, filters)[0].toString()
     print(url)
     sys.exit(0)
 elif arguments.getcolor:
     from PyQt5.QtWidgets import QColorDialog
     if arguments.default:
         from PyQt5.QtGui import QColor
         color = QColorDialog.getColor(QColor(arguments.default)).name()