本文整理汇总了Python中python_qt_binding.QtGui.QMessageBox.deleteLater方法的典型用法代码示例。如果您正苦于以下问题:Python QMessageBox.deleteLater方法的具体用法?Python QMessageBox.deleteLater怎么用?Python QMessageBox.deleteLater使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类python_qt_binding.QtGui.QMessageBox
的用法示例。
在下文中一共展示了QMessageBox.deleteLater方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: RosPyPluginProvider
# 需要导入模块: from python_qt_binding.QtGui import QMessageBox [as 别名]
# 或者: from python_qt_binding.QtGui.QMessageBox import deleteLater [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