本文整理汇总了Python中python_qt_binding.QtGui.QMessageBox类的典型用法代码示例。如果您正苦于以下问题:Python QMessageBox类的具体用法?Python QMessageBox怎么用?Python QMessageBox使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QMessageBox类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: on_power_on
def on_power_on(self):
try:
power = rospy.ServiceProxy("/RobotHardwareServiceROSBridge/power", OpenHRP_RobotHardwareService_power)
power(OpenHRP_RobotHardwareService_powerRequest("all", 0))
except Exception, e:
mb = QMessageBox(QMessageBox.NoIcon, "Error", "Failed to power on: %s" % (e), QMessageBox.Ok, self.parent())
mb.exec_()
示例2: __init__
def __init__(self, icon, title, text, detailed_text="", buttons=QMessageBox.Ok):
QMessageBox.__init__(self, icon, title, text, buttons)
if detailed_text:
self.setDetailedText(detailed_text)
horizontalSpacer = QSpacerItem(480, 0, QSizePolicy.Minimum, QSizePolicy.Expanding)
layout = self.layout()
layout.addItem(horizontalSpacer, layout.rowCount(), 0, 1, layout.columnCount())
if QMessageBox.Abort & buttons:
self.setEscapeButton(QMessageBox.Abort)
elif QMessageBox.Ignore & buttons:
self.setEscapeButton(QMessageBox.Ignore)
else:
self.setEscapeButton(buttons)
self.textEdit = textEdit = self.findChild(QTextEdit)
if textEdit is not None:
textEdit.setMinimumHeight(0)
textEdit.setMaximumHeight(600)
textEdit.setMinimumWidth(0)
textEdit.setMaximumWidth(600)
textEdit.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
self.ignore_all_btn = QPushButton('Don\'t display again')
self.addButton(self.ignore_all_btn, QMessageBox.HelpRole)
示例3: __init__
def __init__(self, context):
super(NodeManager, self).__init__(context)
# Give QObjects reasonable names
self.setObjectName('NodeManagerFKIE')
# Process standalone plugin command-line arguments
from argparse import ArgumentParser
parser = ArgumentParser()
# Add argument(s) to the parser.
parser.add_argument("-q", "--quiet", action="store_true",
dest="quiet",
help="Put plugin in silent mode")
args, unknowns = parser.parse_known_args(context.argv())
if not args.quiet:
print 'arguments: ', args
print 'unknowns: ', unknowns
node_manager_fkie.init_settings()
masteruri = node_manager_fkie.settings().masteruri()
node_manager_fkie.init_globals(masteruri)
# Create QWidget
try:
self._widget = MainWindow()
# self._widget.read_view_history()
except Exception, e:
msgBox = QMessageBox()
msgBox.setText(str(e))
msgBox.exec_()
raise
示例4: on_save_motion_button_clicked
def on_save_motion_button_clicked(self):
motion_name = str(self.motion_name_combo.currentText())
if len(motion_name) == 0:
QMessageBox.warning(self, 'Error', 'No name given to save this motion.')
return
self._motion_data.save(motion_name, self.get_motion_from_timeline())
self.update_motion_name_combo()
示例5: click_btn_apply
def click_btn_apply(self):
if self.validate_checked():
quit_msg = "Are you sure you want to Apply this configuration?"
reply = QMessageBox.question(self, 'Message', quit_msg, QMessageBox.Yes, QMessageBox.No)
self.get_selected_robot_checked()
if reply == QMessageBox.Yes:
xml_info = XmlInfo()
env_os = EnvOs()
dialog_xml = DialogXml()
deleted_general_items = xml_info.get_deleted_general_variable() #get deleted general items (deleted status = 1 in xml)
variable_general_items = xml_info.get_general_variables()
dialog_xml.get_deleted_variable_robot()
deleted_robots_items=dialog_xml.get_deleted_variable_robot()
variable_robot_items,active_robot=dialog_xml.get_general_variable_robot()
deleted_robot=dialog_xml.get_deleted_robot()
asociative_variable_robot = dialog_xml.get_asociative_robot_variable()
env_os.unset_to_htbash(deleted_robots_items+deleted_robots_items)
env_os.export_to_general_htbash(variable_general_items)
env_os.export_to_robot_htbash(variable_robot_items,active_robot)
dialog_xml.remove_asociative_robot_variable(asociative_variable_robot)
for item in deleted_robot:
dialog_xml.remove_robot_list_variable(item)
for item in deleted_general_items:
xml_info.remove_general_variable(item)
env_os.include_htbash()
self.lblmsg.setText("write file .htbash successfully")
else:
pass
else:
QMessageBox.information(self, 'Checked validate',"You only must select one active robot")
示例6: on_delete_motion_button_clicked
def on_delete_motion_button_clicked(self):
motion_name = str(self.motion_name_combo.currentText())
if len(motion_name) == 0:
QMessageBox.warning(self, 'Error', 'No motion selected to delete.')
return
if motion_name not in self._motion_data:
QMessageBox.warning(self, 'Error', 'Motion "%s" not in motion list.' % motion_name)
return
self._motion_data.delete(motion_name)
self.update_motion_name_combo()
示例7: on_move_button_clicked
def on_move_button_clicked(self):
position_name = str(self.move_name_combo.currentText())
if len(position_name) == 0:
QMessageBox.warning(self, 'Error', 'No position selected to move to.')
return
appendix_name = str(self.move_appendix_combo.currentText())
target_positions = self._position_data[self.robot_config.groups[appendix_name].group_type][position_name]
target_positions = self.robot_config.groups[appendix_name].adapt_to_side(target_positions)
print '[Motion Editor] Moving %s to "%s": %s' % (appendix_name, position_name, target_positions)
self._motion_publisher.move_to_position(appendix_name, target_positions)
示例8: RosPyPluginProvider
class RosPyPluginProvider(CompositePluginProvider):
_master_found_signal = Signal(int)
def __init__(self):
super(RosPyPluginProvider, self).__init__([RospkgPluginProvider('rqt_gui', 'rqt_gui_py::Plugin')])
self.setObjectName('RosPyPluginProvider')
self._node_initialized = False
self._wait_for_master_dialog = None
self._wait_for_master_thread = None
def load(self, plugin_id, plugin_context):
self._check_for_master()
self._init_node()
return super(RosPyPluginProvider, self).load(plugin_id, plugin_context)
def _check_for_master(self):
# check if master is available
try:
rospy.get_master().getSystemState()
return
except Exception:
pass
# spawn thread to detect when master becomes available
self._wait_for_master_thread = threading.Thread(target=self._wait_for_master)
self._wait_for_master_thread.start()
self._wait_for_master_dialog = QMessageBox(QMessageBox.Question, self.tr('Waiting for ROS master'), self.tr("Could not find ROS master. Either start a 'roscore' or abort loading the plugin."), QMessageBox.Abort)
self._master_found_signal.connect(self._wait_for_master_dialog.done, Qt.QueuedConnection)
button = self._wait_for_master_dialog.exec_()
# check if master existence was not detected by background thread
no_master = button != QMessageBox.Ok
self._wait_for_master_dialog.deleteLater()
self._wait_for_master_dialog = None
if no_master:
raise PluginLoadError('RosPyPluginProvider._init_node() could not find ROS master')
def _wait_for_master(self):
while True:
time.sleep(0.1)
if not self._wait_for_master_dialog:
break
try:
rospy.get_master().getSystemState()
except Exception:
continue
self._master_found_signal.emit(QMessageBox.Ok)
break
def _init_node(self):
# initialize node once
if not self._node_initialized:
name = 'rqt_gui_py_node_%d' % os.getpid()
qDebug('RosPyPluginProvider._init_node() initialize ROS node "%s"' % name)
rospy.init_node(name, disable_signals=True)
self._node_initialized = True
示例9: show
def show(self):
# append folder of 'qt_gui_cpp/lib' to module search path
qt_gui_cpp_path = os.path.realpath(get_package_path("qt_gui_cpp"))
sys.path.append(os.path.join(qt_gui_cpp_path, "lib"))
sys.path.append(os.path.join(qt_gui_cpp_path, "src"))
from qt_gui_cpp.cpp_binding_helper import qt_gui_cpp
import rospkg
_rospkg_version = getattr(rospkg, "__version__", "< 0.2.4")
logo = os.path.join(self._qtgui_path, "resource", "ros_org_vertical.png")
text = '<img src="%s" width="56" height="200" style="float: left;"/>' % logo
text += '<h3 style="margin-top: 1px;">%s</h3>' % self.tr("rqt")
text += "<p>%s %s</p>" % (
self.tr("rqt is a framework for graphical user interfaces."),
self.tr("It is extensible with plugins which can be written in either Python or C++."),
)
text += "<p>%s</p>" % (
self.tr(
'Please see the <a href="%s">Wiki</a> for more information on rqt and available plugins.'
% "http://wiki.ros.org/rqt"
)
)
text += "<p>%s: " % self.tr("Utilized libraries:")
text += "Python %s, " % platform.python_version()
text += "rospkg %s, " % _rospkg_version
if QT_BINDING == "pyside":
text += "PySide"
elif QT_BINDING == "pyqt":
text += "PyQt"
text += " %s (%s), " % (QT_BINDING_VERSION, ", ".join(sorted(QT_BINDING_MODULES)))
text += "Qt %s, " % qVersion()
if qt_gui_cpp is not None:
if QT_BINDING == "pyside":
text += "%s" % (self.tr("%s C++ bindings available") % "Shiboken")
elif QT_BINDING == "pyqt":
text += "%s" % (self.tr("%s C++ bindings available") % "SIP")
else:
text += "%s" % self.tr("C++ bindings available")
else:
text += "%s" % self.tr("no C++ bindings found - no C++ plugins available")
text += ".</p>"
mb = QMessageBox(QMessageBox.NoIcon, self.tr("About rqt"), text, QMessageBox.Ok, self.parent())
mb.exec_()
示例10: on_run_motion_button_clicked
def on_run_motion_button_clicked(self):
motion_name = str(self.motion_name_combo.currentText())
if len(motion_name) == 0:
QMessageBox.warning(self, 'Error', 'No motion selected to run.')
return
if motion_name not in self._motion_data:
QMessageBox.warning(self, 'Error', 'Motion "%s" not in motion list.' % motion_name)
return
self._clear_playback_marker()
self._motion_publisher.publish_motion(self._motion_data[motion_name], self.time_factor_spin.value())
print '[Motion Editor] Running motion:', motion_name
示例11: _send_comand_cb
def _send_comand_cb(self):
'''
Sends a mission command
'''
msg = MissionCommand()
msg.command = self._widget.comboBox_command.currentText()
try:
msg.variable = float(self._widget.lineEdit_parameter.text().encode("utf8"))
except ValueError, e:
rospy.logerr('MissionCommanderGUI:_send_command_cb: %s',e)
QMessageBox.warning(self._widget, 'Error', 'Incorrect format of the parameter. A number is expected')
示例12: on_download
def on_download(self):
try:
hrpsys_save = rospy.ServiceProxy("/DataLoggerServiceROSBridge/save", OpenHRP_DataLoggerService_save )
name = "/tmp/rtclog-" + time.strftime("%Y%m%d%H%M%S")
print "Writing log data to ",name
hrpsys_save(OpenHRP_DataLoggerService_saveRequest(name))
print "Done writing",name
except rospy.ServiceException, e:
mb = QMessageBox(QMessageBox.NoIcon, "Error",
"Failed to save rtcd log: service call failed with error: %s"%(e),
QMessageBox.Ok, self.parent())
mb.exec_()
示例13: on_delete_button_clicked
def on_delete_button_clicked(self):
appendix_name = str(self.save_appendix_combo.currentText())
position_name = str(self.save_name_combo.currentText())
if len(position_name) == 0 or \
position_name not in self._position_data[self.robot_config.groups[appendix_name].group_type]:
QMessageBox.warning(self, 'Error', 'Position "%s" not in position list.')
return
self._position_data[self.robot_config.groups[appendix_name].group_type].delete(position_name)
self.position_list_updated.emit(self._position_data)
self.on_save_appendix_combo_currentIndexChanged(appendix_name)
if self.robot_config.groups[self.move_appendix_combo.currentText()].group_type \
== self.robot_config.groups[appendix_name].group_type:
self.on_move_appendix_combo_currentIndexChanged(appendix_name)
示例14: on_saveButton_clicked
def on_saveButton_clicked(self):
'''
Saves the current document. This method is called if the C{save button}
was clicked.
'''
saved, errors, msg = self.tabWidget.currentWidget().save(True)
if errors:
QMessageBox.critical(self, "Error", msg)
self.tabWidget.setTabIcon(self.tabWidget.currentIndex(), self._error_icon)
self.tabWidget.setTabToolTip(self.tabWidget.currentIndex(), msg)
elif saved:
self.tabWidget.setTabIcon(self.tabWidget.currentIndex(), self._empty_icon)
self.tabWidget.setTabToolTip(self.tabWidget.currentIndex(), '')
示例15: on_load_motion_button_clicked
def on_load_motion_button_clicked(self):
motion_name = str(self.motion_name_combo.currentText())
if len(motion_name) == 0:
QMessageBox.warning(self, 'Error', 'No motion selected to load.')
return
if motion_name not in self._motion_data:
QMessageBox.warning(self, 'Error', 'Motion "%s" not in motion list.' % motion_name)
return
self.on_clear_motion_button_clicked()
motion = self._motion_data[motion_name]
for group_name, poses in motion.items():
for pose in poses:
data = self.robot_config.groups[group_name].adapt_to_side(pose['positions'])
self._timeline_widget.scene().add_clip(group_name, pose['name'], pose['starttime'], pose['duration'], data)