
| Current Path : /home/ift/52_procpy/dataninja/test/ |
Linux ift1.ift-informatik.de 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 |
| Current File : //home/ift/52_procpy/dataninja/test/qt.py |
# coding: utf8
import os,re,sys
import procpy
import procpy.procapp
import procpy.block
import sqlite3
from PyQt5.QtWidgets import QApplication, QWidget, QProgressBar, QPushButton
from PyQt5.QtCore import QBasicTimer
class Example(QWidget):
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
self.pbar = QProgressBar(self)
self.pbar.setGeometry(30, 40, 200, 25)
self.btn_start = QPushButton('Start', self)
self.btn_start.move(40, 100)
self.btn_start.clicked.connect(self.doStartAction)
self.btn_stop = QPushButton('Stop', self)
self.btn_stop.move(40, 120)
self.btn_stop.clicked.connect(self.doStopAction)
self.btn_new = QPushButton('New', self)
self.btn_new.move(40, 140)
self.btn_new.clicked.connect(self.doNewAction)
self.timer = QBasicTimer()
self.step = 0
self.setGeometry(300, 300, 800, 600)
self.setWindowTitle('Demo for Button and Progress bar')
self.show()
def timerEvent(self, e):
if self.step >= 100:
self.timer.stop()
self.btn_start.setText('Completion')
return
self.step = self.step + 1
self.pbar.setValue(self.step)
def doStartAction(self, value):
if self.timer.isActive():
self.timer.stop()
self.btn_start.setText('Start')
else:
self.timer.start(100, self)
self.btn_start.setText('Stop')
def doStopAction(self, value):
if self.timer.isActive():
self.timer.stop()
self.btn_stop.setText('Stop')
else:
self.timer.start(100, self)
self.btn_start.setText('Start')
def doStopAction(self, value):
if self.timer.isActive():
self.timer.stop()
self.btn_stop.setText('Stop')
else:
self.timer.start(100, self)
self.btn_start.setText('Start')
def doNewAction(self, value):
if self.timer.isActive():
self.timer.stop()
self.btn_new.setText('Stop')
else:
self.timer.start(100, self)
self.btn_new.setText('Start')
if __name__ == '__main__':
app = QApplication(sys.argv)
ex = Example()
sys.exit(app.exec_())