View Single Post
Posts: 13 | Thanked: 2 times | Joined on Nov 2009 @ Stockholm
#12
My "Pimped" version of the Hello World with the QLabel moving with help of timer events.
In the Qt Designer I named the QLabel to "SplashLabel" and put it at the coordinates x=100,y=100.

Another tip: I used DropN900 to pick up my files from Dropbox (http://www.dropbox.com/referrals/NTE3ODY3Njk) instead of SSH-Server...

Now I'm waiting for a bluetooth dongle to connect to my car's databus (eobd alá carman) and play further....

I hope someone could find something from the code below!

/Claes

Code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from sys import argv, exit

from PyQt4 import QtCore, QtGui

from qt4_designer_output_python_file import Ui_MainWindow

class main_win(QtGui.QMainWindow):
    def __init__(self, *args, **kw):
        super(main_win, self).__init__(*args, **kw)
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        self.ctimer = QtCore.QTimer()
        QtCore.QObject.connect(self.ctimer, QtCore.SIGNAL("timeout()"), \
                               self.constantUpdate)
        self.ctimer.start(25)
        self.move_count = 0

    def constantUpdate(self):
        splash = self.ui.SplashLabel
        if self.move_count < 200:
            self.move_count += 1
            splash.move(splash.x() + 1, splash.y() + 1)
        else:
            self.ctimer.stop()
            splash.hide()

if __name__ == "__main__":
    app = QtGui.QApplication(argv)
    myapp = main_win()
    myapp.show()
    exit(app.exec_())

Last edited by clob; 2010-09-21 at 22:18.