当前位置: 首页>>代码示例>>Python>>正文


Python QFileDialog.getOpenFileName方法代码示例

本文整理汇总了Python中python_qt_binding.QtGui.QFileDialog.getOpenFileName方法的典型用法代码示例。如果您正苦于以下问题:Python QFileDialog.getOpenFileName方法的具体用法?Python QFileDialog.getOpenFileName怎么用?Python QFileDialog.getOpenFileName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在python_qt_binding.QtGui.QFileDialog的用法示例。


在下文中一共展示了QFileDialog.getOpenFileName方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _load_dot

# 需要导入模块: from python_qt_binding.QtGui import QFileDialog [as 别名]
# 或者: from python_qt_binding.QtGui.QFileDialog import getOpenFileName [as 别名]
    def _load_dot(self, file_name=None):
        if file_name is None:
            file_name, _ = QFileDialog.getOpenFileName(self._widget, self.tr('Open graph from file'), None, self.tr('DOT graph (*.dot)'))
            if file_name is None or file_name == '':
                return

        try:
            fh = open(file_name, 'rb')
            dotcode = fh.read()
            fh.close()
        except IOError:
            return

        # disable controls customizing fetched ROS graph
        self._widget.depth_combo_box.setEnabled(False)
        self._widget.directions_combo_box.setEnabled(False)
        self._widget.package_type_combo_box.setEnabled(False)
        self._widget.filter_line_edit.setEnabled(False)
        self._widget.with_stacks_check_box.setEnabled(False)
        self._widget.mark_check_box.setEnabled(False)
        self._widget.colorize_check_box.setEnabled(False)
        self._widget.hide_transitives_check_box.setEnabled(False)

        self._update_graph(dotcode)
        self._redraw_graph_scene()
开发者ID:OSUrobotics,项目名称:rqt_common_plugins,代码行数:27,代码来源:ros_pack_graph.py

示例2: browseForLocation

# 需要导入模块: from python_qt_binding.QtGui import QFileDialog [as 别名]
# 或者: from python_qt_binding.QtGui.QFileDialog import getOpenFileName [as 别名]
    def browseForLocation(self):
        location = QFileDialog.getOpenFileName(filter="*.bag;;*", directory=os.path.dirname(self.demoLocation.text()))[0]
        if len(location) == 0:
            return

        self.demoLocation.setText(location)
        self.loadLocation()
开发者ID:HLP-R,项目名称:hlpr_kinesthetic_teaching,代码行数:9,代码来源:kinesthetic_teaching_widget.py

示例3: on_open_xml_clicked

# 需要导入模块: from python_qt_binding.QtGui import QFileDialog [as 别名]
# 或者: from python_qt_binding.QtGui.QFileDialog import getOpenFileName [as 别名]
 def on_open_xml_clicked(self):
     (fileName, _) = QFileDialog.getOpenFileName(self,
                                                 "Load launch file",
                                                 self.__current_path,
                                                 "Config files (*.launch);;All files (*)")
     if fileName:
         self.__current_path = os.path.dirname(fileName)
         self.launchlist_model.add2LoadHistory(fileName)
         self.load_signal.emit(fileName)
开发者ID:fkie,项目名称:multimaster_fkie,代码行数:11,代码来源:launch_files_widget.py

示例4: load_file

# 需要导入模块: from python_qt_binding.QtGui import QFileDialog [as 别名]
# 或者: from python_qt_binding.QtGui.QFileDialog import getOpenFileName [as 别名]
    def load_file(self):
        filename = QFileDialog.getOpenFileName(self, self.tr("Open File"), "../", self.tr("Yaml (*.yaml)"))
	if os.path.basename(filename[0].encode("ascii")) == "":
	    return

	self.filelist.append(filename[0])
	self.filenames.append(os.path.basename(filename[0].encode("ascii")))
	self.fileLabel.setText('Files: ' + str(self.filenames))
        self.fileLabel.setWordWrap(True)	
开发者ID:dbking77,项目名称:pr2_motor_diagnostic_tool,代码行数:11,代码来源:diagnostic_tool_widget.py

示例5: on_open_xml_clicked

# 需要导入模块: from python_qt_binding.QtGui import QFileDialog [as 别名]
# 或者: from python_qt_binding.QtGui.QFileDialog import getOpenFileName [as 别名]
 def on_open_xml_clicked(self):
     (fileName, _) = QFileDialog.getOpenFileName(self,
                                                 "Load launch file",
                                                 self.__current_path,
                                                 "Config files (*.launch);;All files (*)")
     if fileName:
         self.__current_path = os.path.dirname(fileName)
         nm.settings().launch_history_add(fileName)
         self.load_signal.emit(fileName, [], None)
开发者ID:zhouchengming1,项目名称:multimaster_fkie,代码行数:11,代码来源:launch_files_widget.py

示例6: _import

# 需要导入模块: from python_qt_binding.QtGui import QFileDialog [as 别名]
# 或者: from python_qt_binding.QtGui.QFileDialog import getOpenFileName [as 别名]
    def _import(self):
        file_path, _ = QFileDialog.getOpenFileName(self, self.tr('Import custom graph'),
                                                   None, self.tr('DOT graph (*.dot)'))

        if file_path is None or file_path == '':
            return

        custom_graph = Graph(self._dot_processor, file_path, file_path)
        self.decision_graphs[custom_graph.source] = custom_graph
        self._current_graph = custom_graph

        self.decision_graphs_combo_box.addItem(custom_graph.source)
        self.decision_graphs_combo_box.setCurrentIndex(self.decision_graphs_combo_box.findText(custom_graph.source))
开发者ID:danerde,项目名称:decision_making,代码行数:15,代码来源:graph_widget.py

示例7: _on_import_perspective

# 需要导入模块: from python_qt_binding.QtGui import QFileDialog [as 别名]
# 或者: from python_qt_binding.QtGui.QFileDialog import getOpenFileName [as 别名]
    def _on_import_perspective(self):
        file_name, _ = QFileDialog.getOpenFileName(self._menu_manager.menu, self.tr('Import perspective from file'), None, self.tr('Perspectives (*.perspective)'))
        if file_name is None or file_name == '':
            return

        perspective_name = os.path.basename(file_name)
        suffix = '.perspective'
        if perspective_name.endswith(suffix):
            perspective_name = perspective_name[:-len(suffix)]
        if perspective_name in self.perspectives:
            perspective_name = self._choose_new_perspective_name(False)
            if perspective_name is None:
                return

        self.import_perspective_from_file(file_name, perspective_name)
开发者ID:abhat91,项目名称:ros_osx,代码行数:17,代码来源:perspective_manager.py

示例8: _load_dot

# 需要导入模块: from python_qt_binding.QtGui import QFileDialog [as 别名]
# 或者: from python_qt_binding.QtGui.QFileDialog import getOpenFileName [as 别名]
    def _load_dot(self, file_name=None):
        if file_name is None:
            file_name, _ = QFileDialog.getOpenFileName(
                self._widget,
                self.tr('Open graph from file'),
                None,
                self.tr('DOT graph (*.dot)'))
            if file_name is None or file_name == '':
                return

        try:
            fhandle = open(file_name, 'rb')
            dotcode = fhandle.read()
            fhandle.close()
        except IOError:
            return

        self._update_graph_view(dotcode)
开发者ID:Aerobota,项目名称:rqt_robot_plugins,代码行数:20,代码来源:tf_tree.py

示例9: _load_dot

# 需要导入模块: from python_qt_binding.QtGui import QFileDialog [as 别名]
# 或者: from python_qt_binding.QtGui.QFileDialog import getOpenFileName [as 别名]
    def _load_dot(self, file_name=None):
        if file_name is None:
            file_name, _ = QFileDialog.getOpenFileName(self._widget, self.tr('Open graph from file'), None, self.tr('DOT graph (*.dot)'))
            if file_name is None or file_name == '':
                return

        try:
            fh = open(file_name, 'rb')
            dotcode = fh.read()
            fh.close()
        except IOError:
            return

        # disable controls customizing fetched ROS graph
        self._widget.graph_type_combo_box.setEnabled(False)
        self._widget.filter_line_edit.setEnabled(False)
        self._widget.topic_filter_line_edit.setEnabled(False)
        self._widget.namespace_cluster_check_box.setEnabled(False)
        self._widget.actionlib_check_box.setEnabled(False)
        self._widget.dead_sinks_check_box.setEnabled(False)
        self._widget.leaf_topics_check_box.setEnabled(False)
        self._widget.quiet_check_box.setEnabled(False)

        self._update_graph_view(dotcode)
开发者ID:OSUrobotics,项目名称:rqt_common_plugins,代码行数:26,代码来源:ros_graph.py

示例10: _handle_load_clicked

# 需要导入模块: from python_qt_binding.QtGui import QFileDialog [as 别名]
# 或者: from python_qt_binding.QtGui.QFileDialog import getOpenFileName [as 别名]
 def _handle_load_clicked(self):
     filename = QFileDialog.getOpenFileName(self, self.tr('Load from File'), '.', self.tr('Bag files {.bag} (*.bag)'))
     if filename[0] != '':
         self.load_bag(filename[0])
开发者ID:suryaprakaz,项目名称:rospy_android,代码行数:6,代码来源:bag_widget.py

示例11: _handle_load_clicked

# 需要导入模块: from python_qt_binding.QtGui import QFileDialog [as 别名]
# 或者: from python_qt_binding.QtGui.QFileDialog import getOpenFileName [as 别名]
 def _handle_load_clicked(self):
     filename = QFileDialog.getOpenFileName(
         self, self.tr("Load from File"), ".", self.tr("Bag files {.bag} (*.bag)")
     )
     if filename[0] != "":
         self.load_bag(filename[0])
开发者ID:harmishhk,项目名称:rqt_common_plugins,代码行数:8,代码来源:bag_widget.py

示例12: _handle_load_clicked

# 需要导入模块: from python_qt_binding.QtGui import QFileDialog [as 别名]
# 或者: from python_qt_binding.QtGui.QFileDialog import getOpenFileName [as 别名]
    def _handle_load_clicked(self, checked):
        filename = QFileDialog.getOpenFileName(self, self.tr('Load from File'), '.', self.tr('rqt_console message file {.csv} (*.csv)'))
        if filename[0] != '':
            try:
                with open(filename[0], 'r') as h:
                    lines = h.read().splitlines()
            except IOError as e:
                qWarning(str(e))
                return False

            # extract column header
            columns = lines[0].split(';')
            if len(lines) < 2:
                return True

            # join wrapped lines
            rows = []
            last_wrapped = False
            for line in lines[1:]:
                # ignore empty lines
                if not line:
                    continue
                # check for quotes and remove them
                if line == '"':
                    has_prefix = not last_wrapped
                    has_suffix = last_wrapped
                    line = ''
                else:
                    has_prefix = line[0] == '"'
                    if has_prefix:
                        line = line[1:]
                    has_suffix = line[-1] == '"'
                    if has_suffix:
                        line = line[:-1]

                # ignore line without prefix if previous line was not wrapped
                if not has_prefix and not last_wrapped:
                    continue
                # remove wrapped line which is not continued on the next line
                if last_wrapped and has_prefix:
                    rows.pop()

                # add/append lines
                if last_wrapped:
                    rows[-1] += line
                else:
                    # add line without quote prefix
                    rows.append(line)

                last_wrapped = not has_suffix

            # generate message for each row
            messages = []
            skipped = []
            for row in rows:
                data = row.split('";"')
                msg = Message()
                msg.set_stamp_format('hh:mm:ss.ZZZ (yyyy-MM-dd)')
                for i, column in enumerate(columns):
                    value = data[i]
                    if column == 'message':
                        msg.message = value.replace('\\"', '"')
                    elif column == 'severity':
                        msg.severity = int(value)
                        if msg.severity not in Message.SEVERITY_LABELS:
                            skipped.append('Unknown severity value: %s' % value)
                            msg = None
                            break
                    elif column == 'stamp':
                        parts = value.split('.')
                        if len(parts) != 2:
                            skipped.append('Unknown timestamp format: %s' % value)
                            msg = None
                            break
                        msg.stamp = (int(parts[0]), int(parts[1]))
                    elif column == 'topics':
                        msg.topics = value.split(',')
                    elif column == 'node':
                        msg.node = value
                    elif column == 'location':
                        msg.location = value
                    else:
                        skipped.append('Unknown column: %s' % column)
                        msg = None
                        break
                if msg:
                    messages.append(msg)
            if skipped:
                qWarning('Skipped %d rows since they do not appear to be in rqt_console message file format:\n- %s' % (len(skipped), '\n- '.join(skipped)))

            if messages:
                self._model.insert_rows(messages)

                self._handle_pause_clicked(True)

            return True

        else:
            qWarning('File does not appear to be a rqt_console message file: missing file header.')
            return False
开发者ID:OSUrobotics,项目名称:rqt_common_plugins,代码行数:102,代码来源:console_widget.py


注:本文中的python_qt_binding.QtGui.QFileDialog.getOpenFileName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。