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

QtWidgets #1

Open
johansoderkvist opened this issue Jun 28, 2018 · 6 comments
Open

QtWidgets #1

johansoderkvist opened this issue Jun 28, 2018 · 6 comments

Comments

@johansoderkvist
Copy link

johansoderkvist commented Jun 28, 2018

I am not able to get the latest pyncview-git (https://github.com/BoldingBruggeman/pyncview) work together with the latest GOTM/code/gui (https://github.com/gotm-model/code)

For example:
python multiplot.py -s INFILE –e VARIABLE
gives: “cannot import name QtWidgets”
The error message is from multiplot.py
“ def plot(self,startmessageloop=True):
gui = self.output is None

    if gui:
        # We have to show figure in GUI.

        # Import PyQt libraries if not doen already.
        global QtWidgets
        if QtWidgets is None:
            from xmlstore.qt_compat import QtWidgets

To me, it seems like that module QtWidgets does not exist in:
GOTM/gotm-code/gui.py/xmlstore/qt_compat.py

Required paths are defined as export
GOTMDIR=HOME/GOTM/gotm-code
export PYTHONPATH=HOME/GOTM/gotm-code/gui.py

In multiplot.py, I have tried to shift from PyQt4 to PyQt5 and use
from PyQt5 import QtWidgets
instead, but since the xmlplot-dir use PyQt4, it is not a possible way forward


I have also tried to import the module in an ipython-environment:
ipython: from xmlstore.qt_compat import QtWidgets
In [1]: from xmlstore.qt_compat import QtWidgets
ImportError Traceback (most recent call last)
in ()
----> 1 from xmlstore.qt_compat import QtWidgets

ImportError: cannot import name QtWidgets

In [2]: import xmlstore.qt_compat


Thus, it is possible to import qt_compat but not the QtQidgets

It seems like older version of the pyncview-packages does not use QtWidgets.
In my older version of multiplot.py (def plot) use PyQt4-package instead:
“ global QtGui
from PyQt4 import QtGui”


Do you have any solution to get the pyncview package up and running?

/Johan Söderkvist
Defence Centre for Operational Oceanography (FCOO)
Denmark

@bolding
Copy link
Contributor

bolding commented Jun 28, 2018 via email

@johansoderkvist
Copy link
Author

Dear Karsten

Thank you for the tips. You are right about GOTM-version (I do not know how I mangaged to clone an old version though).
I have now downloaded and installed GOTM on linux as stated on: http://gotm.net/software/linux/
I have installed pyncview, xmlplot and xmlstore with pip.
QtWidget-problem is gone! Thanks!

Still, I run in to problems, a bit technichal though:

  1. multiplot.py:
    multiplot.py -s INFILE -e VARIABLE
    “type object got multiple values for keyword argument 'markersize'”
    The error occur in
    HOME/.local/lib/python2.7/site-packages/xmlplot/plot.py
    axes.grid(True,**lineargs) # that is line 1999

where lineargs is defined as:
lineargs = getLineProperties(gridnode['LineProperties'])
Values of lineargs are:
{'color': (0.6901960784313725, 0.6901960784313725, 0.6901960784313725), 'markersize': 6.0, 'markeredgewidth': 0.5, 'markeredgecolor': (0.0, 0.0, 0.0), 'marker': u'', 'markerfacecolor': (0.6901960784313725, 0.6901960784313725, 0.6901960784313725), 'linewidth': 0.8, 'linestyle': u'-'}

thus "'markersize': 6.0, " seems to me be a very OK value., I do not understand why multiplot-py-command gives
“type object got multiple values for keyword argument 'markersize'”

Replacing
axes.grid(True,**lineargs)
with
axes.grid(True)
results in a nice image.

  1. pyncview.py
    I can view image using pyncview. However zooming gives errors:

File "HOME/.local/lib/python2.7/site-packages/xmlplot/gui_qt4.py", line 360, in mouse_move
lastx, lasty, a, ind, lim, trans= self._xypress[0]
ValueError: need more than 5 values to unpack

So, something is missing in the object _xypress[0]
print self._xypress[0] (gives)
(174, 143.0, <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f2c9d0210>, 0, (735964.0, 736329.9930555555, -0.4382813550207892, 2.5572712728477165))

In the old environment which works fine (same nc-file but not exact same zooming area) the print statement for self._xypress[0]) is:
"
(191, 386.0, <matplotlib.axes.AxesSubplot object at 0x3671bd0>, 0, Bbox(array([[ 7.35964000e+05, -5.00000000e-01],
[ 7.36329993e+05, 2.50000000e+00]])), Affine2D(array([[ 1.58814489e+00, 0.00000000e+00, -1.16872371e+06],
[ 0.00000000e+00, 2.00000000e+02, 1.75000000e+02],
[ 0.00000000e+00, 0.00000000e+00, 1.00000000e+00]])))

I hope that this information will be sufficient for you to pinpoint what is going on, and guide me to the next step!

Best regards
Johan

@bolding
Copy link
Contributor

bolding commented Jun 29, 2018 via email

@johansoderkvist
Copy link
Author

current version of matplotlib is 2.1.1, so that should not be a problem

Thanks for tip on pyncview

@bolding
Copy link
Contributor

bolding commented Jul 2, 2018 via email

@johansoderkvist
Copy link
Author

I have downloaded and installed GOTM and pyncview.
matplotlib version =2.1.1

Still, not able to use multiplot:
python multiplot.py -s $INFILE -e VARIABLE
type object got multiple values for keyword argument 'markersize'

pyncview works fine, until I try to zoom or choosing specific coordinate (thus not 2D-plot)
Get similar error message, plus some error messages from directorys:
lib/python2.7/site-packages/xmlplot
lib/python2.7/site-packages/matplotlib/axis.py

/Johan Söderkvist

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

2 participants