Home | Trees | Indices | Help |
|
---|
|
1 # ============================================================================ 2 # 3 # Copyright (C) 2007-2008 Conceptive Engineering bvba. All rights reserved. 4 # www.conceptive.be / project-camelot@conceptive.be 5 # 6 # This file is part of the Camelot Library. 7 # 8 # This file may be used under the terms of the GNU General Public 9 # License version 2.0 as published by the Free Software Foundation 10 # and appearing in the file LICENSE.GPL included in the packaging of 11 # this file. Please review the following information to ensure GNU 12 # General Public Licensing requirements will be met: 13 # http://www.trolltech.com/products/qt/opensource.html 14 # 15 # If you are unsure which license is appropriate for your use, please 16 # review the following information: 17 # http://www.trolltech.com/products/qt/licensing.html or contact 18 # project-camelot@conceptive.be. 19 # 20 # This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 21 # WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 22 # 23 # For use of this library in commercial applications, please contact 24 # project-camelot@conceptive.be 25 # 26 # ============================================================================ 27 28 from PyQt4 import QtGui 29 from PyQt4.QtCore import Qt 3032 """A widget indicating the application is performing some background task. The widget acts 33 as an overlay of its parent widget and displays animating orbs""" 348836 QtGui.QWidget.__init__(self, parent) 37 palette = QtGui.QPalette(self.palette()) 38 palette.setColor(palette.Background, Qt.transparent) 39 self.setPalette(palette) 40 self.setAttribute(Qt.WA_TransparentForMouseEvents) 41 self.orbs = 5 42 self.highlighted_orb = self.orbs 43 self.timer = None4446 """start/stop the animation 47 :arg busy_state: True or False 48 """ 49 if busy_state: 50 self.timer = self.startTimer(200) 51 self.counter = 0 52 self.show() 53 else: 54 if self.timer: 55 self.killTimer(self.timer) 56 self.timer = None 57 self.hide()5860 """custom paint, painting the orbs""" 61 painter = QtGui.QPainter() 62 painter.begin(self) 63 painter.setRenderHint(QtGui.QPainter.Antialiasing) 64 painter.setPen(QtGui.QPen(Qt.NoPen)) 65 width = self.width() 66 height = self.height() 67 radius = (min(width, height)/4) 68 for i in range(self.orbs): 69 if i!=self.highlighted_orb: 70 painter.setBrush(QtGui.QBrush(QtGui.QColor(180, 180, 180))) 71 else: 72 painter.setBrush(QtGui.QBrush(QtGui.QColor(127, 127, 127))) 73 center_x = width - (3*i+2)*radius 74 center_y = height / 2 75 painter.drawEllipse(center_x - radius, 76 center_y - radius, 77 2*radius, 78 2*radius) 79 painter.end()80
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Sat Jun 12 15:42:12 2010 | http://epydoc.sourceforge.net |