本文整理汇总了Python中python_qt_binding.QtGui.QMessageBox.exec_方法的典型用法代码示例。如果您正苦于以下问题:Python QMessageBox.exec_方法的具体用法?Python QMessageBox.exec_怎么用?Python QMessageBox.exec_使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类python_qt_binding.QtGui.QMessageBox
的用法示例。
在下文中一共展示了QMessageBox.exec_方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from python_qt_binding.QtGui import QMessageBox [as 别名]
# 或者: from python_qt_binding.QtGui.QMessageBox import exec_ [as 别名]
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
示例2: on_power_on
# 需要导入模块: from python_qt_binding.QtGui import QMessageBox [as 别名]
# 或者: from python_qt_binding.QtGui.QMessageBox import exec_ [as 别名]
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_()
示例3: _showWarning
# 需要导入模块: from python_qt_binding.QtGui import QMessageBox [as 别名]
# 或者: from python_qt_binding.QtGui.QMessageBox import exec_ [as 别名]
def _showWarning(self, title, body):
if threading.current_thread().name != "MainThread":
rospy.logwarn("{}: {}".format(title, body))
else:
msg = QMessageBox()
msg.setIcon(QMessageBox.Warning)
msg.setWindowTitle(title)
msg.setText(body)
msg.setStandardButtons(QMessageBox.Ok)
msg.exec_()
示例4: show
# 需要导入模块: from python_qt_binding.QtGui import QMessageBox [as 别名]
# 或者: from python_qt_binding.QtGui.QMessageBox import exec_ [as 别名]
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_()
示例5: on_download
# 需要导入模块: from python_qt_binding.QtGui import QMessageBox [as 别名]
# 或者: from python_qt_binding.QtGui.QMessageBox import exec_ [as 别名]
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_()
示例6: DialogService
# 需要导入模块: from python_qt_binding.QtGui import QMessageBox [as 别名]
# 或者: from python_qt_binding.QtGui.QMessageBox import exec_ [as 别名]
class DialogService(QWidget):
'''
Provides popup windows for information and error messages
'''
#----------------------------------
# Initializer
#--------------
def __init__(self, parent=None):
super(DialogService, self).__init__(parent);
# All-purpose error popup message:
# Used by self.showErrorMsgByErrorCode(<errorCode>),
# or self.showErrorMsg(<string>). Returns a
# QErrorMessage without parent, but with QWindowFlags set
# properly to be a dialog popup box:
self.errorMsgPopup = QErrorMessage.qtHandler();
# Re-parent the popup, retaining the window flags set
# by the qtHandler:
self.errorMsgPopup.setParent(parent, self.errorMsgPopup.windowFlags());
#self.errorMsgPopup.setStyleSheet(SpeakEasyGUI.stylesheetAppBG);
self.infoMsg = QMessageBox(parent=parent);
#self.infoMsg.setStyleSheet(SpeakEasyGUI.stylesheetAppBG);
#----------------------------------
# showErrorMsg
#--------------
QErrorMessage
def showErrorMsg(self,errMsg):
'''
Given a string, pop up an error dialog on top of the application window.
@param errMsg: The message
@type errMsg: string
'''
self.errorMsgPopup.showMessage(errMsg);
#----------------------------------
# showInfoMsg
#--------------
def showInfoMsg(self, text):
'''
Display a message window with an OK button on top of the application window.
@param text: text to display
@type text: string
'''
self.infoMsg.setText(text);
self.infoMsg.exec_();
示例7: on_servo_off
# 需要导入模块: from python_qt_binding.QtGui import QMessageBox [as 别名]
# 或者: from python_qt_binding.QtGui.QMessageBox import exec_ [as 别名]
def on_servo_off(self):
try:
if self.stop_command:
Popen(['bash', '-c', self.stop_command])
else:
power = rospy.ServiceProxy("/RobotHardwareServiceROSBridge/power", OpenHRP_RobotHardwareService_power )
servo = rospy.ServiceProxy("/RobotHardwareServiceROSBridge/servo", OpenHRP_RobotHardwareService_servo )
servo(OpenHRP_RobotHardwareService_servoRequest("all", 1))
time.sleep(1)
power(OpenHRP_RobotHardwareService_powerRequest("all",1))
except Exception, e:
mb = QMessageBox(QMessageBox.NoIcon, "Error",
"Failed to servo off: %s"%(e),
QMessageBox.Ok, self.parent())
mb.exec_()
示例8: on_servo_off
# 需要导入模块: from python_qt_binding.QtGui import QMessageBox [as 别名]
# 或者: from python_qt_binding.QtGui.QMessageBox import exec_ [as 别名]
def on_servo_off(self):
try:
if self.stop_command:
Popen(["bash", "-c", self.stop_command])
elif self.use_hrpsys_configurator:
execHrpsysConfiguratorCommand("hcf.servoOff()")
else:
power = rospy.ServiceProxy("/RobotHardwareServiceROSBridge/power", OpenHRP_RobotHardwareService_power)
servo = rospy.ServiceProxy("/RobotHardwareServiceROSBridge/servo", OpenHRP_RobotHardwareService_servo)
servo(OpenHRP_RobotHardwareService_servoRequest("all", 1))
time.sleep(1)
power(OpenHRP_RobotHardwareService_powerRequest("all", 1))
except Exception, e:
mb = QMessageBox(
QMessageBox.NoIcon, "Error", "Failed to servo off: %s" % (e), QMessageBox.Ok, self.parent()
)
mb.exec_()
示例9: on_servo_on
# 需要导入模块: from python_qt_binding.QtGui import QMessageBox [as 别名]
# 或者: from python_qt_binding.QtGui.QMessageBox import exec_ [as 别名]
def on_servo_on(self):
try:
if self.start_command:
Popen(['bash', '-c', self.start_command])
else:
servo = rospy.ServiceProxy("/RobotHardwareServiceROSBridge/servo", OpenHRP_RobotHardwareService_servo )
power = rospy.ServiceProxy("/RobotHardwareServiceROSBridge/power", OpenHRP_RobotHardwareService_power )
actual = rospy.ServiceProxy("/StateHolderServiceROSBridge/goActual", OpenHRP_StateHolderService_goActual )
power(OpenHRP_RobotHardwareService_powerRequest("all",0))
time.sleep(1)
actual(OpenHRP_StateHolderService_goActualRequest())
time.sleep(2)
servo(OpenHRP_RobotHardwareService_servoRequest("all",0))
except Exception, e:
mb = QMessageBox(QMessageBox.NoIcon, "Error",
"Failed to servo on: %s"%(e),
QMessageBox.Ok, self.parent())
mb.exec_()
示例10: RosPyPluginProvider
# 需要导入模块: from python_qt_binding.QtGui import QMessageBox [as 别名]
# 或者: from python_qt_binding.QtGui.QMessageBox import exec_ [as 别名]
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
示例11: newButtonSetOrUpdateCurrent
# 需要导入模块: from python_qt_binding.QtGui import QMessageBox [as 别名]
# 或者: from python_qt_binding.QtGui.QMessageBox import exec_ [as 别名]
def newButtonSetOrUpdateCurrent(self):
'''
Asks user whether saving of button set is to be
to a new file, or an update to the current file.
Cancel is offered as well.
@return: ButtonSaveResult.NEW_SET, ButtonSaveResult.UPDATE_CURRENT, or ButtonSaveResult.CANCEL
@rtype: DialogService.ButtonSaveResult
'''
msgBox = QMessageBox()
msgBox.setStyleSheet(SpeakEasyGUI.stylesheetAppBG);
msgBox.setText('Create new button set, or update current set?')
updateCurrButton = QPushButton('Update current')
msgBox.addButton(updateCurrButton, QMessageBox.NoRole)
newSetButton = QPushButton('Create new set')
msgBox.addButton(newSetButton, QMessageBox.YesRole)
cancelButton = QPushButton('Cancel');
msgBox.addButton(cancelButton, QMessageBox.RejectRole)
value = msgBox.exec_();
return value;
示例12: DialogService
# 需要导入模块: from python_qt_binding.QtGui import QMessageBox [as 别名]
# 或者: from python_qt_binding.QtGui.QMessageBox import exec_ [as 别名]
class DialogService(object):
class ButtonSaveResult:
UPDATE_CURRENT = 0;
NEW_SET = 1;
CANCEL = 2;
#----------------------------------
# Initializer
#--------------
def __init__(self, parent=None):
# All-purpose error popup message:
# Used by self.showErrorMsgByErrorCode(<errorCode>),
# or self.showErrorMsg(<string>). Returns a
# QErrorMessage without parent, but with QWindowFlags set
# properly to be a dialog popup box:
self.errorMsgPopup = QErrorMessage.qtHandler();
# Re-parent the popup, retaining the window flags set
# by the qtHandler:
self.errorMsgPopup.setParent(parent, self.errorMsgPopup.windowFlags());
self.errorMsgPopup.setStyleSheet(SpeakEasyGUI.stylesheetAppBG);
self.infoMsg = QMessageBox(parent=parent);
self.infoMsg.setStyleSheet(SpeakEasyGUI.stylesheetAppBG);
#----------------------------------
# showErrorMsg
#--------------
QErrorMessage
def showErrorMsg(self,errMsg):
'''
Given a string, pop up an error dialog.
@param errMsg: The message
@type errMsg: string
'''
self.errorMsgPopup.showMessage(errMsg);
#----------------------------------
# showInfoMsg
#--------------
def showInfoMessage(self, text):
self.infoMsg.setText(text);
self.infoMsg.exec_();
#----------------------------------
# newButtonSetOrUpdateCurrent
#--------------
def newButtonSetOrUpdateCurrent(self):
'''
Asks user whether saving of button set is to be
to a new file, or an update to the current file.
Cancel is offered as well.
@return: ButtonSaveResult.NEW_SET, ButtonSaveResult.UPDATE_CURRENT, or ButtonSaveResult.CANCEL
@rtype: DialogService.ButtonSaveResult
'''
msgBox = QMessageBox()
msgBox.setStyleSheet(SpeakEasyGUI.stylesheetAppBG);
msgBox.setText('Create new button set, or update current set?')
updateCurrButton = QPushButton('Update current')
msgBox.addButton(updateCurrButton, QMessageBox.NoRole)
newSetButton = QPushButton('Create new set')
msgBox.addButton(newSetButton, QMessageBox.YesRole)
cancelButton = QPushButton('Cancel');
msgBox.addButton(cancelButton, QMessageBox.RejectRole)
value = msgBox.exec_();
return value;
示例13: show_warning
# 需要导入模块: from python_qt_binding.QtGui import QMessageBox [as 别名]
# 或者: from python_qt_binding.QtGui.QMessageBox import exec_ [as 别名]
def show_warning(self, text):
qWarning(text)
msgBox = QMessageBox()
msgBox.setText(text)
msgBox.exec_()