Python PyQt6 Notes
Python PyQt6 Notes
IMPORTANT THINGS TO DO
Create window then widgets
To make more than one widget(all the time) make one large widget that stores the
layout and then display is at "setCentralWidget"
The order of when widgets are made influences their position on the layout
IMPORTS:
Read Images -> icons
from PyQt6.QtGui import QIcon
Creates Widgets
from PyQt6.QtGui import QLabel
Align Text or Grid Layouts:
from PyQt6.QtCore import Qt
Read Images to widgets:
from PyQt6.QtGui import QPixmap
Push Buttons:
from PyQt6.QtWidgets import QPushButton
VBoxLayout(the exact same for Hboxlayout):
from PyQt6.QtWidgets import QVBoxLayout
More complex widgets:
from PyQt6.QtWidgets import QWidget
QGridLayout:
from PyQt6.QtWidgets import QGridLayout
QLineEdit lets you make a text entry box:
from PyQt6.QtWidgets import QLineEdit
Drop down boxes:
from PyQt6.QtWidgets import QComboBox
Spin Boxes:
from PyQt6.QtWidgets import QSpinBox
Double Spinboxes:
from PyQt6.QtWidgets import QDoubleSpinBox
Add a Radio Button (Multip choice):
fomr PyQt6.QtWidgets import QRadioButton
Makes it easier to work with buttons especially Radio:
from PyQt6.QtWidgets import QButtonGroup
Pop up message:
from PyQt6.QtWidgets import QMessageBox
Msg that can have an imput:
from PyQt6.QtWidgets import QInputBox
Color Picker msgbox:
from PyQt6.QtWidgets import QColorDialog
Font Picker:
from PyQt6.QtWidgets import QFontDialog
Design Process:
Make Imports
Set Up Window
Set Layout
Add Widgets
The window will not show untill these commands are put in:
window.show()
app.exec()
Maximized Window:
window.showMaximized()
Minimized Window:
window.showminimized()
Set icons:
window.setWindowIcon(QIcon("PlaceHolderAppIcon.png"))
Create a widget:
label = QLabel("Text Goes Here")
Alight a Widget:
label = QLabel("Text Goes Here", alignment=Qt.AlignmentFlag.Align_______)
Create a class:
class Window(QMainWindow):
Create a inputbox:
msg = QInputDialog()