Last active
August 29, 2015 14:21
-
-
Save bessey/3c3774650c0451993a4b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PyQt4 import QtGui | |
from PyQt4 import QtCore | |
from PyQt4.QtCore import pyqtSlot,SIGNAL,SLOT | |
import sys | |
# They're defining a class that extends LCD, so they can create | |
class myLCDNumber(QtGui.QLCDNumber): # a function to allow the LCD to change itself | |
value = 60 | |
@pyqtSlot() # I don't think you need to worry about this line | |
def count(self): # Here's the important bit, defining a method that changes the LCD's value on execution | |
self.display(self.value) | |
self.value = self.value-1 | |
def main(): | |
app = QtGui.QApplication(sys.argv) | |
lcdNumber = myLCDNumber() # Note they create an instance of THEIR LCD, not the QT one | |
#Resize width and height | |
lcdNumber.resize(250,250) | |
lcdNumber.setWindowTitle('PyQt QLcdNumber Countdown Example') | |
timer = QtCore.QTimer() | |
# So I have no idea WHY but the API appears to be (in arg order | |
# 1. the function to sync to | |
# 2. the signal that function will send that triggers the sync | |
# 3 the object that we will call a method of when we sync | |
# 4. some weird syntax for the method we will call on that object | |
# So your code is failing because your LCD class has no count() function! | |
# You need to do the same as them, create a class that extends LCD and adds a function named count() (or rename it) | |
lcdNumber.connect(timer,SIGNAL("timeout()"),lcdNumber,SLOT("count()")) | |
timer.start(1000) | |
lcdNumber.show() | |
sys.exit(app.exec_()) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment