DDDD
DDDD

Reputation: 153

PyQt timer in GUI to update info

I am creating a GUI in python to display info from some sensors.

This way, i want that after pressing a linking pushbutton, the GUI periodically updates info. Here is the code:

def linkage(self, Form):
    self.s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);
    self.label_communication.setText("aaaa")
    try:
        ip=self.lineEdit_ip.text()
        port=self.lineEdit_2.text()
        self.s.connect((ip,int(port)));
        self.label_communication.setText("connected")
        #self.timer = QtCore.QTimer()
        #self.timer.timeout.connect(updatefunc)
        #self.timer.start(1000)
    except:
        self.label_communication.setText("not connected")

When i press the button with the timer lines commented, the label shows "connected". But when the timer is not commented, it shows "not connected".

How should i solve this?

Thanks

Upvotes: 0

Views: 320

Answers (1)

Achayan
Achayan

Reputation: 5885

you are using try/except so you are suppressing the original error. So in your case either remove tr/except or use a print or traceback, I prefer traceback

import traceback
try:
   your_code
except:
   print traceback.format_exc()
   self.label_communication.setText("not connected")

this will show what exactly happening without erroring out

Upvotes: 1

Related Questions