Hi, i've been working on simple code just prototyping the system i'd like to make. This all works and is going great apart from my "quit" button, the button appears. however when you click on it, it doesn't close the interface..i think it just stops the code from running or something.

Any idea where I might have gone wrong in my code?!
Thanks

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


class Form(QWidget):
    def __init__(self):

        QWidget.__init__(self)

        label = QLabel("Book or Amend a Badminton Court:\n\n")

        layout = QGridLayout()

        combo = QComboBox()
        combo.addItems(["Available","Booked"])
        layout.addWidget(QLabel("09:00: "),0,0)
        layout.addWidget(combo,0,1)

        button = QPushButton("Quit")
        layout.addWidget(QLabel(" "),1,0)
        layout.addWidget(button,1,1)

        self.setLayout(layout)


        self.connect(button, SIGNAL("clicked()"),app.quit)

        self.setWindowTitle("Badminton Court Booking")

app =  QApplication(sys.argv)
form = Form()
form.show()
app.exec_()

I am curious what operating system you have. I have been trying to install PyQt4 on my Windows Vista machine and it seems to fail.

I downloaded PyQt-Py2.5-gpl-4.4.2-1.exe which is the Windows binary installer. It is supposed to contain everything needed for PyQt development except for Python itself:

PyQt
Qt (with database support for SQLite3 and ODBC)
Qt Designer
Qt Linguist
Qt Assistant
pyuic4
pylupdate4
lrelease
pyrcc4
QScintilla

However after the installation I get the notorious:
"ImportError: No module named PyQt4"
even though there is a PyQT4 folder and a bin subfolder with all the needed dll files in my Python Lib folder.

A shame, because PyQT sounds like and interesting GUI toolkit. Let me know what you did to make it work on your computer. If I get it to go, I can help you too.

More details, I downloaded:
http://www.riverbankcomputing.co.uk/static/Downloads/PyQt4/PyQt-Py2.5-gpl-4.4.2-1.exe

Looks like Windows Vista screws you up. The above PyQt-Py2.5-gpl-4.4.2-1.exe installed perfectly fine on my Windows XP machine. I tested dangermini's pyqt code and it works without a hitch. Not quite sure why he has a problem?

I am curious what operating system you have. I have been trying to install PyQt4 on my Windows Vista machine and it seems to fail.

I downloaded PyQt-Py2.5-gpl-4.4.2-1.exe which is the Windows binary installer. It is supposed to contain everything needed for PyQt development except for Python itself:

PyQt
Qt (with database support for SQLite3 and ODBC)
Qt Designer
Qt Linguist
Qt Assistant
pyuic4
pylupdate4
lrelease
pyrcc4
QScintilla

However after the installation I get the notorious:
"ImportError: No module named PyQt4"
even though there is a PyQT4 folder and a bin subfolder with all the needed dll files in my Python Lib folder.

A shame, because PyQT sounds like and interesting GUI toolkit. Let me know what you did to make it work on your computer. If I get it to go, I can help you too.

More details, I downloaded:
http://www.riverbankcomputing.co.uk/static/Downloads/PyQt4/PyQt-Py2.5-gpl-4.4.2-1.exe

Don't ask me how I did it, but I got it to go on my Windows Vista machine. I started with the premise that the MS mindset is magnanimously screwed up. So here is the solution:
The PyQT installation works on Windows Vista if you add the file qt.conf found in C:\Python25 after the installation to (oh my God, what are those MS folks thinking?):
C:\Users\User_Name\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\PyQt GPL v4.4.2 for Python v2.5

You have to use your own User_Name!

Sorry for the late post. I just noticed this. Your button line should read
self.connect(button, SIGNAL("clicked()"), self, SLOT("close()"))
I'm thinking of doing a PyQt tutorial, or at least a list to links on using PyQt(4), thread on DaniWeb. Do you have any links that might be of interest?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.