当前位置: 首页>>代码示例>>Python>>正文


Python QtCore.QBasicTimer类代码示例

本文整理汇总了Python中PyQt5.QtCore.QBasicTimer的典型用法代码示例。如果您正苦于以下问题:Python QBasicTimer类的具体用法?Python QBasicTimer怎么用?Python QBasicTimer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了QBasicTimer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: T_window

class T_window(QWidget):
    def __init__(self):
        super().__init__()
        self.tabs = QTabWidget()
        self.com = T_communication()
        self.pbar = QProgressBar()
        self.pbar.setFormat("Battery : %p%")
        self.grid = QGridLayout()

        self.setLayout(self.grid)
        self.grid.addWidget(self.pbar)
        self.grid.addWidget(self.tabs)

        self.dpi = T_dpi()
        self.com.getDpi(self.dpi)
        self.dpi.dataHasBeenSent()
        self.t = []
        for i in range(0, 4):
            self.t.append(T_tab(i, self.dpi, self.com))
            self.tabs.addTab(self.t[i], "Mode " + str(i + 1))

        self.data = T_data(self.pbar, self.tabs, self.dpi, self.com)
        for i in range(0, 4):
            self.t[i].sendButton.clicked.connect(self.data.sendDpi)
            self.t[i].resetButton.clicked.connect(self.com.resetDpi)
        self.timer = QBasicTimer()
        self.timer.start(100, self.data)
        self.tabs.currentChanged.connect(self.com.sendMode)
开发者ID:np,项目名称:MadCatz,代码行数:28,代码来源:configurator.py

示例2: __init__

 def __init__(self, parent):
     QBasicTimer.__init__(self)
     self.startTime = 0
     self.interval = 0
     self.is_started = False
     self.is_paused = False
     self.parent = parent
开发者ID:hristy93,项目名称:FallingRocks,代码行数:7,代码来源:timer.py

示例3: Marquee

class Marquee(QLabel):
    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.right_to_left_direction = True
        self.initUI()
        self.timer = QBasicTimer()
        self.timer.start(80, self)

    def initUI(self):
        self.setWindowFlags(Qt.FramelessWindowHint)
        self.setAttribute(Qt.WA_TranslucentBackground)
        self.setText("Hello World! ")
        self.setFont(QFont(None, 50, QFont.Bold))
        # make more irritating for the authenticity with <marquee> element
        self.setStyleSheet("QLabel {color: cyan; }")

    def timerEvent(self, event):
        i = 1 if self.right_to_left_direction else -1
        self.setText(self.text()[i:] + self.text()[:i])  # rotate

    def mouseReleaseEvent(self, event):  # change direction on mouse release
        self.right_to_left_direction = not self.right_to_left_direction

    def keyPressEvent(self, event):  # exit on Esc
        if event.key() == Qt.Key_Escape:
            self.close()
开发者ID:acmeism,项目名称:RosettaCodeData,代码行数:26,代码来源:animation-1.py

示例4: WigglyLabel

class WigglyLabel(object):

    def __init__(self, clazz):
        self.clazz = clazz
        # clazz.setBackgroundRole(QPalette.Midlight)
        # clazz.setAutoFillBackground(True)

        setattr(clazz, "paintEvent", self.paintEvent)
        setattr(clazz, "timerEvent", self.timerEvent)

#         newFont = self.clazz.font()
#         newFont.setPointSize(newFont.pointSize() + 20)
#         self.clazz.setFont(newFont)

        self.timer = QBasicTimer()

        self.step = 0;
        self.timer.start(60, self.clazz)

    def __del__(self):
        self.timer.stop()

    def getText(self):
        return self.clazz.text()

    def paintEvent(self, event):
        # 上下跳动
        # sineTable = (0, 38, 71, 92, 100, 92, 71, 38, 0, -38, -71, -92, -100, -92, -71, -38)

        metrics = QFontMetrics(self.clazz.font())
        x = (self.clazz.width() - metrics.width(self.getText())) / 2
        y = (self.clazz.height() + metrics.ascent() - metrics.descent()) / 2
        color = QColor()

        painter = QPainter(self.clazz)

        for i, ch in enumerate(self.getText()):
            index = (self.step + i) % 16
            color.setHsv((15 - index) * 16, 255, 191)
            painter.setPen(color)
            # 上下跳动
            # painter.drawText(x, y - ((sineTable[index] * metrics.height()) / 400), ch)
            painter.drawText(x, y , ch)
            x += metrics.width(ch)

    def timerEvent(self, event):
        if event.timerId() == self.timer.timerId():
            self.step += 1
            self.clazz.update()
        else:
            super(WigglyLabel, self).timerEvent(event)
开发者ID:892768447,项目名称:BlogClient,代码行数:51,代码来源:wiggly.py

示例5: init_timers

    def init_timers(self):
        """Initializes the timers in the game."""
        self.game_timer = QBasicTimer()
        self.rock_timer = QBasicTimer()
        self.level_timer = QBasicTimer()
        self.powerup_timer = QBasicTimer()
        self.ticker_timer = QBasicTimer()
        self.bullet_timer = QBasicTimer()

        self.player_invincibility_timer = QBasicTimer()
        self.big_bomb_timer = QBasicTimer()
        self.slow_down_rocks_timer = QBasicTimer()
        self.shoot_rocks_timer = QBasicTimer()

        self.powerup_duration_timer = QTimer()
开发者ID:hristy93,项目名称:FallingRocks,代码行数:15,代码来源:user_interface.py

示例6: setupWidget

class setupWidget(QWidget):

	def __init__(self,parent_):
		super(setupWidget,self).__init__(parent_)
		self.parent_=parent_
		self.initUI()

	def initUI(self):
		self.pbar = QProgressBar(self)
		self.pbar.setObjectName('pbar')
		self.pbar.setTextVisible(True)
		self.pbar.setFormat('Configuring...')

		self.timer = QBasicTimer()
		self.step = 0

		pixmap=QPixmap(':/Assets/moodly.gif')
		lbl=QLabel(self)
		lbl.setPixmap(pixmap)

		hbox1=QHBoxLayout()
		hbox1.addStretch(1)
		hbox1.addWidget(lbl)
		hbox1.addStretch(1)

		hbox2=QHBoxLayout()
		hbox2.addStretch(1)
		hbox2.addWidget(self.pbar)
		hbox2.addStretch(1)

		vbox=QVBoxLayout()
		vbox.addStretch(8)
		vbox.addLayout(hbox1)
		vbox.addStretch(1)
		vbox.addLayout(hbox2)
		vbox.addStretch(8)

		self.setLayout(vbox)
		self.callTimer()

	def timerEvent(self,e):
		if self.step>=100:
			self.step=0
		self.step=self.step+1
		self.pbar.setValue(self.step)

	def callTimer(self):
		 self.timer.start(100, self)
开发者ID:AkshayAgarwal007,项目名称:Moodly,代码行数:48,代码来源:view.py

示例7: initUI

	def initUI(self):
		self.pbar = QProgressBar(self)
		self.pbar.setObjectName('pbar')
		self.pbar.setTextVisible(True)
		self.pbar.setFormat('Configuring...')

		self.timer = QBasicTimer()
		self.step = 0

		pixmap=QPixmap(':/Assets/moodly.gif')
		lbl=QLabel(self)
		lbl.setPixmap(pixmap)

		hbox1=QHBoxLayout()
		hbox1.addStretch(1)
		hbox1.addWidget(lbl)
		hbox1.addStretch(1)

		hbox2=QHBoxLayout()
		hbox2.addStretch(1)
		hbox2.addWidget(self.pbar)
		hbox2.addStretch(1)

		vbox=QVBoxLayout()
		vbox.addStretch(8)
		vbox.addLayout(hbox1)
		vbox.addStretch(1)
		vbox.addLayout(hbox2)
		vbox.addStretch(8)

		self.setLayout(vbox)
		self.callTimer()
开发者ID:AkshayAgarwal007,项目名称:Moodly,代码行数:32,代码来源:view.py

示例8: initUI

    def initUI(self):
        self.gridSize = 22
        self.speed = 10

        self.timer = QBasicTimer()
        self.setFocusPolicy(Qt.StrongFocus)

        hLayout = QHBoxLayout()
        self.tboard = Board(self, self.gridSize)
        hLayout.addWidget(self.tboard)

        self.sidePanel = SidePanel(self, self.gridSize)
        hLayout.addWidget(self.sidePanel)

        self.statusbar = self.statusBar()
        self.tboard.msg2Statusbar[str].connect(self.statusbar.showMessage)

        self.start()

        self.center()
        self.setWindowTitle('Tetris')
        self.show()

        self.setFixedSize(self.tboard.width() + self.sidePanel.width(),
                          self.sidePanel.height() + self.statusbar.height())
开发者ID:EleVenPerfect,项目名称:OTHERS,代码行数:25,代码来源:tetris_game.py

示例9: __init__

    def __init__(self, parent = None):
        super(TetrixBoard, self).__init__(parent)
        self.setStyleSheet("background-color:black;border:2px solid darkGreen;")

        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.setFrameStyle(QFrame.Box)
        self.setFocusPolicy(Qt.StrongFocus)
        self.isStarted = False
        self.isPaused = False
        self.clearBoard()

        self.nextPiece.setRandomShape()
开发者ID:hgoldfish,项目名称:quickpanel,代码行数:25,代码来源:tetrix.py

示例10: init_ui

 def init_ui(self, board_size, game_mode, game_difficulty_level,
             game_time_for_move):
     self.game = Game(board_size, mode=game_mode,
                      difficulty_level=game_difficulty_level,
                      is_console_game=False,
                      time_for_move=game_time_for_move)
     self.game_was_saved = False
     self.time_for_move = game_time_for_move
     self.count = self.time_for_move
     self.timer = QBasicTimer()
     self.move_timer = QTimer()
     self.ai_thread = AIThread(self)
     self.ai_thread.finished.connect(self.ai_finish)
     self.ai_finished = True
     self.load_images()
     self.add_toolbar()
     self.font_size = 10
     self.resize(board_size * s.IMG_SIZE,
                 (board_size * s.IMG_SIZE + self.toolbar.height() + 10 +
                  self.font_size))
     self.center()
     self.setWindowTitle('Reversi')
     self.show()
     self.timer.start(1, self)
     self.move_timer.timeout.connect(self.count_down)
     self.move_timer.start(1000)
开发者ID:ElenaArslanova,项目名称:rev,代码行数:26,代码来源:reversi.py

示例11: __init__

 def __init__(self):
     super().__init__()
     self.speed = 100  #重绘速度1s
     self.WindowSize = 50
     self.timer = QBasicTimer()
     self.sim = sm.Stimulator(self.WindowSize)
     self.initUI()
开发者ID:zwdnet,项目名称:liquid,代码行数:7,代码来源:MainWindow.py

示例12: __init__

    def __init__(self, parent):

        super().__init__(parent)
        self.parent = parent
        # self.initBoard()

        self.loadPixmaps()
        self.use_this_pixmap = self.nurse_pixmap

        # setting logical value for information about animation state
        self.isStopped = False
        self.isActive = False

        self.symptoms = []

        # creating empty list of points of size board_width x board_height
        self.board = [
            [
                ''
                for x in range(self.board_width)
            ]
            for y in range(self.board_height)
        ]

        # creating list of static map objects
        # PIXMAPs are declared in function self.loadPixmaps()

        self.objects = {
            Object("curtain1",  (0, 0),     (80, 160),  7),
            Object("bed1",      (80, 0),    (80, 160),  4),
            Object("curtain2",  (240, 0),   (80, 160),  7),
            Object("bed2",      (320, 0),   (80, 160),  4),
            Object("curtain3",  (480, 0),   (80, 160),  7),
            Object("bed3",      (560, 0),   (80, 160),  5),
            # Object("table_top", (640, 240), (80, 80),   8, 90),
            Object("table",     (640, 400), (80, 80),   9, 90),
            Object("curtain4",  (0, 240),   (160, 80),  7, 90),
            Object("bed4",      (0, 320),   (160, 80),  6, 270),
            Object("curtain5",  (0, 480),   (160, 80),  7, 90),
            # Object
        }

        for obj in self.objects:
            if obj.getName() == 'bed3' or obj.getName() == 'bed4':
                obj.changePixmap(4)

        """
        Creating graph to get paths
        """
        self.graph = GridWithWeights(self.graph_width,
                                     self.graph_height)
        self.graph.setWalls(*self.objects)
        self.path = []

        # drawing static objects on map
        # self.fillBoard(80, 0, 40, 80, 'bed')

        # creating timer
        self.timer = QBasicTimer()
开发者ID:wieloranski,项目名称:experiNurse,代码行数:59,代码来源:board.py

示例13: __init__

 def __init__(self, *args, **kwargs):
     '''
     Class representing OpenGL widget in the VisualizationWindow.
     '''
     super(OpenGLWidget, self).__init__(*args, **kwargs)
     self._room = self.parent().room   # assign room geometry to a variable
     self.setGeometry(self.parent()._width * .25, 0, self.parent()._width, self.parent()._height)   # window size/pos
     self._timer = QBasicTimer()   # create a timer
开发者ID:Nhor,项目名称:4d-ray-tracing-method,代码行数:8,代码来源:opengl_widget.py

示例14: start

 def start(self):
     self.show()
     self.setFocusPolicy(Qt.StrongFocus)
     self.timer = QBasicTimer()
     self.timer.start(150, self)
     if isinstance(self.game.first_player, Computer) \
         and isinstance(self.game.second_player, Computer):
         self.computers_play()
开发者ID:tvetan,项目名称:Reversi,代码行数:8,代码来源:board_ui.py

示例15: Example

class Example(QWidget):
    def __init__(self):
        super().__init__()
        self.initUI()
 
    def initUI(self):
        self.progress_bar = QProgressBar(self)
        self.progress_bar.setGeometry(30, 40, 200, 25)
 
        self.btn = QPushButton('Start', self)
        self.btn.move(30, 80)
        self.btn.clicked.connect(self.doAction)
 
        self.timer = QBasicTimer()
        self.step = 0
 
        self.setGeometry(300, 300, 280, 170)
        self.setWindowTitle('QProgressBar')
        self.show()
 
    def timerEvent(self, QTimerEvent):
        if self.step >= 100:
            self.timer.stop()
            self.btn.setText('Finished')
            return
        self.step += 1
        self.progress_bar.setValue(self.step)
 
    def doAction(self):
        if self.timer.isActive():
            self.timer.stop()
            self.btn.setText('Start')
        else:
            self.timer.start(100, self)
            self.btn.setText('Stop')
开发者ID:blackPantherOS,项目名称:playground,代码行数:35,代码来源:progress.py


注:本文中的PyQt5.QtCore.QBasicTimer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。