Package Camelot :: Package camelot :: Package view :: Package controls :: Module progress_dialog |
[frames] | no frames]

# Source Code for Module Camelot.camelot.view.controls.progress_dialog

     1  #  ============================================================================
     2  #
     3  #  Copyright (C) 2007-2008 Conceptive Engineering bvba. All rights reserved.
     4  #  www.conceptive.be / project-camelot@conceptive.be
     5  #
     6  #  This file is part of the Camelot Library.
     7  #
     8  #  This file may be used under the terms of the GNU General Public
     9  #  License version 2.0 as published by the Free Software Foundation
    10  #  and appearing in the file LICENSE.GPL included in the packaging of
    11  #  this file.  Please review the following information to ensure GNU
    12  #  General Public Licensing requirements will be met:
    13  #  http://www.trolltech.com/products/qt/opensource.html
    14  #
    15  #  If you are unsure which license is appropriate for your use, please
    16  #  review the following information:
    17  #  http://www.trolltech.com/products/qt/licensing.html or contact
    18  #  project-camelot@conceptive.be.
    19  #
    20  #  This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
    21  #  WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
    22  #
    23  #  For use of this library in commercial applications, please contact
    24  #  project-camelot@conceptive.be
    25  #
    26  #  ============================================================================
    27
    28  """Functions and classes to use a progress dialog in combination with
    29  a model thread"""
    30
    31  from camelot.core.utils import ugettext as _
    32  from camelot.view.art import Icon
    33
    34  from PyQt4 import QtGui, QtCore
    35
    36 -class ProgressDialog(QtGui.QProgressDialog):
    37      """A Progress Dialog to be used in combination with a post to the model thread::
    38
    39      to display a progress dialog until my_function has finished :
    40
    41      d = ProgressDialog()
    42      post(my_function, p.finished, p.exception)
    43      d.exec_()
    44
    45      """
    46
    47 -    def __init__(self, name, icon=Icon('tango/32x32/actions/appointment-new.png')):
    48          QtGui.QProgressDialog.__init__( self, QtCore.QString(), QtCore.QString(), 0, 0 )
    49          label = QtGui.QLabel(unicode(name))
    50          #label.setPixmap(icon.getQPixmap())
    51          self.setLabel(label)
    52          self.setWindowTitle( _('Please wait') )
    53
    54 -    def finished(self, success):
    55          self.close()
    56
    57 -    def exception(self, exception_info):
    58          from camelot.view.controls.exception import model_thread_exception_message_box
    59          model_thread_exception_message_box(exception_info)
    60          self.finished(False)
    61