E5Gui/E5ProgressDialog.py

branch
Py2 comp.
changeset 3080
6c0a430b19df
parent 3071
83d066710d60
child 3088
7f1e291875d9
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/E5Gui/E5ProgressDialog.py	Sat Nov 16 10:06:28 2013 +0100
@@ -0,0 +1,59 @@
+# -*- coding: utf-8 -*-
+
+# Copyright (c) 2013 Detlev Offenbach <detlev@die-offenbachs.de>
+#
+
+"""
+Module implementing a progress dialog allowing a customized progress bar label.
+"""
+
+from __future__ import unicode_literals    # __IGNORE_WARNING__
+
+from PyQt4.QtCore import Qt
+from PyQt4.QtGui import QProgressBar, QProgressDialog
+
+
+class E5ProgressDialog(QProgressDialog):
+    """
+    Class implementing a progress dialog allowing a customized progress bar
+    label.
+    """
+    def __init__(self, labelText, cancelButtonText, minimum, maximum,
+                 format=None, parent=None, flags=Qt.WindowFlags()):
+        """
+        Constructor
+        
+        @param labelText text of the dialog label (string)
+        @param cancelButtonText text of the cancel button (string)
+        @param minimum minimum value (integer)
+        @param maximum maximum value (integer)
+        @keyparam format label format of the progress bar (string)
+        @keyparam parent reference to the parent widget (QWidget)
+        @keyparam flags window flags of the dialog (Qt.WindowFlags)
+        """
+        super(E5ProgressDialog, self).__init__(labelText, cancelButtonText, minimum, maximum,
+                         parent, flags)
+        
+        self.__progressBar = QProgressBar(self)
+        self.__progressBar.setMinimum(minimum)
+        self.__progressBar.setMaximum(maximum)
+        if format:
+            self.__progressBar.setFormat(format)
+        
+        self.setBar(self.__progressBar)
+    
+    def format(self):
+        """
+        Public method to get the progress bar format.
+        
+        @return progress bar format (string)
+        """
+        return self.__progressBar.format()
+    
+    def setFormat(self, format):
+        """
+        Public method to set the progress bar format.
+        
+        @param format progress bar format (string)
+        """
+        self.__progressBar.setFormat(format)

eric ide

mercurial