# Import the necessary modules
from PyQt5.QtCore import QObject, pyqtSignal

# Define a custom signal
class MySignal(QObject):
    my_signal = pyqtSignal(str)

# Create an instance of the custom signal
my_signal_instance = MySignal()

# Connect a slot to the signal
def my_slot(message):
    print(message)

my_signal_instance.my_signal.connect(my_slot)

# Emit the signal
my_signal_instance.my_signal.emit("Hello World!")

 

posted on 2023-05-12 14:16  逻辑思维导图  阅读(24)  评论(0)    收藏  举报