sem-geologist / HussariX

HussariX - software to open/ read and view Cameca EPMA and Bruker SEM formats, track samples in μ-space and time.
GNU General Public License v3.0
8 stars 2 forks source link

module 'PyQt5.QtGui' has no attribute 'QGraphicsPolygonItem' #2

Open ricounet67 opened 3 years ago

ricounet67 commented 3 years ago

When I try to execute HussariX.py I have the following error: Traceback (most recent call last): File "D:\OneDrive - UPEC\QSEM-viewer\HussariX.py", line 12, in from lib.ui import SpectrumWidgets as sw File "D:\OneDrive - UPEC\QSEM-viewer\lib\ui\SpectrumWidgets.py", line 50, in from .CustomPGWidgets import CustomViewBox, CustomAxisItem File "D:\OneDrive - UPEC\QSEM-viewer\lib\ui\CustomPGWidgets.py", line 181, in class selectablePolygon(selectableMarker, QtGui.QGraphicsPolygonItem): AttributeError: module 'PyQt5.QtGui' has no attribute 'QGraphicsPolygonItem'

sem-geologist commented 3 years ago

These are classes which were not revised as those were for Jeol SEM stuff, they probably will be reused for Bruker stuff, or dropped. You probably have newest PyQt5, which is more strict. Some older versions of QtGui, for "convenience" was exposing widgets under QtGui , while proper import should be from QtWidgets. I am updating the master branch with that fix, please let know if problem persists.

ricounet67 commented 3 years ago

yes, but now I have a new one: Traceback (most recent call last): File "HussariX.py", line 29, in class DockMenu(QtGui.QMenu): AttributeError: module 'PyQt5.QtGui' has no attribute 'QMenu'

sem-geologist commented 3 years ago

Ok... looks I need to look through whole code and get rid of that inconvenient-convenience stuff. Convenience stuff always backfires in ome or other way... I probably should switch away from hard dependency on PyQt5, and move to QtPy, pyqt from pyqtgraph... so it could be used with pyside2, pyside6 or pyqt5 or 6....

ricounet67 commented 3 years ago

Sorry for that. Maybe you can just specify to make a virtualenv with the specific versions of the different libraries? Because like this, the application was launching. I just had a warning about a missing image in the icons/light folder. I think that the file rtp_open.svg is misspelled it should be rtx_open.svg like in the dark directory.

Eric LEROY

Le 28 juil. 2021 à 20:38, Petras Jokubauskas @.***> a écrit :

 Ok... looks I need to look through whole code and get rid of that inconvenient-convenience stuff. Convenience stuff always backfires in ome or other way... I probably should switch away from hard dependency on PyQt5, and move to QtPy, pyqt from pyqtgraph... so it could be used with pyside2, pyside6 or pyqt5 or 6....

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

sem-geologist commented 3 years ago

Nice catch with filename typo. Well this is quite a start of this project, I am thinking how to make it more universal, so that it would not be so much dependent from versions. I could use qtpy but that is additional dependency. pyqtgraph has its own mechanics to use qt version and can use pyside, pyqt4, pyqt5, pyside2 and will be able to use pyside6 (Qt6). Because of still having pyside and pyqt4 export pyqtgraph puts and exposes under pyqtgraph only QtCore and QtGui; no direct QtWidgets. I like the division between QtWidgets and QtGui in newer PyQt or PySide versions - it is logical, and it helps navigating along documentation (I am used in reading/consulting C++/Qt documentation, makes more sense to me). Any solution have its bad sides...

ricounet67 commented 3 years ago

Thank you. By the way I tried to open different wdsdat files. Some are working and some are not working. For those that are working I can’t visualize the spectrum. Maybe a problem of color since the crystals are read

Eric LEROY

Le 29 juil. 2021 à 21:46, Petras Jokubauskas @.***> a écrit :

 Nice catch with filename typo. Well this is quite a start of this project, I am thinking how to make it more universal, so that it would not be so much dependent from versions. I could use qtpy but that is additional dependency. pyqtgraph has its own mechanics to use qt version and can use pyside, pyqt4, pyqt5, pyside2 and will be able to use pyside6 (Qt6). Because of still having pyside and pyqt4 export pyqtgraph puts and exposes under pyqtgraph only QtCore and QtGui; no direct QtWidgets. I like the division between QtWidgets and QtGui in newer PyQt or PySide versions - it is logical, and it helps navigating along documentation (I am used in reading/consulting C++/Qt documentation, makes more sense to me). Any solution have its bad sides...

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

sem-geologist commented 3 years ago

Probably the best way will be to require pyqtgraph >=0.12, as starting from that QtGui, QtCore, QtWidgets can be imported from pyqtgraph.Qt. It works at least with system python and conda python on linux.

As for not seeing a thing when files are loaded, probably my help WhatIsThis strings needs lots of improvement. Please look at this screenshot and numbered elements: Hussarix_screen_shot

for WDS curve to appear on canvas, dataset needs to be checked at (1), AND one ( or more) of xtal-spectrometer combination needs to be checked at (2); dataset tree view check state does not autorange ( intentionally) canvas, while xtal-spect selector does. thus (3) needs to be clicked.

sem-geologist commented 3 years ago

I need to bring some light why it is like that

The wdsDat explore mode is built so that different datasets could be effortlessly inspected and overlayed. It departs there from how Peaksight handles wdsDat. In peaksight, we can see only single dataset at once, if we want to plot data from different dataset we need to import every dataset into single dataset, and there is no batch merging of datasets into single dataset. Also datasets can contain different xtals and spectrometers and all these gets mingled in peaksight into single list in the dataset. Basically to achieve something like in Hussarix needs tone of clicking and waiting. On HussariX these scopes are completely separated. When files (wdsDat) are loaded the datasets are scanned for possible xtal-spect combinations and exposes those in the separate list. This have few benefits: at first, we don't need "single", "multi", "compare" modes and corresponding radio boxes, the list of possible xtal-spect combinations does all that without taking precious display space.

The peaksight "single"-like mode, where you can plot every xtal-spect wds curves in a single plotting canvas is possible in Hussarix only if x-axis units are other than cameca units (100k sin(theta)); default mode of plotting data from all spectrometers in single spect position x-axis makes no sense and would be extremely cluttered. This is prevented in Hussarix, as when x-axis mode is cameca spect units, when we check xtal-spect combination, we can check only another combination, which contains xtal from the same xtal family (i.e. 3:LIF and 4:LLIF). Currently colors are not customizable, colorcet's glasbey color palette is borrowed for most distinct color list. In the future I think I should add right-click menu for color change, as I find that on some screens some curve colors at light-mode is not easily distinct from background; Alternatively, I could make some modifications on borrowed palette, and simply get rid of colors which cause visibility trouble (pallet length is 255, there would be no shortcoming to throw out few too bright ones). At xtal-spect list the line shape and width can be customized (mouse right-click on xtal-spect combination) in some degree, albeit line-width when set more than 1 cause performance penalty. So "single" and "compare" like modes can be "emulated" and no checkbox is needed.

What about "multi"- mode?; that can be achieved by generating separate plotting widget (menu-plotting-new plotting widget).

BTW, file dataset tree is global, check state applies to all plotting widgets, while xtal-spect list is local - changes visibility only for the plotting canvas it is attached to.

Why such strange approach? This is useful to inspect background positions (free regions from artifacts and overlaps) when we have wds scans for high concentration for every measurable element. (as You can see in previous screenshot, where is list of standards which were WDS scanned). Taking such Wds scan set takes some analytical time, but saves a lot of time later, as there is no more need to take full wds Scans for unknown; If we want to measure small concentrations, high intensity acquisition of high concentration reference material will show better all spectral artifacts, than what we could reasonably get from wds scan of unknown.

I use this every-time I am creating a new analytical label in peaksight, I load wdsDat in Hussarix with set of scans of references taking at same HV, check-on the datasets with elements as major for elements I need to analyse, go through peaks and background positions, and adjust for no collision or other funky effects (edge).

sem-geologist commented 3 years ago

@ricounet67 , so are Your wdsDat files, which You can open, still not visible in canvas? Could You open issue and attach some wdsDat files which You can't open at peaksight-binary-parser repository (I guess files which You can open are older files (pre peaksight =<6.4), and files which You can't open are peaksight 6.5).

sem-geologist commented 3 years ago

@ricounet67 , just a bump with same question as above. Basically this issue is fixed, as I had moved to Qt imports from pyqtgraph - that way this should work with pyside2, pyside6 or pyqt5 or pyqt6. As for development and better handling of this issue, pyqtgraph implemented much better wrapper for Qt, and from pyqtgraph 0.12 QtWidgets are also exposed. It also restructured wrapper so now IDE's completion works flawlessly.

Now, If you have files which can't be opened, I really would appreciate that to be reported at https://github.com/sem-geologist/peaksight-binary-parser/issues

Can I close this issue?

ricounet67 commented 3 years ago

I still have some files that can’t be opened. I can upload them if you need. I will get the latest version and check if the issue is still there.

Le sam. 11 sept. 2021 à 14:44, Petras Jokubauskas @.***> a écrit :

@ricounet67 https://github.com/ricounet67 , just a bump with same question as above. Basically this issue is fixed, as I had moved to Qt imports from pyqtgraph - that way this should work with pyside2, pyside6 or pyqt5 or pyqt6. As for development and better handling of this issue, pyqtgraph implemented much better wrapper for Qt, and from pyqtgraph 0.12 QtWidgets are also exposed. It also restructured wrapper so now IDE's completion works flawlessly.

Now, If you have files which can't be opened, I really would appreciate that to be reported at https://github.com/sem-geologist/peaksight-binary-parser/issues

Can I close this issue?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/sem-geologist/QSEM-viewer/issues/2#issuecomment-917401423, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAIKHNHLLIQABV7RC4IFBZTUBNFLDANCNFSM5BD4NSJQ .

-- Éric Leroy

sem-geologist commented 3 years ago

Yes please, I would like to see those files. As For PyQt5, It looks that I was mistaken, my IDE still does not do code completion if Qt classes are imported from pyqtgraph, so I am staying currently with PyQt5 as dependence in code.

sem-geologist commented 2 years ago

@ricounet67 just letting you to know that I got my hands on some peaksight 6.5 files, and the diferring file structure was adressed/taken careoff, so that can be considered fixed. All latestest versions should have no problem. As soon I will finish with implementation of "burning" the markers/ annotations to plot, I will consider Wds part to be completed. And then plan to do some tutorial videos and applicational demonstrations.