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, parent=None):
00047         super(AboutHandler, self).__init__(parent)
00048 
00049     def show(self):
00050         # append folder of 'qt_gui_cpp/lib' to module search path
00051         qt_gui_cpp_path = os.path.realpath(get_package_path('qt_gui_cpp'))
00052         sys.path.append(os.path.join(qt_gui_cpp_path, 'lib'))
00053         sys.path.append(os.path.join(qt_gui_cpp_path, 'src'))
00054         from qt_gui_cpp.cpp_binding_helper import qt_gui_cpp
00055 
00056         _rospkg_version = None
00057         try:
00058             import rospkg
00059             _rospkg_version = getattr(rospkg, '__version__', '< 0.2.4')
00060         except ImportError:
00061             pass
00062 
00063         logo = os.path.realpath(os.path.join(os.path.dirname(__file__), '..', '..', 'icons', 'ros_org_vertical.png'))
00064         text = '<img src="%s" width="56" height="200" style="float: left;"/>' % logo
00065 
00066         text += '<h3 style="margin-top: 1px;">%s</h3>' % self.tr('ROS GUI')
00067 
00068         text += '<p>%s %s</p>' % (self.tr('ROS GUI is a framework for graphical user interfaces.'), self.tr('It is extensible with plugins which can be written in either Python or C++.'))
00069         text += '<p>%s</p>' % (self.tr('Please see the <a href="%s">Wiki</a> for more information on ROS GUI and available plugins.' % 'http://www.ros.org/wiki/rqt'))
00070 
00071         text += '<p>%s: ' % self.tr('Utilized libraries:')
00072 
00073         text += 'Python %s, ' % platform.python_version()
00074 
00075         if _rospkg_version is not None:
00076             text += 'rospkg %s, ' % _rospkg_version
00077         else:
00078             text += '%s, ' % self.tr('rospkg not found - using roslib')
00079 
00080         if QT_BINDING == 'pyside':
00081             text += 'PySide'
00082         elif QT_BINDING == 'pyqt':
00083             text += 'PyQt'
00084         text += ' %s (%s), ' % (QT_BINDING_VERSION, ', '.join(sorted(QT_BINDING_MODULES)))
00085 
00086         text += 'Qt %s, ' % qVersion()
00087 
00088         if qt_gui_cpp is not None:
00089             if QT_BINDING == 'pyside':
00090                 text += '%s' % (self.tr('%s C++ bindings available') % 'Shiboken')
00091             elif QT_BINDING == 'pyqt':
00092                 text += '%s' % (self.tr('%s C++ bindings available') % 'SIP')
00093             else:
00094                 text += '%s' % self.tr('C++ bindings available')
00095         else:
00096             text += '%s' % self.tr('no C++ bindings found - no C++ plugins available')
00097 
00098         text += '.</p>'
00099 
00100         QMessageBox.about(self.parent(), self.tr('About ROS GUI'), text)


qt_gui
Author(s): Dirk Thomas
autogenerated on Fri Jan 3 2014 11:44:00