eric6/E5Gui/E5AnimatedLabel.py

Sat, 27 Feb 2021 12:08:23 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 27 Feb 2021 12:08:23 +0100
changeset 8138
169e65a6787c
parent 7923
91e843545d9a
child 8218
7c09585bd960
permissions
-rw-r--r--

Shell: added functionality to show a prompt when the main client process has exited (e.g. a script ended).

7514
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
7923
91e843545d9a Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7514
diff changeset
3 # Copyright (c) 2020 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
7514
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a label widget showing an animated pixmap.
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 from PyQt5.QtCore import pyqtSlot, QTimer
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11 from PyQt5.QtGui import QPixmap
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12 from PyQt5.QtWidgets import QLabel
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14 import UI.PixmapCache
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17 class E5AnimatedLabel(QLabel):
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 """
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 Class implementing a label widget showing an animated pixmap.
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 """
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 def __init__(self, parent=None, *, animationFile="", interval=100):
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 """
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 Constructor
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 @param parent reference to the parent window
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 @type QWidget
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 @keyparam animationFile path to the file containing the animation data
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 @type str
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 @keyparam interval interval in milliseconds between animation frames
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 @type int
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 """
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 super(E5AnimatedLabel, self).__init__(parent)
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 self.__timer = QTimer(self)
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 self.__timer.setInterval(interval)
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 self.__timer.timeout.connect(self.__animate)
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 self.__currentFrame = 0
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 self.__frames = 0
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 self.__pixmap = None
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 self.__pixmapHeight = 0
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 self.__animationFile = ""
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 self.__animationFileLoaded = False
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 self.__loadAnimationFile(animationFile)
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 def __loadAnimationFile(self, animationFile):
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 """
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 Private method to load an animation file.
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 @param animationFile path to the file containing the animation data
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 @type str
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 """
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 self.__animationFile = animationFile
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 pixmap = UI.PixmapCache.getPixmap(animationFile)
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 if not pixmap.isNull():
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 self.__pixmap = pixmap
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 self.__pixmapHeight = pixmap.height()
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 self.__frames = pixmap.width() // pixmap.height()
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 # assume quadratic animation frames
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 self.__animationFileLoaded = True
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 else:
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 self.__pixmap = QPixmap()
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 self.__pixmapHeight = 0
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 self.__frames = 0
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 self.__animationFileLoaded = False
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 self.reset()
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 @pyqtSlot()
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 def __animate(self):
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 """
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 Private slot to animate the pixmap.
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 """
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 if self.__animationFileLoaded:
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 self.__currentFrame = (self.__currentFrame + 1) % self.__frames
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 super(E5AnimatedLabel, self).setPixmap(self.__pixmap.copy(
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 self.__currentFrame * self.__pixmapHeight,
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 0,
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 self.__pixmapHeight,
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 self.__pixmapHeight
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 ))
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 else:
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 self.clear()
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87 @pyqtSlot()
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88 def reset(self):
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89 """
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 Public slot to reset the animation.
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91 """
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92 self.__currentFrame = -1
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93 self.__animate()
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95 @pyqtSlot()
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96 def start(self):
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97 """
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98 Public slot to start the animation.
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99 """
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 if self.__animationFileLoaded:
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 self.__timer.start()
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103 @pyqtSlot()
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104 def stop(self):
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105 """
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 Public slot to stop the animation.
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107 """
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108 self.__timer.stop()
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 def isActive(self):
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111 """
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112 Public method to check, if the animation is active.
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114 @return flag indicating an active animation
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115 @rtype bool
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116 """
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117 return self.__timer.isActive() and self.__animationFileLoaded
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 def setAnimationFile(self, animationFile):
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 """
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121 Public method to set the name of the animation file.
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
122
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123 @param animationFile path to the file containing the animation data
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124 @type str
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125 """
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126 active = self.__timer.isActive()
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127 self.__timer.stop()
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128 self.__loadAnimationFile(animationFile)
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129 if active and self.__animationFileLoaded:
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130 self.__timer.start()
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132 def getAnimationFile(self):
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
133 """
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
134 Public method to get the name of the animation file.
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136 @return path to the file containing the animation data
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
137 @rtype str
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138 """
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
139 return self.__animationFile
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
140
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
141 def isAnimationFileLoaded(self):
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
142 """
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
143 Public method to check, if the animation file was loaded.
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
144
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145 @return flag indicating a successfully loaded animation file
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146 @rtype bool
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
147 """
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
148 return self.__animationFileLoaded
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
149
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
150 def setInterval(self, interval):
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
151 """
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
152 Public method to set the interval between the animated frames.
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
153
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
154 @param interval interval in milliseconds between animation frames
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
155 @type int
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
156 """
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
157 self.__timer.setInterval(interval)
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
158
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
159 def getInterval(self):
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
160 """
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
161 Public method to get the interval between the animated frames.
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
162
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
163 @return interval in milliseconds between animation frames
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
164 @rtype int
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
165 """
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
166 return self.__timer.interval()
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
167
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
168 def setPixmap(self, pixmap):
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
169 """
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
170 Public slot to set the pixmap of the label.
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
171
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
172 Setting a standard pixmap will stop the animation and set the given
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
173 pixmap without animating it. Thereafter the animation has to be
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
174 restarted with the start() method.
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
175
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
176 @param pixmap pixmap to be set
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
177 @type QPixmap
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
178 """
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
179 self.stop()
0960c7c1f497 Added a label widget showing an animated pixmap.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
180 super(E5AnimatedLabel, self).setPixmap(pixmap)

eric ide

mercurial