about_handler.py
Go to the documentation of this file.
00001 # Copyright (c) 2011, Dirk Thomas, Dorian Scholz, TU Darmstadt
00002 # All rights reserved.
00003 #
00004 # Redistribution and use in source and binary forms, with or without
00005 # modification, are permitted provided that the following conditions
00006 # are met:
00007 #
00008 #   * Redistributions of source code must retain the above copyright
00009 #     notice, this list of conditions and the following disclaimer.
00010 #   * Redistributions in binary form must reproduce the above
00011 #     copyright notice, this list of conditions and the following
00012 #     disclaimer in the documentation and/or other materials provided
00013 #     with the distribution.
00014 #   * Neither the name of the TU Darmstadt nor the names of its
00015 #     contributors may be used to endorse or promote products derived
00016 #     from this software without specific prior written permission.
00017 #
00018 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00019 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00020 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00021 # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00022 # COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00023 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00024 # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00025 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00026 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00027 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00028 # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00029 # POSSIBILITY OF SUCH DAMAGE.
00030 
00031 import os
00032 import platform
00033 import sys
00034 
00035 from python_qt_binding import QT_BINDING, QT_BINDING_MODULES, QT_BINDING_VERSION
00036 from python_qt_binding.QtCore import QObject, qVersion
00037 from python_qt_binding.QtGui import QMessageBox
00038 
00039 from .ros_package_helper import get_package_path
00040 
00041 
00042 class AboutHandler(QObject):
00043 
00044     """Handler for the about action in the menu bar showing a message box with details on the used libraries and their versions."""
00045 
00046     def __init__(self, qtgui_path, parent=None):
00047         super(AboutHandler, self).__init__(parent)
00048         self._qtgui_path = qtgui_path
00049 
00050     def show(self):
00051         # append folder of 'qt_gui_cpp/lib' to module search path
00052         qt_gui_cpp_path = os.path.realpath(get_package_path('qt_gui_cpp'))
00053         sys.path.append(os.path.join(qt_gui_cpp_path, 'lib'))
00054         sys.path.append(os.path.join(qt_gui_cpp_path, 'src'))
00055         from qt_gui_cpp.cpp_binding_helper import qt_gui_cpp
00056 
00057         import rospkg
00058         _rospkg_version = getattr(rospkg, '__version__', '< 0.2.4')
00059 
00060         logo = os.path.join(self._qtgui_path, 'resource', 'ros_org_vertical.png')
00061         text = '<img src="%s" width="56" height="200" style="float: left;"/>' % logo
00062 
00063         text += '<h3 style="margin-top: 1px;">%s</h3>' % self.tr('rqt')
00064 
00065         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++.'))
00066         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'))
00067 
00068         text += '<p>%s: ' % self.tr('Utilized libraries:')
00069 
00070         text += 'Python %s, ' % platform.python_version()
00071 
00072         text += 'rospkg %s, ' % _rospkg_version
00073 
00074         if QT_BINDING == 'pyside':
00075             text += 'PySide'
00076         elif QT_BINDING == 'pyqt':
00077             text += 'PyQt'
00078         text += ' %s (%s), ' % (QT_BINDING_VERSION, ', '.join(sorted(QT_BINDING_MODULES)))
00079 
00080         text += 'Qt %s, ' % qVersion()
00081 
00082         if qt_gui_cpp is not None:
00083             if QT_BINDING == 'pyside':
00084                 text += '%s' % (self.tr('%s C++ bindings available') % 'Shiboken')
00085             elif QT_BINDING == 'pyqt':
00086                 text += '%s' % (self.tr('%s C++ bindings available') % 'SIP')
00087             else:
00088                 text += '%s' % self.tr('C++ bindings available')
00089         else:
00090             text += '%s' % self.tr('no C++ bindings found - no C++ plugins available')
00091 
00092         text += '.</p>'
00093 
00094         mb = QMessageBox(QMessageBox.NoIcon, self.tr('About rqt'), text, QMessageBox.Ok, self.parent())
00095         mb.exec_()


qt_gui
Author(s): Dirk Thomas
autogenerated on Thu Jun 6 2019 18:07:34