當前位置: 首頁>>代碼示例>>Python>>正文


Python QFileDialog.getOpenFileName方法代碼示例

本文整理匯總了Python中AnyQt.QtWidgets.QFileDialog.getOpenFileName方法的典型用法代碼示例。如果您正苦於以下問題:Python QFileDialog.getOpenFileName方法的具體用法?Python QFileDialog.getOpenFileName怎麽用?Python QFileDialog.getOpenFileName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在AnyQt.QtWidgets.QFileDialog的用法示例。


在下文中一共展示了QFileDialog.getOpenFileName方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: open_report

# 需要導入模塊: from AnyQt.QtWidgets import QFileDialog [as 別名]
# 或者: from AnyQt.QtWidgets.QFileDialog import getOpenFileName [as 別名]
    def open_report(self):
        filename, _ = QFileDialog.getOpenFileName(
            self, "Open Report", self.open_dir, "Report (*.report)")
        if not filename:
            return

        self.report_changed = False
        self.open_dir = os.path.dirname(filename)
        self.saveSettings()

        try:
            report = self.load(filename)
        except (IOError, AttributeError, pickle.UnpicklingError) as e:
            message_critical(
                 self.tr("Could not load an Orange Report file"),
                 title=self.tr("Error"),
                 informative_text=self.tr("Error occurred "
                                          "while loading '{}'.").format(filename),
                 exc_info=True,
                 parent=self)
            log.error(str(e), exc_info=True)
            return
        self.set_instance(report)
        self = report
        self._build_html()
        self.table.selectRow(0)
        self.show()
        self.raise_()
開發者ID:benzei,項目名稱:orange3,代碼行數:30,代碼來源:owreport.py

示例2: main

# 需要導入模塊: from AnyQt.QtWidgets import QFileDialog [as 別名]
# 或者: from AnyQt.QtWidgets.QFileDialog import getOpenFileName [as 別名]
def main(argv=sys.argv):
    if len(argv) == 1:
        filename = None
    else:
        if argv[1] in ["-h", "--help"]:
            usage(argv)
            return 0
        else:
            filename = argv[1]
    
    app = QApplication(argv)
    app.setAttribute(Qt.AA_EnableHighDpiScaling)
    app.setAttribute(Qt.AA_UseHighDpiPixmaps)
    if filename is None:
        filename, _ = QFileDialog.getOpenFileName(
            None, "Image file", os.path.expanduser("~/Documents"),
            "Image (*.png)")
        if not filename:
            return 1
        print(filename)

    form = MainForm(filename=filename)
    rect = QApplication.desktop().availableGeometry()
    form.show()
    form.raise_()
    return app.exec_()
開發者ID:biolab,項目名稱:orange-tools,代碼行數:28,代碼來源:stamper.py

示例3: onAddScriptFromFile

# 需要導入模塊: from AnyQt.QtWidgets import QFileDialog [as 別名]
# 或者: from AnyQt.QtWidgets.QFileDialog import getOpenFileName [as 別名]
 def onAddScriptFromFile(self, *args):
     filename, _ = QFileDialog.getOpenFileName(
         self, 'Open Python Script',
         os.path.expanduser("~/"),
         'Python files (*.py)\nAll files(*.*)'
     )
     if filename:
         name = os.path.basename(filename)
         contents = open(filename, "rb").read().decode("utf-8", errors="ignore")
         self.libraryList.append(Script(name, contents, 0, filename))
         self.setSelectedScript(len(self.libraryList) - 1)
開發者ID:rekonder,項目名稱:orange3,代碼行數:13,代碼來源:owpythonscript.py

示例4: browse

# 需要導入模塊: from AnyQt.QtWidgets import QFileDialog [as 別名]
# 或者: from AnyQt.QtWidgets.QFileDialog import getOpenFileName [as 別名]
    def browse(self):
        """Select a filename using an open file dialog."""
        if self.filename is None:
            startdir = stdpaths.Documents
        else:
            startdir = os.path.dirname(self.filename)

        filename, _ = QFileDialog.getOpenFileName(
            self, self.tr("Open"), directory=startdir, filter=self.FILTER)

        if filename:
            self.load(filename)
開發者ID:PrimozGodec,項目名稱:orange3,代碼行數:14,代碼來源:owloadmodel.py

示例5: onAddScriptFromFile

# 需要導入模塊: from AnyQt.QtWidgets import QFileDialog [as 別名]
# 或者: from AnyQt.QtWidgets.QFileDialog import getOpenFileName [as 別名]
 def onAddScriptFromFile(self, *args):
     filename, _ = QFileDialog.getOpenFileName(
         self, 'Open Python Script',
         os.path.expanduser("~/"),
         'Python files (*.py)\nAll files(*.*)'
     )
     if filename:
         name = os.path.basename(filename)
         # TODO: use `tokenize.detect_encoding`
         with open(filename, encoding="utf-8") as f:
             contents = f.read()
         self.libraryList.append(Script(name, contents, 0, filename))
         self.setSelectedScript(len(self.libraryList) - 1)
開發者ID:acopar,項目名稱:orange3,代碼行數:15,代碼來源:owpythonscript.py

示例6: browse_file

# 需要導入模塊: from AnyQt.QtWidgets import QFileDialog [as 別名]
# 或者: from AnyQt.QtWidgets.QFileDialog import getOpenFileName [as 別名]
 def browse_file(self):
     """
     Open the file dialog and open the chosen file.
     """
     start_path = self.last_path() or os.path.expanduser("~")
     filename, _ = QFileDialog.getOpenFileName(
         None, "Open File", start_path, 'All Files (*.*)')
     if not filename:
         return
     self.closeContext()
     self.add_path(filename)
     self.openContext(filename)
     self.open_file()
開發者ID:pavlin-policar,項目名稱:orange3-prototypes,代碼行數:15,代碼來源:owgrep.py

示例7: browse_file

# 需要導入模塊: from AnyQt.QtWidgets import QFileDialog [as 別名]
# 或者: from AnyQt.QtWidgets.QFileDialog import getOpenFileName [as 別名]
    def browse_file(self, in_demos=False):
        if in_demos:
            start_file = get_sample_datasets_dir()
            if not os.path.exists(start_file):
                QMessageBox.information(
                    None, "File",
                    "Cannot find the directory with documentation data sets")
                return
        else:
            start_file = self.last_path() or os.path.expanduser("~/")

        filename, _ = QFileDialog.getOpenFileName(
            self, 'Open Distance File', start_file, "(*.dst)")
        if not filename:
            return
        self.add_path(filename)
        self.open_file()
開發者ID:RachitKansal,項目名稱:orange3,代碼行數:19,代碼來源:owdistancefile.py

示例8: browse_file

# 需要導入模塊: from AnyQt.QtWidgets import QFileDialog [as 別名]
# 或者: from AnyQt.QtWidgets.QFileDialog import getOpenFileName [as 別名]
    def browse_file(self, in_demos=False):
        if in_demos:
            start_file = get_sample_datasets_dir()
            if not os.path.exists(start_file):
                QMessageBox.information(
                    None, "File",
                    "Cannot find the directory with documentation data sets")
                return
        else:
            start_file = self.last_path() or os.path.expanduser("~/")

        filename, _ = QFileDialog.getOpenFileName(
            self, 'Open Orange Data File', start_file, dialog_formats())
        if not filename:
            return
        self.add_path(filename)
        self.source = self.LOCAL_FILE
        self.load_data()
開發者ID:benzei,項目名稱:orange3,代碼行數:20,代碼來源:owfile.py


注:本文中的AnyQt.QtWidgets.QFileDialog.getOpenFileName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。