Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PyQt4 still being used in some meqtrees scripts. #59

Open
twillis449 opened this issue Oct 11, 2020 · 18 comments
Open

PyQt4 still being used in some meqtrees scripts. #59

twillis449 opened this issue Oct 11, 2020 · 18 comments

Comments

@twillis449
Copy link
Contributor

Some scripts, such as meqbrowser.py, are still using PyQy4 . At a minimum I suggest transiting to PyQt5, as python-land will be migrating to PyQt6 in the not-too-distant future. I'm suspicious that this use of PyQt4 may be causing some of the problems I've had getting a working MeqTrees system up and running recently.

@bmerry
Copy link
Contributor

bmerry commented Dec 15, 2020

It's also getting pulled in by meqtree-pipeliner.py:

Traceback (most recent call last):
  File "/usr/local/bin/meqtree-pipeliner.py", line 71, in <module>
    from Timba.Apps import meqserver
  File "/home/kat/ve3/lib/python3.8/site-packages/Timba/Apps/meqserver.py", line 32, in <module>
    from Timba.Meq import meqds
  File "/home/kat/ve3/lib/python3.8/site-packages/Timba/Meq/meqds.py", line 32, in <module>
    from Timba.GUI.pixmaps import pixmaps
  File "/home/kat/ve3/lib/python3.8/site-packages/Timba/GUI/pixmaps.py", line 1, in <module>
    from Kittens.pixmaps import *
  File "/home/kat/ve3/lib/python3.8/site-packages/Kittens/pixmaps.py", line 28, in <module>
    from PyQt4.Qt import SIGNAL, QPixmap, QIcon
ModuleNotFoundError: No module named 'PyQt4'

@bennahugo
Copy link
Contributor

Hi as discussed with @Athanaseus we will try backport and ship PyQt4 for Ubuntu 20.04. I don't think we have the capacity on our side to rewrite the Meqtrees gui in Qt 5 with all the new form event handling system, since it is no longer actively used in our team - it is being replaced by Dask based commandline tools. I think we can try isolate it from the pipeliner. That should be do-able.

Note there is another upstream issue in the new astropy which makes the pipeliner fail @bmerry. It only triggers under some special import conditions and I'm yet to isolate it. I think the kludge for now would be to downgrade Astropy to a version prior to the introduction of the bug.

@twillis449
Copy link
Contributor Author

Actually, I've done much of the coding to make things work with PyQt5 (including modification of a lot of python scripts originally written by @o-smirnov but I'm not sure which version/branch of MeqTrees to check out to test if things are working. I was actually held up by some octopussy script which @Athanaseus was going to fix - has that been done? The pyqt4toqt5 (sic?) script that's available on the net will do most of the signal/event handling conversion for you - the only issue is what to to do if the signal is caught by a separate script which you are importing.

@bennahugo
Copy link
Contributor

I have decoupled some of the pyqt4 dependency in the scripts - if it is not installed the pipeliner will still run. This solves @bmerry's issue on ubuntu 20.04. @twillis449 if you can make a PR with your pyqt5 changes I can have a look and see how much there is left to do

@twillis449
Copy link
Contributor Author

@bennahugo OK - will work on this.

@twillis449
Copy link
Contributor Author

twillis449 commented Jan 20, 2021

Still working on this but making progress. I'm starting to hate Qt and PyQt - why can't they provide interfaces for backward compatibility - I guess they want to create jobs for life - grrrr!

And of course, these ancillary packages kittens and cattery, etc also need to be upgraded. grrrr +++

@twillis449
Copy link
Contributor Author

An example of inconsistencies in signals/slots in our code. We have pyqtSIGNAL, SIGNAL, pyqtsignal, and Signal at the moment being imported from various sources. I'm trying to straighten things out ... There are also a few scripts that are proving difficult to upgrade to PyQt5. And thank the good Lord for the existence of Stackoverflow and StackExchange websites :)

@bennahugo
Copy link
Contributor

bennahugo commented Jan 29, 2021 via email

@bennahugo
Copy link
Contributor

bennahugo commented Jan 29, 2021 via email

@twillis449
Copy link
Contributor Author

I found an annoyance in the latest PythonQwt (v0.8) - the owner added a test so that you cannot have X data of say type float32 and the y-data of type float64 and somewhere deep in my system (I can't figure out where) I can at some stage send in y-data of type float64 while the x data remains at type float 32. Anyway, since I have the actual code, I've just commented out that test.

Unfortunately, the owner only seems to surface about once every three years to do bug fixes or changes.

@bennahugo
Copy link
Contributor

bennahugo commented Jan 29, 2021 via email

@twillis449
Copy link
Contributor Author

I'm fed up with Qt because it started out as a nice system for developing GUI interfaces but has now become some sort of gigantic multi-tentacled octopus(sy). I tried to compute Qt5 a week or two ago and the compilation ate up some 45 Gb of disk space before it crashed as I had run out of disk space. :(

Anyway @o-smirnov I'm now completely stumped as I get the error:
File "/usr/local/lib/python3.8/dist-packages/Timba/GUI/app_proxy_gui.py", line 158, in init
HierBrowser.init(self,self._vbox,name,udi_root=udi_root);
File "/usr/local/lib/python3.8/dist-packages/Timba/GUI/browsers.py", line 425, in init
self._tw.header().setResizeMode(0,QHeaderView.ResizeToContents);
AttributeError: 'QHeaderView' object has no attribute 'setResizeMode'

This happens in PyApps/src/GUI/browser.py ....

init for HierBrowser

def init(self,parent,name,name1='',udi_root=None,caption=None,prec=(None,'g'),maxwidth=None):
self._tw = DataDraggableTreeWidget(ClickableTreeWidget)(parent);
self._tw.setHeaderLabels([name1,'',name]);
self._tw.setRootIsDecorated(True);
self._tw.setSortingEnabled(False);
self._tw.header().setResizeMode(0,QHeaderView.ResizeToContents); # <------ note my line number will be from the PyQt4 version
self._tw.header().setResizeMode(1,QHeaderView.ResizeToContents);
self._tw.header().setResizeMode(2,QHeaderView.ResizeToContents);
self._tw.header().setStretchLastSection(False);
self._tw.header().setResizeMode(QHeaderView.ResizeToContents);

The DataDraggableTreeWidget is defined in PyApps/src/GUI/widgets.py

@razman786
Copy link

razman786 commented Jan 30, 2021 via email

@razman786
Copy link

razman786 commented Jan 30, 2021 via email

@bennahugo
Copy link
Contributor

bennahugo commented Jan 30, 2021 via email

@razman786
Copy link

razman786 commented Jan 30, 2021 via email

@twillis449
Copy link
Contributor Author

twillis449 commented Jan 30, 2021

Thanks for your various comments guys. some responses - both PyQt-qwt (author GauiStori) and python-qwt (author Raybaut) are available as packages on Ubuntu 2.04 LTS. Unfortunately, the python-qwt package is still at release 0.5.5 and doesn't seem to work properly (at least not for me) whereas the current github code does seem to work, so that's what I'm currently using. Also, interestingly the current version introduced me to the qtpy package. Qtpy is a wrapper which (at least in theory) allows your 'base' interface to Qt to be either PyQt or Pyside. so you import stuff as e.g.

from qtpy.QtGui import QBrush, QPen, QColor, QImage, qRgba, QFont, QFontInfo
from qtpy.QtCore import Qt, QSize, QObject, QTimer, QPoint, Signal

and it 'should just work' to get the correct python package, either PyQt or Pyside. So I've been using these calls in all my updated code.

As you correctly surmise @razman786 I'm porting from PyQt4 to PyQt5, and thanks for the suggested bug fix that you provided above. I will look at that. I actually ported all my visualization stuff in the timba PyApps/src/Plugins directory to PyQt5 and python-qwt last July and that's provided me with some foreknowledge of the headaches I would get. :)

PyQtGraph is also available as a standard Ubuntu package. It claims to be very fast (which is something I could use if I want to plot data for 20000 SKA baselines) but that's something I'm leaving for another day. @razman786 if you do successfully port some code to pyqtgraph let me know :)
Cheers
Tony

@razman786
Copy link

razman786 commented Jan 30, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants