|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2013 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing a progress dialog allowing a customized progress bar label. |
|
8 """ |
|
9 |
|
10 from PyQt4.QtCore import Qt |
|
11 from PyQt4.QtGui import QProgressBar, QProgressDialog |
|
12 |
|
13 |
|
14 class E5ProgressDialog(QProgressDialog): |
|
15 """ |
|
16 Class implementing a progress dialog allowing a customized progress bar |
|
17 label. |
|
18 """ |
|
19 def __init__(self, labelText, cancelButtonText, minimum, maximum, |
|
20 format=None, parent=None, flags=Qt.WindowFlags()): |
|
21 """ |
|
22 Constructor |
|
23 |
|
24 @param labelText text of the dialog label (string) |
|
25 @param cancelButtonText text of the cancel button (string) |
|
26 @param minimum minimum value (integer) |
|
27 @param maximum maximum value (integer) |
|
28 @keyparam format label format of the progress bar (string) |
|
29 @keyparam parent reference to the parent widget (QWidget) |
|
30 @keyparam flags window flags of the dialog (Qt.WindowFlags) |
|
31 """ |
|
32 super().__init__(labelText, cancelButtonText, minimum, maximum, |
|
33 parent, flags) |
|
34 |
|
35 self.__progressBar = QProgressBar(self) |
|
36 self.__progressBar.setMinimum(minimum) |
|
37 self.__progressBar.setMaximum(maximum) |
|
38 if format: |
|
39 self.__progressBar.setFormat(format) |
|
40 |
|
41 self.setBar(self.__progressBar) |
|
42 |
|
43 def format(self): |
|
44 """ |
|
45 Public method to get the progress bar format. |
|
46 |
|
47 @return progress bar format (string) |
|
48 """ |
|
49 return self.__progressBar.format() |
|
50 |
|
51 def setFormat(self, format): |
|
52 """ |
|
53 Public method to set the progress bar format. |
|
54 |
|
55 @param format progress bar format (string) |
|
56 """ |
|
57 self.__progressBar.setFormat(format) |