master_info.py
Go to the documentation of this file.
00001 #
00002 # License: BSD
00003 #   https://raw.github.com/robotics-in-concert/rocon_qt_gui/license/LICENSE
00004 #
00005 ##############################################################################
00006 # Imports
00007 ##############################################################################
00008 
00009 from __future__ import division
00010 import os
00011 
00012 from python_qt_binding import loadUi
00013 
00014 # QtCore
00015 #    SIGNAL, SLOT,  pyqtSlot, pyqtSignal
00016 #    QString, QStringList,
00017 #    QPoint, QEvent, QFile, QIODevice,
00018 #    QAbstractListModel
00019 #from python_qt_binding.QtCore import Qt, QAbstractListModel
00020 # QtGui
00021 #    QMainWindow,
00022 #    QCheckBox, QComboBox,
00023 #    QTextEdit, QCompleter,
00024 #    QFileDialog,
00025 #    QPushButton
00026 #    QGraphicsScene, QImage, QPainter, QBrush, QColor, QPen, QPixmap
00027 from python_qt_binding.QtGui import QWidget, QPixmap
00028 # QtSvg
00029 #    QSvgGenerator
00030 
00031 from qt_gui.plugin import Plugin
00032 
00033 import rospkg
00034 import rocon_master_info
00035 
00036 ##############################################################################
00037 # Plugin
00038 ##############################################################################
00039 
00040 
00041 class MasterInfo(Plugin):
00042 
00043     def __init__(self, context):
00044         super(MasterInfo, self).__init__(context)
00045         self.initialised = False
00046         self.setObjectName('MasterInfo')
00047         self._current_dotcode = None
00048 
00049         self._master_info = rocon_master_info.get_master_info(0.5)  # at worst a small timeout here, but perhaps should be run in a thread.
00050 
00051         self._widget = QWidget()
00052         self._widget.setObjectName('RoconMasterInfoUi')
00053         rospack = rospkg.RosPack()
00054         ui_file = os.path.join(rospack.get_path('rocon_qt_master_info'), 'ui', 'master_info.ui')
00055         loadUi(ui_file, self._widget)
00056         if context.serial_number() > 1:
00057             self._widget.setWindowTitle(self._widget.windowTitle() + (' (%d)' % context.serial_number()))
00058 
00059         pixmap = QPixmap()
00060         pixmap.loadFromData(self._master_info.icon.data, format=self._master_info.icon.format)
00061         self._widget.icon_label.setPixmap(pixmap)
00062         self._widget.icon_label.resize(pixmap.width(), pixmap.height())
00063 
00064         self._widget.info_label.resize(200, pixmap.height())
00065         self._widget.info_label.setText("<b>Name:</b> %s<br/><b>Rocon Version:</b> %s<br/><b>Description:</b> %s" % (self._master_info.name, self._master_info.version, self._master_info.description))
00066         self._widget.adjustSize()
00067 
00068         context.add_widget(self._widget)
00069 
00070     def shutdown_plugin(self):
00071         pass


rocon_qt_master_info
Author(s): Daniel Stonier
autogenerated on Fri Feb 12 2016 02:50:15