Python Forum
[PyQt4] Is it right python coding scheme between TCP Server Thread and GUI class ?
Thread Rating:
  • 2 Vote(s) - 3.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[PyQt4] Is it right python coding scheme between TCP Server Thread and GUI class ?
#4
It is fine to create your gui instance (XDialog) in global, but instead you might want to put the launching code in main() right away, in case you would like to make a package in the future (see here). Also, you shouldn't put your signal in empty class (MySignal and MySignal2), they should be declared into your worker thread (MyTCPHandler), which should be a QObject. Init the object from your gui loop and connect the signals directly:

self.tcpHandler = MyTcpHandler(self)
self.tcpHandler.signal1.connect(self.imageRefresh)
...
Also, avoid using global variables (such as global progressBar_statusValue). Instead of using threading module, initiate the thread in your gui loop and pass self in your thread instance. Then you can refer directly to the variable of the parent (self.parent.progressBar_statusValue) from the worker thread.
Reply


Messages In This Thread
RE: [PyQt4] Is it right python coding scheme between TCP Server Thread and GUI class ? - by Alfalfa - Sep-18-2018, 01:21 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [PyQt] PyQt4 dynamic QComboBox littleGreenDude 4 5,696 Jan-02-2019, 07:22 PM
Last Post: littleGreenDude
  [PyQt] PyQt4 handle dynamic checkbox click littleGreenDude 1 6,596 Dec-27-2018, 09:17 PM
Last Post: littleGreenDude
  PyQt4 installation frustration littleGreenDude 4 4,549 Dec-27-2018, 04:29 PM
Last Post: littleGreenDude
  How to Integrate PyQt4 Custom Widget with Qt Designer Zukias 1 3,922 Aug-29-2018, 05:33 PM
Last Post: Zukias
  Updating Python version from command prompt and Conversion from PyQt4 to PyQt5 Vysero 4 4,970 Jul-19-2018, 03:15 PM
Last Post: Vysero
  Trouble displaying an image in PyQt4 Vysero 2 3,107 Jul-01-2018, 05:25 PM
Last Post: Alfalfa
  [PyQt] problem with PyQt4 jss15497 0 2,770 Jan-16-2018, 08:32 AM
Last Post: jss15497
  [PyQt] Learn pyqt5 using pyqt4 jimclay75051 5 5,815 Nov-13-2017, 06:29 AM
Last Post: zykbee
  How to program PyQt4 from python? medic_ward 3 4,930 Feb-27-2017, 05:11 PM
Last Post: medic_ward
  PyQT4 only upper case text iFunKtion 1 3,687 Feb-27-2017, 01:13 PM
Last Post: Raures

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020