popup.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 #
00003 # Copyright 2015 Airbus
00004 # Copyright 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA)
00005 #
00006 # Licensed under the Apache License, Version 2.0 (the "License");
00007 # you may not use this file except in compliance with the License.
00008 # You may obtain a copy of the License at
00009 #
00010 #   http://www.apache.org/licenses/LICENSE-2.0
00011 #
00012 # Unless required by applicable law or agreed to in writing, software
00013 # distributed under the License is distributed on an "AS IS" BASIS,
00014 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00015 # See the License for the specific language governing permissions and
00016 # limitations under the License.
00017 
00018 import rospy
00019 
00020 from python_qt_binding import QtGui
00021 from python_qt_binding import QtCore
00022 
00023 ## @package: QAgiPopup
00024 ##
00025 ## @version 2.0
00026 ## @author  Matignon Martin
00027 ## @date    Last modified 04/03/2014
00028 ## @class QAgiPopup
00029 ## @brief Popup object.
00030 class QAgiPopup(QtGui.QWidget):
00031 
00032     TopLeft     = 1
00033     BottomRight = 2
00034     TopRight    = 3
00035     BottomLeft  = 4
00036     Center      = 5
00037     
00038     def __init__(self, parent = None):
00039         """! The constructor.
00040         @param parent: object parent.
00041         @type parent: QObject.
00042         """
00043         
00044         QtGui.QWidget.__init__(self, parent)
00045         self.setWindowFlags(QtCore.Qt.Popup | QtCore.Qt.FramelessWindowHint)
00046         self.setStyleSheet("QWidget{background-color: #d9d9d9;}")
00047         self._parent = parent
00048         self._popup_link  = self.TopRight
00049         self._parent_link = self.BottomRight
00050     
00051     @staticmethod
00052     def getObjectPosition(obj, corner):
00053         """! Get glabal corner position.
00054         @param obj: object.
00055         @type obj: QObject.
00056         
00057         @param corner: corner type.
00058         @type corner: int.
00059         """
00060         if corner == QAgiPopup.TopLeft:
00061             return obj.mapToGlobal(obj.rect().topLeft())
00062         elif corner == QAgiPopup.BottomRight:
00063             return obj.mapToGlobal(obj.rect().bottomRight())
00064         elif corner == QAgiPopup.TopRight:
00065             return obj.mapToGlobal(obj.rect().topRight())
00066         elif corner == QAgiPopup.BottomLeft:
00067             return obj.mapToGlobal(obj.rect().bottomLeft())
00068         else :
00069             return obj.mapToGlobal(obj.rect().center())
00070         
00071     def setRelativePosition(self, popup, widget):
00072         self._popup_link  = popup
00073         self._parent_link = widget
00074         
00075     def show_(self):
00076         
00077         """! Show popup."""
00078         parent_pos = QAgiPopup.getObjectPosition(self._parent, self._parent_link)
00079         popup_pos = QAgiPopup.getObjectPosition(self, self._popup_link)
00080         
00081         self.move(parent_pos - popup_pos)
00082         self.show()
00083         
00084 #End of file


airbus_pyqt_extend
Author(s): Martin Matignon
autogenerated on Thu Jun 6 2019 17:59:16