[PyQt] Basic serial question

Kyle Altendorf sda at fstab.net
Mon Sep 25 00:54:56 BST 2017


On 2017-09-24 19:35, Phil wrote:
> I wasn't thinking about using QSerialPort and pyserial together. I had
> the idea that QSerialPort would be the preferred Qt way of doing
> things.

In my PyQt application I tend to use non-Qt libs generally leaving Qt as 
primarily a GUI library.  My reasoning is that I'm more likely to want 
to reuse code or knowledge in other non-Qt Python code than in 
non-Python Qt code.

> Anyway, pyserial does the job and that's all that matters I suppose.

In some cases just getting the job done is sufficient, but sometimes how 
it gets done also matters.  The hazard with using pyserial directly is 
that you will generally end up blocking your GUI thread or running a 
separate thread, neither of which are particularly great.  At least by 
using the Qt serial library you would get signals and slots to allow for 
asynchronous send and receive.  Using Twisted instead would get you 
another layer above that for defining your protocol and any sequencing.

Aside, I would recommend resolving whatever issue you have with PyQt5 
rather than using PyQt4.  At least for new stuff, there are always extra 
considerations with existing code.

Cheers,
-kyle


More information about the PyQt mailing list