34 from dbus
import Interface
35 from dbus.connection
import Connection
36 from python_qt_binding.QtCore
import (QByteArray, qCritical, QDataStream,
37 qDebug, QIODevice, Qt, qWarning, Slot)
38 from python_qt_binding.QtGui
import QVBoxLayout, QX11EmbedWidget
47 Client part of the `PluginHandlerXEmbed`.
49 Client utilizes the `PluginHandlerDBusService` of the `PluginHandlerXEmbedContainer` through a
50 peer-to-peer DBus connection.
53 def __init__(self, parent, main_window, instance_id,
54 application_context, container_manager, argv, dbus_object_path):
55 super(PluginHandlerXEmbedClient, self).
__init__(
56 parent, main_window, instance_id, application_context, container_manager, argv)
57 self.setObjectName(
'PluginHandlerXEmbedClient')
68 self.
_remote_container = Interface(proxy,
'org.ros.qt_gui.PluginHandlerContainer')
83 super(PluginHandlerXEmbedClient, self).
_load()
87 if exception
is not None:
106 qDebug(
'PluginHandlerXEmbedClient._save_settings_from_remote()')
113 'PluginHandlerXEmbedClient._save_settings_from_remote() plugin "%s" '
114 'raised an exception:\n%s' % (str(self.
_instance_id), traceback.format_exc()))
125 qDebug(
'PluginHandlerXEmbedClient._restore_settings_from_remote()')
132 'PluginHandlerXEmbedClient._restore_settings_from_remote() '
133 'plugin "%s" raised an exception:\n%s' %
144 qWarning(
'PluginHandlerXEmbedClient.add_widget() widget "%s" already added' %
147 embed_widget = QX11EmbedWidget()
148 layout = QVBoxLayout()
149 layout.setContentsMargins(0, 0, 0, 0)
150 layout.addWidget(widget)
151 embed_widget.setLayout(layout)
158 os.getpid(), widget.objectName())
159 embed_widget.embedInto(embed_container_window_id)
166 signaler.window_icon_changed_signal.emit(widget)
167 signaler.window_title_changed_signal.emit(widget)
174 s = QDataStream(ba, QIODevice.WriteOnly)
175 s << widget.windowIcon()
176 icon_str = str(ba.toBase64())
177 self.
_remote_container.update_embedded_widget_icon(widget.objectName(), icon_str)
181 widget.objectName(), widget.windowTitle())
192 widget.setParent(
None)
193 embed_widget.deleteLater()
200 qWarning(
'PluginHandlerXEmbedClient.add_toolbar() toolbar "%s" already added' %
201 toolbar.objectName())
203 embed_widget = QX11EmbedWidget()
204 layout = QVBoxLayout()
205 layout.setContentsMargins(0, 0, 0, 0)
206 layout.addWidget(toolbar)
207 embed_widget.setLayout(layout)
213 print(
'embed_widget.containerClosed')
214 embed_widget.containerClosed.connect(foo)
217 os.getpid(), toolbar.objectName())
218 embed_widget.embedInto(embed_container_window_id)
226 if embed_widget.containerWinId() == win_id:
227 toolbar.setOrientation(Qt.Horizontal
if is_horizontal
else Qt.Vertical)
237 toolbar.setParent(
None)
238 embed_widget.deleteLater()