File: waitform.py

package info (click to toggle)
hplip 1.6.10-3etch1
  • links: PTS
  • area: main
  • in suites: etch
  • size: 35,140 kB
  • ctags: 10,985
  • sloc: ansic: 48,004; cpp: 40,938; python: 29,973; xml: 14,675; sh: 9,841; perl: 4,257; makefile: 786
file content (47 lines) | stat: -rw-r--r-- 1,380 bytes parent folder | download | duplicates (2)
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
# -*- coding: utf-8 -*-

import sys
from qt import *
from waitform_base import WaitForm_base

class WaitForm(WaitForm_base):
    def __init__(self, seconds, message=None, cancel_func=None, parent=None, name=None, modal=0, fl=0):
        WaitForm_base.__init__(self,parent,name,modal,fl)

        self.wait_timer = QTimer(self, "WaitTimer")
        self.connect(self.wait_timer, SIGNAL('timeout()'), self.wait_timer_timeout)
        self.seconds = seconds
        self.progress = 0
        self.ProgressBar.setTotalSteps(seconds)

        if seconds == 0:
            self.wait_timer.start(10)
        else:
            self.wait_timer.start(1000)

        if message is not None:
            self.setMessage(message)
            
        self.cancelPushButton.setEnabled(cancel_func is not None)
        self.cancel_func = cancel_func
        self.canceled = False

    def wait_timer_timeout(self):
        self.progress += 1
        self.ProgressBar.setProgress(self.progress)

        if self.progress == self.seconds:
            self.wait_timer.stop()
            self.close()

            
    def setMessage(self, message):
        self.textLabel3.setText(message)

        
    def cancelPushButton_clicked(self):
        self.canceled = True
        if self.cancel_func is not None:
            self.cancel_func()
        self.cancelPushButton.setEnabled(False)