当前位置: 首页>>代码示例>>Python>>正文


Python QMessageBox.deleteLater方法代码示例

本文整理汇总了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
开发者ID:NhatTanXT3,项目名称:humanoid_op_ros,代码行数:57,代码来源:ros_py_plugin_provider.py


注:本文中的python_qt_binding.QtGui.QMessageBox.deleteLater方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。