user1978826
user1978826

Reputation: 203

PyQT4/Python33 issues

I have installed PyQt 4 for use with Python33 on my windows 7 machine, I followed the instructions on riverbank and everything seems to have be done correctly, however, I tried a simple example to create a basic found online, which compiled but doesnt display any GUI. any ideas?

import sys
from PyQt4 import QtGui

def main():

    app = QtGui.QApplication(sys.argv)

    w = QtGui.QWidget()
    w.resize(250, 150)
    w.move(300, 300)
    w.setWindowTitle('Hello')
    w.show()

    sys.exit(app.exec_())

Thanks

Upvotes: 0

Views: 101

Answers (1)

Bakuriu
Bakuriu

Reputation: 102029

You simply defined a function. You must also call it to see the widget:

I have installed PyQt 4 for use with Python33 on my windows 7 machine, I followed the instructions on riverbank and everything seems to have be done correctly, however, I tried a simple example to create a basic found online, which compiled but doesnt display any GUI. any ideas?

import sys
from PyQt4 import QtGui

def main():

    app = QtGui.QApplication(sys.argv)

    w = QtGui.QWidget()
    w.resize(250, 150)
    w.move(300, 300)
    w.setWindowTitle('Hello')
    w.show()

    sys.exit(app.exec_())


if __name__ == '__main__':  #avoids execution when imported.
    main()

Launching the program with $python the-program.py should show the window.

Upvotes: 1

Related Questions