I am working on a Raspberry Pi Project. The Raspi detects when a Laser light barrier has been interrupted.
When this happens, i want to change the text in a PyQt label.
I now have two Python files, which i don't know how to connect together.
The GPIO detection:
import RPi.GPIO as GPIO
import os, time
RECEIVER_PIN = 23
def callback_func(channel):
if GPIO.input(channel):
# CHANGE THE PYQT LABEL TEXT
if __name__ == '__main__':
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(RECEIVER_PIN, GPIO.IN)
GPIO.add_event_detect(RECEIVER_PIN, GPIO.RISING, callback=callback_func, bouncetime=200)
try:
while True:
time.sleep(0.5)
except:
GPIO.remove_event_detect(RECEIVER_PIN)
And the PyQt Window:
import sys from PyQt5.QtWidgets import QApplication, QMainWindow from PyQt5.QtCore import QFile from ui_mainwindow import Ui_MainWindow
class MainWindow(QMainWindow):
def __init__(self):
super(MainWindow, self).__init__()
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self.label.setGeometry(QtCore.QRect(0, 19, 831, 461))
if __name__ == "__main__":
app = QApplication(sys.argv)
window = MainWindow()
window.show()
sys.exit(app.exec_())
How can I connect these together?