
interfaz python + QT
Publicado por kristal (1 intervención) el 30/04/2018 23:52:28
hola amigos!!
necesito ayuda para arreglar mi programa:(
EL PROBLEMA ES QUE, EN LA INTERFAZ QUE CREE CON QT CREATOR, EL DISPLAY NO SE ACTUALIZA CONSTANTEMENTE, QUE LEA LOS VALORES CONTINUAMENTE ES LO QUE NECESITO :( POR AHORA LO TENGO ECHO PARA QUE LEA UN VALOR EN EL DISPLAY DESPUES DE 5 VALORES DE ENTRADA
LES DEJO MI PROGRAMA POR SI ME PUEDEN AYUDAR. ( en negrita dejo la función que creo yo se debe modificar para arreglar este error)
necesito ayuda para arreglar mi programa:(
EL PROBLEMA ES QUE, EN LA INTERFAZ QUE CREE CON QT CREATOR, EL DISPLAY NO SE ACTUALIZA CONSTANTEMENTE, QUE LEA LOS VALORES CONTINUAMENTE ES LO QUE NECESITO :( POR AHORA LO TENGO ECHO PARA QUE LEA UN VALOR EN EL DISPLAY DESPUES DE 5 VALORES DE ENTRADA
LES DEJO MI PROGRAMA POR SI ME PUEDEN AYUDAR. ( en negrita dejo la función que creo yo se debe modificar para arreglar este error)
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
rom PyQt5 import QtWidgets, QtCore, uic
QtCore.Slot = QtCore.pyqtSlot
QtCore.Signal = QtCore.pyqtSignal
import serial
import sys
class lecturasensor_gui(QtWidgets.QWidget):
def __init__(self, parent=None):
super(lecturasensor_gui, self).__init__(parent)
uic.loadUi('./lecturasensor_gui.ui', self)
return
def refresh_text_box(self, sensor):
self.plainTextEdit.setPlainText(sensor)
QtWidgets.QApplication.processEvents()
@QtCore.Slot()
def on_leer_btn_clicked(self):
ar = serial.Serial('COM3', 9600)
c = 0
while c<5:
sensor = ar.readline().strip().decode('utf-8')
print(sensor)
c += 1
self.refresh_text_box(sensor + ' Gr')
ar.close()
return
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
main = lecturasensor_gui()
main.show()
sys.exit(app.exec_())
sys.exit(app.exec_())
Valora esta pregunta


0