[PyQt] pyqt book and first example

FarSight Data Systems msh at farsight-data.com
Tue Apr 8 23:09:05 BST 2008


I'm trying to go through the book and the first example is not working 
properly.

I've installed pyqt4 via adept on my Kubuntu Feisty Fawn laptop.

The first example in the qt section of the books is as follows:

code follows -------------------------------------

#!/usr/bin/env python

import sys
import time
from PyQt4.QtCore import *
from PyQt4.QtGui import *

app = QApplication(sys.argv)

try:
        due = QTime.currentTime()
        message = "Alert!"
        
        if len(sys.argv) < 2:
                raise ValueError
        hours, mins = sys.argv[1].split(":")
        due = QTime(int(hours), int(mins))
        print due
        if not due.isValid():
                print "due is not valid"
                raise ValueError
        else:
                print "due is valid"
        
        if len(sys.argv) > 2:
                message = " ".join(sys.argv[2:])
except ValueError:
        message = "Usage: alert.pyw HH:MM [optional message]" # 24hr clock
                
code ended -------------------------------------

I've added a couple of print lines to get the values of some variable to see 
what they are.  The one that strikes me the most is due, the value returned 
from that isn't time.  It's

<PyQt4.QtCore.QTime object at 0xb7d13e6c>

Can anyone explain the problem I'm having here?

Thanks

Mark



More information about the PyQt mailing list