本文整理汇总了Python中python_qt_binding.QtGui.QFileDialog类的典型用法代码示例。如果您正苦于以下问题:Python QFileDialog类的具体用法?Python QFileDialog怎么用?Python QFileDialog使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QFileDialog类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: save_trajectory_callback
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)
示例2: newLocation
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()
示例3: load_directory
def load_directory(self):
directory = QFileDialog.getExistingDirectory(self, self.tr("Open Directory"), "../")
self.filenames.extend(os.listdir(directory))
temp = [directory + '/' + filepath for filepath in os.listdir(directory)]
self.filelist.extend(temp)
self.fileLabel.setText('Files: ' + str(self.filenames))
self.fileLabel.setWordWrap(True)
示例4: browseForFolder
def browseForFolder(self):
location = QFileDialog.getExistingDirectory(directory=os.path.dirname(self.demoLocation.text()))
if len(location) == 0:
return
self.demoLocation.setText(location)
self.loadLocation()
示例5: browseForLocation
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()
示例6: _load_dot
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()
示例7: _handle_save_clicked
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
示例8: on_open_xml_clicked
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)
示例9: _on_export_perspective
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)
示例10: load_file
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)
示例11: on_open_xml_clicked
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)
示例12: _save_image
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)
示例13: _save_dot
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()
示例14: _import
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))
示例15: _save_svg
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()