我们从Python开源项目中,提取了以下12个代码示例,用于说明如何使用PyQt5.QtCore.QBasicTimer()。
def __init__(self, parent=None): super(TetrixBoard, self).__init__(parent) self.timer = QBasicTimer() self.nextPieceLabel = None self.isWaitingAfterLine = False self.curPiece = TetrixPiece() self.nextPiece = TetrixPiece() self.curX = 0 self.curY = 0 self.numLinesRemoved = 0 self.numPiecesDropped = 0 self.score = 0 self.level = 0 self.board = None self.setFrameStyle(QFrame.Panel | QFrame.Sunken) self.setFocusPolicy(Qt.StrongFocus) self.isStarted = False self.isPaused = False self.clearBoard() self.nextPiece.setRandomShape()
def initUI(self): """ Description: A progress bar, a status message will be shown and a timer() method will be invoked as part of the authentication process. Arguments: None Returns: Nothing """ self.pbar = QProgressBar(self) self.pbar.setGeometry(30, 40, 200, 25) self.status = QLabel(self) self.status.setGeometry(30, 75, 200, 20) self.timer = QBasicTimer() self.step = 0 self.setGeometry(300, 300, 255, 100) self.center() self.setWindowTitle(_('loading')) self.show() self.timer.start(100, self)
def __init__(self): super().__init__() self.mySocket = socket.socket() self.params = {} self.responseThread = ResponseThread(self.mySocket) self.isPlaying = False self.setGeometry(300, 200, 280, 300) self.setWindowTitle('Kodi Remote Control') self.setWindowIcon(QIcon(ICON_PATH)) self.img = QLabel('img') self.img.setPixmap(QPixmap(IMG_PATH)) self.status = QLabel('OK') self.pbar = QProgressBar() self.progress = 0 self.timer = QBasicTimer() box = QVBoxLayout() box.addWidget(self.img) box.addWidget(self.status) box.addWidget(self.pbar) self.setLayout(box) self.show() self.setFixedSize(self.size()) self.responseThread.mySignal.connect(self.handleSignals) self.responseThread.start()
def __init__(self, parent=None): super(WigglyWidget, self).__init__(parent) self.setBackgroundRole(QPalette.Midlight) self.setAutoFillBackground(True) newFont = self.font() newFont.setPointSize(newFont.pointSize() + 20) self.setFont(newFont) self.timer = QBasicTimer() self.text = '' self.step = 0; self.timer.start(60, self)
def __init__(self): super().__init__() self.main = Ui_pro() self.main.setupUi(self) STATUS.UPDATE = self.main self.step = 0 self.finish = None self.timer = QBasicTimer() self.timer.start(100, self)
def __init__(self, camera_port=0, parent=None): super().__init__(parent) self.camera = cv2.VideoCapture(camera_port) self.timer = QtCore.QBasicTimer()
def timerEvent(self, e): """ Description: Called periodically as part of the QBasicTimer() object. Authentication will be handled within this method. Arguments: The event. Won't be used, though. Returns: Nothing, just exits when progress bar reaches 100% """ global conf err = QMessageBox() self.status.setText(_('authenticating')) if not conf.USERNAME: try: kvm = API(url=conf.CONFIG['ovirturl'], username=self.uname + '@' + conf.CONFIG['ovirtdomain'], password=self.pw, insecure=True, timeout=int(conf.CONFIG['conntimeout']), filter=True) conf.OVIRTCONN = kvm conf.USERNAME = self.uname conf.PASSWORD = self.pw self.status.setText(_('authenticated_and_storing')) self.step = 49 except ConnectionError as e: err.critical(self, _('apptitle') + ': ' + _('error'), _('ovirt_connection_error') + ': ' + sub('<[^<]+?>', '', str(e))) self.status.setText(_('error_while_authenticating')) self.step = 100 except RequestError as e: err.critical(self, _('apptitle') + ': ' + _('error'), _('ovirt_request_error') + ': ' + sub('<[^<]+?>', '', str(e))) self.status.setText(_('error_while_authenticating')) self.step = 100 if self.step >= 100: # Authenticacion process has concluded self.timer.stop() self.close() return elif self.step == 50: # Credentials were ok, we check whether we should store them for further uses if self.remember: self.status.setText(_('storing_credentials')) with os.fdopen(os.open(conf.USERCREDSFILE, os.O_WRONLY | os.O_CREAT, 0600), 'w') as handle: handle.write('[credentials]\nusername=%s\npassword=%s' % (self.uname, encode(self.pw, 'rot_13'))) handle.close() self.step = 99 else: self.status.setText(_('successfully_authenticated')) self.step = 99