PyQt Tutorial
PyQt Useful Resources
Selected Reading
- PyQt - QPixmap Class
- PyQt - QClipboard
- PyQt - BrushStyle Constants
- PyQt - Drawing API
- PyQt - Database Handling
- PyQt - Drag and Drop
- PyQt - Multiple Document Interface
- PyQt - QMessageBox
- PyQt - QDialog Class
- PyQt - Basic Widgets
- PyQt - Layout Management
- PyQt - Signals and Slots
- PyQt - Using Qt Designer
- PyQt - Major Classes
- PyQt - Hello World
- PyQt - Introduction
- PyQt - Home
PyQt Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
PyQt - Hello World
PyQt - Hello World
Creating a simple GUI apppcation using PyQt involves the following steps −
Import QtGui module.
Create an apppcation object.
A QWidget object creates top level window. Add QLabel object in it.
Set the caption of label as “hello world”.
Define the size and position of window by setGeometry() method.
Enter the mainloop of apppcation by app.exec_() method.
import sys from PyQt4 import QtGui def window(): app = QtGui.QApppcation(sys.argv) w = QtGui.QWidget() b = QtGui.QLabel(w) b.setText("Hello World!") w.setGeometry(100,100,200,50) b.move(50,20) w.setWindowTitle(“PyQt”) w.show() sys.exit(app.exec_()) if __name__ == __main__ : window()
The above code produces the following output −
Advertisements