1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
#! /usr/bin/python3
from __future__ import print_function
import sys, serial, time, datetime, csv
from os import system
import RPi.GPIO as GPIO
from xbee import XBee, ZigBee
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtWidgets import QApplication, QMainWindow
#import de la fenêtre
from Interface.rdint import Ui_RdInt
###############Définition des classes##################
class RadioApp(QMainWindow):
def __init__(self,parent=None):
super (RadioApp, self).__init__(parent)
self.createWidgets()
self.ser = serial.Serial(SERIALPORT, BAUDRATE)
self.xbee = XBee(self.ser, callback=self.Reception)
self.ui.txtRecept.setText("Test")
#self.SERIALPORT=SERIALPORT
#self.BAUDRATE=BAUDRATE
def createWidgets(self):
self.ui = Ui_RdInt()
self.ui.setupUi(self)
def closeEvent(self, event):
self.xbee.halt()
self.ser.close()
QApplication.instance().exit(2)
def Reception(self, data):
self.ui.txtRecept.setText("20")
SERIALPORT = "/dev/serial0"
BAUDRATE = 9600
#Test application graphique
if __name__ == "__main__":
app = QApplication(sys.argv)
myapp = RadioApp()#"/dev/serial0",9600
myapp.show()
rc = app.exec_()
sys.exit(rc) |
Partager