本文整理汇总了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()
示例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
示例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)
示例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)
示例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)
示例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()
示例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()
示例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)
示例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)
示例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)
示例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)
示例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_()
示例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
示例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()
示例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])