Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
PyQt
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Hello World example== [[File:PyQt screen.png|frame|right|The result in [[Plasma 4|KDE Plasma 4]]]] The below code written for PyQt6 shows a small window on the screen. <syntaxhighlight lang="python3" line="1"> #!/usr/bin/env python3 """ Here we provide the necessary imports. The basic GUI widgets are located in QtWidgets module. """ import sys from PyQt6.QtWidgets import QApplication, QWidget # Every PyQt application must create an application object. # The application object is located in the QtWidgets module. app = QApplication([]) # The QWidget widget is the base class of all user interface objects in PyQt. # We provide the default constructor for QWidget. The default constructor has no parent. # A widget with no parent is called a window. root = QWidget() root.resize(320, 240) # The resize() method resizes the widget. root.setWindowTitle("Hello, World!") # Here we set the title for our window. root.show() # The show() method displays the widget on the screen. sys.exit(app.exec()) # Finally, we enter the mainloop of the application. </syntaxhighlight>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)