-
Notifications
You must be signed in to change notification settings - Fork 2
/
DlgWaiting.py
71 lines (57 loc) · 2.25 KB
/
DlgWaiting.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# -*- coding: utf-8 -*-
"""
/***************************************************************************
Name : Omero RT
Description : Omero plugin
Date : October 21, 2011
copyright : (C) 2011 by Giuseppe Sucameli (Faunalia)
email : [email protected]
***************************************************************************/
Omero plugin
Works done from Faunalia (http://www.faunalia.it) with funding from Regione
Toscana - S.I.T.A. (http://www.regione.toscana.it/territorio/cartografia/index.html)
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
"""
from PyQt4.QtCore import *
from PyQt4.QtGui import *
class DlgWaiting(QDialog):
def __init__(self, parent=None):
QDialog.__init__(self, parent)
self.finished = False
self.setupUi()
def setupUi(self):
self.setWindowTitle( self.tr( "Attendi..." ) )
self.setLayout( QVBoxLayout() )
self.progress = QProgressBar(self)
self.layout().addWidget( self.progress )
self.resize(300, self.sizeHint().height())
def reset(self):
self.progress.reset()
self.onProgress(0)
def setRange(self, minimum, maximum):
self.progress.setRange(minimum, maximum)
self.reset()
def onProgress(self, n=None):
if n == None:
self.progress.setValue( self.progress.value()+1 )
elif n < 0:
self.progress.setValue( self.progress.maximum() )
else:
self.progress.setValue(n)
self.update()
QCoreApplication.processEvents( QEventLoop.ExcludeUserInputEvents )
def closeEvent(self, event):
event.ignore() if not self.finished else event.accept()
def exec_(self):
QTimer.singleShot(500, self.run)
return QDialog.exec_(self)
def run(self):
self.finished = True
self.done(ret)