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


Python QFileDialog.getSaveFileName方法代码示例

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


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

示例1: newLocation

# 需要导入模块: from python_qt_binding.QtGui import QFileDialog [as 别名]
# 或者: from python_qt_binding.QtGui.QFileDialog import getSaveFileName [as 别名]
    def newLocation(self):
        location = QFileDialog.getSaveFileName(filter="*.bag;;*", directory=os.path.dirname(self.demoLocation.text()))[0]
        if len(location) == 0:
            return
        self.demoLocation.setText(location)
        self.playDemoButton.setEnabled(False)
        self.zeroMarker.clear()
        self.zeroMarker.setEnabled(False)
        self.startTrajectoryButton.setEnabled(True)
        self.startButton.setEnabled(True)
        self.addButton.setEnabled(True)
        self.openHandButton.setEnabled(True)
        self.closeHandButton.setEnabled(True)
        self.endButton.setEnabled(True)

        try:
            os.remove(location)
            self._showStatus("Deleted existing save file.")
        except OSError:
            pass

        if not self.kinesthetic_interaction:
            self._showWarning("Record keyframe demo server unreachable", "Record keyframe demo server isn't loaded. Run `roslaunch hlpr_record_demonstration start_record_services.launch` and restart the GUI.")
            return

        saveFile = self.kinesthetic_interaction.init_demo(location=location, timestamp=self.shouldTimestamp.isChecked())
        self.demoLocation.setText(saveFile)
        self.demoName.setText(os.path.basename(saveFile))
        self.keyframeCount.setText("")
        self.playbackTree.clear()
开发者ID:HLP-R,项目名称:hlpr_kinesthetic_teaching,代码行数:32,代码来源:kinesthetic_teaching_widget.py

示例2: _handle_save_clicked

# 需要导入模块: from python_qt_binding.QtGui import QFileDialog [as 别名]
# 或者: from python_qt_binding.QtGui.QFileDialog import getSaveFileName [as 别名]
 def _handle_save_clicked(self, checked):
     filename = QFileDialog.getSaveFileName(self, 'Save to File', '.', self.tr('rqt_console msg file {.csv} (*.csv)'))
     if filename[0] != '':
         filename = filename[0]
         if filename[-4:] != '.csv':
             filename += '.csv'
         try:
             handle = open(filename, 'w')
         except IOError as e:
             qWarning(str(e))
             return
         try:
             handle.write(';'.join(MessageDataModel.columns) + '\n')
             for index in range(self._proxy_model.rowCount()):
                 row = self._proxy_model.mapToSource(self._proxy_model.index(index, 0)).row()
                 msg = self._model._messages[row]
                 data = {}
                 data['message'] = msg.message.replace('"', '\\"')
                 data['severity'] = str(msg.severity)
                 data['node'] = msg.node
                 data['stamp'] = str(msg.stamp[0]) + '.' + str(msg.stamp[1]).zfill(9)
                 data['topics'] = ','.join(msg.topics)
                 data['location'] = msg.location
                 line = []
                 for column in MessageDataModel.columns:
                     line.append('"%s"' % data[column])
                 handle.write(';'.join(line) + '\n')
         except Exception as e:
             qWarning('File save failed: %s' % str(e))
             return False
         finally:
             handle.close()
         return True
开发者ID:OSUrobotics,项目名称:rqt_common_plugins,代码行数:35,代码来源:console_widget.py

示例3: save_trajectory_callback

# 需要导入模块: from python_qt_binding.QtGui import QFileDialog [as 别名]
# 或者: from python_qt_binding.QtGui.QFileDialog import getSaveFileName [as 别名]
    def save_trajectory_callback(self):
        self.blockSignals(True)
        print "Save gains"
        # Save data to file that we can read in
        # TODO - invalid file names

        fileName = QFileDialog.getSaveFileName()

        #if fileName[0] checks to ensure that the file dialog has not been canceled
        if fileName[0]:
            if self.calculate_trajectory():
                print self.robot_command;
                newFileptr = open(fileName[0], 'w')
                # Suggested format for files to make it easy to combine different outputs
                newFileptr.write('# Trajectory \n')
                newFileptr.write(self.robot_command)
                newFileptr.write('\n')
                newFileptr.close()
            else:
                print "Trajectory calculation failure - do not save!"
        else:
            print "Save cancelled."

        newFilePtr.close()

        self.blockSignals(False)
开发者ID:team-vigir,项目名称:vigir_rqt,代码行数:28,代码来源:sinusoidal_trajectory_widget.py

示例4: _on_export_perspective

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

        # trigger save of perspective before export
        self._callback = self._on_export_perspective_continued
        self._callback_args = [file_name]
        self.save_settings_signal.emit(self._global_settings, self._perspective_settings)
开发者ID:abhat91,项目名称:ros_osx,代码行数:11,代码来源:perspective_manager.py

示例5: _save_image

# 需要导入模块: from python_qt_binding.QtGui import QFileDialog [as 别名]
# 或者: from python_qt_binding.QtGui.QFileDialog import getSaveFileName [as 别名]
    def _save_image(self):
        file_name, _ = QFileDialog.getSaveFileName(self._widget, self.tr('Save as image'), 'rospackgraph.png', self.tr('Image (*.bmp *.jpg *.png *.tiff)'))
        if file_name is None or file_name == '':
            return

        img = QImage((self._scene.sceneRect().size() * 2.0).toSize(), QImage.Format_ARGB32_Premultiplied)
        painter = QPainter(img)
        painter.setRenderHint(QPainter.Antialiasing)
        self._scene.render(painter)
        painter.end()
        img.save(file_name)
开发者ID:OSUrobotics,项目名称:rqt_common_plugins,代码行数:13,代码来源:ros_pack_graph.py

示例6: _save_dot

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

        handle = QFile(file_name)
        if not handle.open(QIODevice.WriteOnly | QIODevice.Text):
            return

        handle.write(self._current_dotcode)
        handle.close()
开发者ID:OSUrobotics,项目名称:rqt_common_plugins,代码行数:13,代码来源:ros_pack_graph.py

示例7: _save_svg

# 需要导入模块: from python_qt_binding.QtGui import QFileDialog [as 别名]
# 或者: from python_qt_binding.QtGui.QFileDialog import getSaveFileName [as 别名]
    def _save_svg(self):
        file_name, _ = QFileDialog.getSaveFileName(self._widget, self.tr('Save as SVG'), 'rospackgraph.svg', self.tr('Scalable Vector Graphic (*.svg)'))
        if file_name is None or file_name == '':
            return

        generator = QSvgGenerator()
        generator.setFileName(file_name)
        generator.setSize((self._scene.sceneRect().size() * 2.0).toSize())

        painter = QPainter(generator)
        painter.setRenderHint(QPainter.Antialiasing)
        self._scene.render(painter)
        painter.end()
开发者ID:OSUrobotics,项目名称:rqt_common_plugins,代码行数:15,代码来源:ros_pack_graph.py

示例8: _export

# 需要导入模块: from python_qt_binding.QtGui import QFileDialog [as 别名]
# 或者: from python_qt_binding.QtGui.QFileDialog import getSaveFileName [as 别名]
    def _export(self):
        file_name, _ = QFileDialog.getSaveFileName(
            self, self.tr("Save as image"), "graph.png", self.tr("Image (*.bmp *.jpg *.png *.tiff)")
        )

        if file_name is None or file_name == "":
            return

        img = QImage((self._scene.sceneRect().size() * 2.0).toSize(), QImage.Format_ARGB32_Premultiplied)
        painter = QPainter(img)
        painter.setRenderHint(QPainter.Antialiasing)
        self._scene.render(painter)
        painter.end()
        img.save(file_name)
开发者ID:anuragsharma27,项目名称:eklavya-2015,代码行数:16,代码来源:graph_widget.py

示例9: _on_record_settings_selected

# 需要导入模块: from python_qt_binding.QtGui import QFileDialog [as 别名]
# 或者: from python_qt_binding.QtGui.QFileDialog import getSaveFileName [as 别名]
    def _on_record_settings_selected(self, all_topics, selected_topics):
        # TODO verify master is still running
        filename = QFileDialog.getSaveFileName(self, self.tr('Select prefix for new Bag File'), '.', self.tr('Bag files {.bag} (*.bag)'))
        if filename[0] != '':
            prefix = filename[0].strip()

            # Get filename to record to
            record_filename = time.strftime('%Y-%m-%d-%H-%M-%S.bag', time.localtime(time.time()))
            if prefix.endswith('.bag'):
                prefix = prefix[:-len('.bag')]
            if prefix:
                record_filename = '%s_%s' % (prefix, record_filename)

            rospy.loginfo('Recording to %s.' % record_filename)

            self.load_button.setEnabled(False)
            self._recording = True
            self._timeline.record_bag(record_filename, all_topics, selected_topics)
开发者ID:suryaprakaz,项目名称:rospy_android,代码行数:20,代码来源:bag_widget.py

示例10: _on_record_settings_selected

# 需要导入模块: from python_qt_binding.QtGui import QFileDialog [as 别名]
# 或者: from python_qt_binding.QtGui.QFileDialog import getSaveFileName [as 别名]
    def _on_record_settings_selected(self, all_topics, selected_topics):
        # TODO verify master is still running
        filename = QFileDialog.getSaveFileName(
            self, self.tr("Select prefix for new Bag File"), ".", self.tr("Bag files {.bag} (*.bag)")
        )
        if filename[0] != "":
            prefix = filename[0].strip()

            # Get filename to record to
            record_filename = time.strftime("%Y-%m-%d-%H-%M-%S.bag", time.localtime(time.time()))
            if prefix.endswith(".bag"):
                prefix = prefix[: -len(".bag")]
            if prefix:
                record_filename = "%s_%s" % (prefix, record_filename)

            rospy.loginfo("Recording to %s." % record_filename)

            self.load_button.setEnabled(False)
            self._recording = True
            self._timeline.record_bag(record_filename, all_topics, selected_topics)
开发者ID:harmishhk,项目名称:rqt_common_plugins,代码行数:22,代码来源:bag_widget.py

示例11: _handle_record_clicked

# 需要导入模块: from python_qt_binding.QtGui import QFileDialog [as 别名]
# 或者: from python_qt_binding.QtGui.QFileDialog import getSaveFileName [as 别名]
    def _handle_record_clicked(self):
        if self._recording:
            self._timeline.toggle_recording()
            return
        # TODO verify master is still running
        filename = QFileDialog.getSaveFileName(self, self.tr('Select prefix for new Bag File'), '.', self.tr('Bag files {.bag} (*.bag)'))
        if filename[0] != '':
            prefix = filename[0].strip()

            # Get filename to record to
            record_filename = time.strftime('%Y-%m-%d-%H-%M-%S.bag', time.localtime(time.time()))
            if prefix.endswith('.bag'):
                prefix = prefix[:-len('.bag')]
            if prefix:
                record_filename = '%s_%s' % (prefix, record_filename)

            rospy.loginfo('Recording to %s.' % record_filename)

            #TODO Implement recording of topic subsets, regex limiting and by number of messages per topic
            self.load_button.setEnabled(False)
            self._recording = True
            self._timeline.record_bag(record_filename)
开发者ID:aldarionsevero,项目名称:apmcontroller,代码行数:24,代码来源:bag_widget.py

示例12: on_new_xml_clicked

# 需要导入模块: from python_qt_binding.QtGui import QFileDialog [as 别名]
# 或者: from python_qt_binding.QtGui.QFileDialog import getSaveFileName [as 别名]
 def on_new_xml_clicked(self):
     '''
     Creates a new launch file.
     '''
     # get new file from open dialog, use last path if one exists
     open_path = self.__current_path
     if self.launchlist_model.currentPath is not None:
         open_path = self.launchlist_model.currentPath
     (fileName, _) = QFileDialog.getSaveFileName(self,
                                                 "New launch file",
                                                 open_path,
                                                 "Config files (*.launch *.yaml);;All files (*)")
     if fileName:
         try:
             (pkg, _) = package_name(os.path.dirname(fileName))  # _:=pkg_path
             if pkg is None:
                 WarningMessageBox(QMessageBox.Warning, "New File Error",
                                   'The new file is not in a ROS package').exec_()
                 return
             with open(fileName, 'w+') as f:
                 f.write("<launch>\n"
                         "  <arg name=\"robot_ns\" default=\"my_robot\"/>\n"
                         "  <group ns=\"$(arg robot_ns)\">\n"
                         "    <param name=\"tf_prefix\" value=\"$(arg robot_ns)\"/>\n"
                         "\n"
                         "    <node pkg=\"my_pkg\" type=\"my_node\" name=\"my_name\" >\n"
                         "      <param name=\"capability_group\" value=\"MY_GROUP\"/>\n"
                         "    </node>\n"
                         "  </group>\n"
                         "</launch>\n"
                         )
             self.__current_path = os.path.dirname(fileName)
             self.launchlist_model.setPath(self.__current_path)
             self.edit_signal.emit([fileName])
         except EnvironmentError as e:
             WarningMessageBox(QMessageBox.Warning, "New File Error",
                               'Error while create a new file',
                               '%s' % e).exec_()
开发者ID:fkie,项目名称:multimaster_fkie,代码行数:40,代码来源:launch_files_widget.py

示例13: get_profile_file

# 需要导入模块: from python_qt_binding.QtGui import QFileDialog [as 别名]
# 或者: from python_qt_binding.QtGui.QFileDialog import getSaveFileName [as 别名]
 def get_profile_file(self):
     # save the profile
     (path, _) = QFileDialog.getSaveFileName(self,
                                             "New profile file",
                                             nm.settings().current_dialog_path,
                                             "node manager profile files (*.nmprofile);;All files (*)")  # _:=filter
     if path:
         if not path.endswith('.nmprofile'):
             path = "%s.nmprofile" % path
         nm.settings().current_dialog_path = os.path.dirname(path)
         try:
             (pkg, _) = package_name(os.path.dirname(path))  # _:=pkg_path
             if pkg is None:
                 ret = MessageBox.warning(self, "New File Error",
                                          'The new file is not in a ROS package', buttons=MessageBox.Ok | MessageBox.Cancel)
                 if ret == MessageBox.Cancel:
                     return None
             return path
         except EnvironmentError as e:
             MessageBox.warning(self, "New File Error",
                                'Error while create a new file',
                                utf8(e))
     return None
开发者ID:zhouchengming1,项目名称:multimaster_fkie,代码行数:25,代码来源:profile_widget.py

示例14: accept

# 需要导入模块: from python_qt_binding.QtGui import QFileDialog [as 别名]
# 或者: from python_qt_binding.QtGui.QFileDialog import getSaveFileName [as 别名]
    def accept(self):
        if self.textedit.isVisible():
            try:
                tmp_file = os.path.join(nm.screen().LOG_PATH, 'tmp_sync_interface.sync')
                with open(tmp_file, 'w+') as f:
                    f.write(self.textedit.toPlainText())
                from master_discovery_fkie.common import read_interface
                read_interface(tmp_file)
                if not self._new_iface and self.interface_field.currentText() in self._interfaces_files:
                    fileName = self._interfaces_files[self.interface_field.currentText()]
                else:
                    fileName, _ = QFileDialog.getSaveFileName(self, 'Save sync interface', '/home', "Sync Files (*.sync)")
                if fileName:
                    with open(fileName, 'w+') as f:
                        self._interface_filename = fileName
                        f.write(self.textedit.toPlainText())
                        if self._new_iface:
                            self.interface_field.clear()
                            self._interfaces_files = None
                        self._on_select_interface_clicked()
#        QDialog.accept(self)
#        self.resetView()
            except Exception as e:
                MessageBox.warning(self, "Create sync interface",
                                   "Error while create interface",
                                   utf8(e))
        elif self.interface_field.isVisible():
            interface = self.interface_field.currentText()
            if self._interfaces_files and interface in self._interfaces_files:
                self._interface_filename = self._interfaces_files[interface]
                self._sync_args = []
                self._sync_args.append(''.join(['_interface_url:=', interface]))
                QDialog.accept(self)
                self.resetView()
        else:
            QDialog.accept(self)
            self.resetView()
开发者ID:zhouchengming1,项目名称:multimaster_fkie,代码行数:39,代码来源:sync_dialog.py

示例15: _handle_save_clicked

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


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