eric6/E5Gui/E5TabWidget.py

changeset 7514
0960c7c1f497
parent 7360
9190402e4505
child 7759
51aa6c6b66f7
equal deleted inserted replaced
7513:d8354f4d3dc7 7514:0960c7c1f497
6 """ 6 """
7 Module implementing a TabWidget class substituting QTabWidget. 7 Module implementing a TabWidget class substituting QTabWidget.
8 """ 8 """
9 9
10 10
11 from PyQt5.QtCore import Qt, QPoint, QMimeData, QByteArray, pyqtSignal 11 from PyQt5.QtCore import pyqtSignal, Qt, QPoint, QMimeData
12 from PyQt5.QtGui import QDrag, QMovie 12 from PyQt5.QtGui import QDrag
13 from PyQt5.QtWidgets import QTabWidget, QTabBar, QApplication, QStyle, QLabel 13 from PyQt5.QtWidgets import QTabWidget, QTabBar, QApplication, QStyle
14
15 from E5Gui.E5AnimatedLabel import E5AnimatedLabel
14 16
15 17
16 class E5WheelTabBar(QTabBar): 18 class E5WheelTabBar(QTabBar):
17 """ 19 """
18 Class implementing a tab bar class substituting QTabBar to support wheel 20 Class implementing a tab bar class substituting QTabBar to support wheel
309 side = QTabBar.RightSide 311 side = QTabBar.RightSide
310 else: 312 else:
311 side = QTabBar.LeftSide 313 side = QTabBar.LeftSide
312 return side 314 return side
313 315
314 def animationLabel(self, index, animationFile, speed=100): 316 def animationLabel(self, index, animationFile, interval=100):
315 """ 317 """
316 Public slot to set an animated icon. 318 Public slot to set an animated icon.
317 319
318 @param index tab index (integer) 320 @param index tab index
319 @param animationFile name of the file containing the animation (string) 321 @type int
320 @param speed animation speed of the icon in percent of the original 322 @param animationFile name of the file containing the animation
321 icon's speed (integer) 323 @type str
322 @return reference to the created label (QLabel) 324 @param interval interval in milliseconds between animation frames
325 @type int
326 @return reference to the created label
327 @rtype E5AnimatedLabel
323 """ 328 """
324 if index == -1: 329 if index == -1:
325 return None 330 return None
326 331
327 if hasattr(self.__tabBar, 'setTabButton'): 332 if hasattr(self.__tabBar, 'setTabButton'):
328 side = self.__freeSide() 333 side = self.__freeSide()
329 animation = QLabel(self) 334 animation = E5AnimatedLabel(
330 if animationFile and not animation.movie(): 335 self, animationFile=animationFile, interval=interval)
331 movie = QMovie(animationFile, QByteArray(), animation)
332 movie.setSpeed(speed)
333 animation.setMovie(movie)
334 movie.start()
335 self.__tabBar.setTabButton(index, side, None) 336 self.__tabBar.setTabButton(index, side, None)
336 self.__tabBar.setTabButton(index, side, animation) 337 self.__tabBar.setTabButton(index, side, animation)
338 animation.start()
337 return animation 339 return animation
338 else: 340 else:
339 return None 341 return None
340 342
341 def resetAnimation(self, index): 343 def resetAnimation(self, index):
349 351
350 if hasattr(self.__tabBar, 'tabButton'): 352 if hasattr(self.__tabBar, 'tabButton'):
351 side = self.__freeSide() 353 side = self.__freeSide()
352 animation = self.__tabBar.tabButton(index, side) 354 animation = self.__tabBar.tabButton(index, side)
353 if animation is not None: 355 if animation is not None:
354 animation.movie().stop() 356 animation.stop()
355 self.__tabBar.setTabButton(index, side, None) 357 self.__tabBar.setTabButton(index, side, None)
356 del animation 358 del animation

eric ide

mercurial