当前位置: 首页>>代码示例>>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;未经允许,请勿转载。