如何从线程类python中设置SetText标签

时间:2015-07-06 10:22:29

标签: python

我有一个Qt图形界面。 如何从线程

刷新标签文本(lbl_serial_aff)

在主文件MainProg.py中,我有一个启动线程(ComWatcher)来扫描串口的函数:

def RS232_RD_parametres_2(self):
    print('*** DEBUT *** RS232_RD_parametres 2 \r\n')
    watcher = ComWatcher()
    watcher.start()

在Thread.py

import thread
import threading
import time
import serial
import tuto_form4

from tuto_form4 import *
from globalvar import *

class ComWatcher(threading.Thread):
    def __init__(self):
        threading.Thread.__init__(self)
        self.running = False
        port = serial.Serial("/dev/ttyUSB0", baudrate=19200,  timeout=0.0) #
        print('start') 

    def run(self):
        global rd_parametre
        print('run')

        #tuto_formMain.self.aaa()
        #self.lbl_serial_aff.setText("None")

        """Le code que le thread devra exécuter."""
        port = serial.Serial("/dev/ttyUSB0", baudrate=19200,  timeout=0.0) #
        self.running = True
        while self.running:
            [.....]

    def stop(self):
        self.running = False

如何更改图形界面中的标签文字和所有内容?

lbl_serial_aff.setText("None")

谢谢,

0 个答案:

没有答案