about_handler.py
Go to the documentation of this file.
1 # Copyright (c) 2011, Dirk Thomas, Dorian Scholz, TU Darmstadt
2 # All rights reserved.
3 #
4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions
6 # are met:
7 #
8 # * Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer.
10 # * Redistributions in binary form must reproduce the above
11 # copyright notice, this list of conditions and the following
12 # disclaimer in the documentation and/or other materials provided
13 # with the distribution.
14 # * Neither the name of the TU Darmstadt nor the names of its
15 # contributors may be used to endorse or promote products derived
16 # from this software without specific prior written permission.
17 #
18 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21 # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22 # COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
23 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24 # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
28 # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 # POSSIBILITY OF SUCH DAMAGE.
30 
31 import os
32 import platform
33 import sys
34 
35 from python_qt_binding import QT_BINDING, QT_BINDING_MODULES, QT_BINDING_VERSION
36 from python_qt_binding.QtCore import QObject, qVersion
37 from python_qt_binding.QtWidgets import QMessageBox
38 
39 from .ros_package_helper import get_package_path
40 
41 
42 class AboutHandler(QObject):
43  """
44  Handler for the 'About action' menu bar item.
45 
46  This handler shows a message box with details on the used libraries and their versions.
47  """
48 
49  def __init__(self, qtgui_path, parent=None):
50  super(AboutHandler, self).__init__(parent)
51  self._qtgui_path = qtgui_path
52 
53  def show(self):
54  try:
55  # append folder of 'qt_gui_cpp/lib' to module search path
56  qt_gui_cpp_path = os.path.realpath(get_package_path('qt_gui_cpp'))
57  except Exception:
58  qt_gui_cpp = None
59  else:
60  sys.path.append(os.path.join(qt_gui_cpp_path, 'lib'))
61  sys.path.append(os.path.join(qt_gui_cpp_path, 'src'))
62  from qt_gui_cpp.cpp_binding_helper import qt_gui_cpp
63 
64  import rospkg
65  _rospkg_version = getattr(rospkg, '__version__', '< 0.2.4')
66 
67  logo = os.path.join(self._qtgui_path, 'resource', 'ros_org_vertical.png')
68  text = '<img src="%s" width="56" height="200" style="float: left;"/>' % logo
69 
70  text += '<h3 style="margin-top: 1px;">%s</h3>' % self.tr('rqt')
71 
72  text += '<p>%s %s</p>' % (
73  self.tr('rqt is a framework for graphical user interfaces.'),
74  self.tr('It is extensible with plugins which can be written in either Python or C++.'))
75  text += '<p>%s</p>' % (
76  self.tr(
77  'Please see the <a href="%s">Wiki</a> for more information on rqt and available '
78  'plugins.' % 'http://wiki.ros.org/rqt'))
79 
80  text += '<p>%s: ' % self.tr('Utilized libraries:')
81 
82  text += 'Python %s, ' % platform.python_version()
83 
84  text += 'rospkg %s, ' % _rospkg_version
85 
86  if QT_BINDING == 'pyside':
87  text += 'PySide'
88  elif QT_BINDING == 'pyqt':
89  text += 'PyQt'
90  text += ' %s (%s), ' % (QT_BINDING_VERSION, ', '.join(sorted(QT_BINDING_MODULES)))
91 
92  text += 'Qt %s, ' % qVersion()
93 
94  if qt_gui_cpp is not None:
95  if QT_BINDING == 'pyside':
96  text += '%s' % (self.tr('%s C++ bindings available') % 'Shiboken')
97  elif QT_BINDING == 'pyqt':
98  text += '%s' % (self.tr('%s C++ bindings available') % 'SIP')
99  else:
100  text += '%s' % self.tr('C++ bindings available')
101  else:
102  text += '%s' % self.tr('no C++ bindings found - no C++ plugins available')
103 
104  text += '.</p>'
105 
106  mb = QMessageBox(
107  QMessageBox.NoIcon, self.tr('About rqt'), text, QMessageBox.Ok, self.parent())
108  mb.exec_()
qt_gui.about_handler.AboutHandler.__init__
def __init__(self, qtgui_path, parent=None)
Definition: about_handler.py:49
qt_gui.about_handler.AboutHandler
Definition: about_handler.py:42
qt_gui.ros_package_helper.get_package_path
def get_package_path(name)
Definition: ros_package_helper.py:32
qt_gui.about_handler.AboutHandler._qtgui_path
_qtgui_path
Definition: about_handler.py:51
qt_gui.about_handler.AboutHandler.show
def show(self)
Definition: about_handler.py:53


qt_gui
Author(s): Dirk Thomas
autogenerated on Sat Jun 25 2022 02:15:05