I
I
ibr_982017-08-13 00:35:28
Python
ibr_98, 2017-08-13 00:35:28

How to properly use a timer in PyQt?

Hello!
why is this code not working???? How do I ************** with this pyqt .......................

from PyQt5.QtCore import QTimer
from PyQt5.QtWidgets import*
import sys
app = QApplication(sys.argv)

def tick():
  print('Hello World')

timer = QTimer()
timer.timeout.connect(tick)
timer.start(1000)
timer.stop()


sys.exit(app.exec())

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey6661313, 2018-04-01
@Sergey6661313

Your code does exactly what you wrote.
timer.start(1000) - starts the timer
timer.stop() - stops the timer. What does it have to do with it in our case even before the actual start of the timer. app.exec() hasn't even started yet.
What actions do you expect from him if you stopped him???

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question