1 # -*- coding: utf-8 -*-
3 # (c) Copyright 2003-2007 Hewlett-Packard Development Company, L.P.
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 from waitform_base import WaitForm_base
26 class WaitForm(WaitForm_base):
27 def __init__(self, seconds, message=None, cancel_func=None, parent=None, name=None, modal=0, fl=0):
28 WaitForm_base.__init__(self,parent,name,modal,fl)
30 self.wait_timer = QTimer(self, "WaitTimer")
31 self.connect(self.wait_timer, SIGNAL('timeout()'), self.wait_timer_timeout)
32 self.seconds = seconds
34 self.ProgressBar.setTotalSteps(seconds)
37 self.wait_timer.start(10)
39 self.wait_timer.start(seconds*1000)
41 if message is not None:
42 self.setMessage(message)
44 self.cancelPushButton.setEnabled(cancel_func is not None)
45 self.cancel_func = cancel_func
48 def wait_timer_timeout(self):
50 self.ProgressBar.setProgress(self.progress)
52 if self.progress == self.seconds:
53 self.wait_timer.stop()
56 def setMessage(self, message):
57 self.textLabel3.setText(message)
60 def cancelPushButton_clicked(self):
62 if self.cancel_func is not None:
64 self.cancelPushButton.setEnabled(False)