12/1/2024, sunday
Windows python q5 designer with pyCharm
11/30
..//
PyQt5 Tutorial - Setup and a Basic GUI Application
PyQt5 Tutorial - How to Use Qt Designer
https://www.youtube.com/watch?v=FVpho_UiDAY&list=PLzMcBGfZo4-lB8MZfHPLTEHO9zJDDLpYj&index=3
https://www.youtube.com/watch?v=Vde5SH8e1OQ&list=PLzMcBGfZo4-lB8MZfHPLTEHO9zJDDLpYj
../
Getting Started With PyQt5 (in Python) For Absolute Beginners
https://www.youtube.com/watch?v=tlhFIAymKnQ&list=PL3JVwFmb_BnRpvOeIh_To4YSiebiggyXS
../
Create An LCD Clock - PyQt5 GUI Thursdays #35
https://www.youtube.com/watch?v=CcnsV4qlBGQ
../
How to make a GUI using PyQt5 and Matplotlib to plot real-time data: PyQt5 tutorial - Part 10
https://www.youtube.com/watch?v=Ng00Mj5Tt8o
self.update_plot()
self.timer =QtCire.QTimer()
self.timer.setinterval(self.interval) #msec
self.timer.timeout.connect(self.update_plot)
self.timer.start()
from PyQt5.QtCore import QTimer
def update_label():
# This function will be called every 1000 milliseconds (1 second)
print("Timer triggered!")
timer = QTimer()
timer.timeout.connect(update_label)
timer.start(1000) # 1000 milliseconds = 1 second
1. Accessing UI Elements:
When you design a UI in Qt Designer, the generated Python code creates a class that represents your UI. Within this class, self allows you to access and manipulate the UI elements that you've added to your form.
Python
# Example from a Qt Designer-generated class
class MyWindow(QtWidgets.QMainWindow):
def __init__(self):
super().__init__()
uic.loadUi("my_ui.ui", self) # Load the UI file
# Access UI elements using self
self.pushButton.clicked.connect(self.on_button_click)
2. Defining Methods:
You'll often define methods within your class to handle events, perform calculations, or update the UI. These methods need to access the instance of the class, which is done using self.
Python
def on_button_click(self):
# Do something when the button is clicked
text = self.lineEdit.text()
self.label.setText(f"You entered: {text}")
3. Initializing the UI:
In the constructor (__init__) of your class, you'll typically use self.setupUi(self) to initialize the UI elements defined in your .ui file.
Python
def __init__(self):
super().__init__()
uic.loadUi("my_ui.ui", self)
# ... other initialization code