src/eric7/EricWidgets/EricAnimatedWidget.py

branch
eric7
changeset 10476
5182a7c5a9f3
parent 10475
ee41fab001f2
child 10482
72d9b5ea39b4
equal deleted inserted replaced
10475:ee41fab001f2 10476:5182a7c5a9f3
9 9
10 # 10 #
11 # Code was inspired by qupzilla web browser 11 # Code was inspired by qupzilla web browser
12 # 12 #
13 13
14 import enum
15
14 from PyQt6.QtCore import QPoint, QTimeLine, pyqtSlot 16 from PyQt6.QtCore import QPoint, QTimeLine, pyqtSlot
15 from PyQt6.QtWidgets import QWidget 17 from PyQt6.QtWidgets import QWidget
16 18
19
20 class EricAnimationDirection(enum.Enum):
21 """
22 Class defining the animation directions.
23 """
24 Down = 0
25 Up = 1
17 26
18 class EricAnimatedWidget(QWidget): 27 class EricAnimatedWidget(QWidget):
19 """ 28 """
20 Class implementing an animated widget. 29 Class implementing an animated widget.
21 """ 30 """
22 31
23 # TODO: change this to an enum 32 def __init__(
24 DirectionDown = 0 33 self, direction=EricAnimationDirection.Down, duration=300, parent=None
25 DirectionUp = 1 34 ):
26
27 def __init__(self, direction=DirectionDown, duration=300, parent=None):
28 """ 35 """
29 Constructor 36 Constructor
30 37
31 @param direction direction of the animation 38 @param direction direction of the animation
32 @type int (one of DirectionDown or DirectionUp) 39 @type EricAnimationDirection
33 @param duration duration of the animation 40 @param duration duration of the animation
34 @type int 41 @type int
35 @param parent reference to the parent widget 42 @param parent reference to the parent widget
36 @type QWidget 43 @type QWidget
37 """ 44 """
67 return 74 return
68 75
69 shown = 0 76 shown = 0
70 hidden = 0 77 hidden = 0
71 78
72 if self.__direction == self.DirectionDown: 79 if self.__direction == EricAnimationDirection.Down:
73 shown = 0 80 shown = 0
74 hidden = -self.__widget.height() 81 hidden = -self.__widget.height()
75 82
76 self.__widget.move(QPoint(self.__widget.pos().x(), hidden)) 83 self.__widget.move(QPoint(self.__widget.pos().x(), hidden))
77 84

eric ide

mercurial