larray-project / larray-editor

Graphical User Interface for LArray
GNU General Public License v3.0
2 stars 2 forks source link

viewer does not work correctly after Array.plot() #261

Closed gdementen closed 1 year ago

gdementen commented 1 year ago

Test case:

arr = ndtest(3)
arr.plot()
plt.show()
view(arr)

The behaviour is different using larray 0.34 and 0.34.1, but bad in both cases.

When using 0.34, since there is a Qt application left over by matplotlib, but no Window is detected, view() shows the window but closes it immediately. Even without plt.show() it seems like the Qt application is created and thus the viewer is closed immediately. When using 0.34.1, it seems to work fine if we do not actually show the window via plt.show() but with it, it crashes with:

Traceback (most recent call last):
  File "<whatever>", line 41, in main
    view(arr)
  File "[...]\lib\site-packages\larray\viewer\__init__.py", line 30, in view
    view(obj, title, depth + 1)
  File "[...]\lib\site-packages\larray_editor\api.py", line 388, in view
    _show_dialog("Viewer", create_edit_dialog, obj=obj, title=title, readonly=True, depth=depth + 1)
  File "[...]\lib\site-packages\larray_editor\api.py", line 47, in _show_dialog
    dlg = create_dialog_func(parent, *args, **kwargs)
  File "[...]\lib\site-packages\larray_editor\api.py", line 179, in create_edit_dialog
    dlg = ArrayEditor(parent)
  File "[...]\lib\site-packages\larray_editor\editor.py", line 1163, in __init__
    AbstractEditor.__init__(self, parent, editable=True)
  File "[...]\lib\site-packages\larray_editor\editor.py", line 92, in __init__
    QMainWindow.__init__(self, parent)
TypeError: QMainWindow(parent: QWidget = None, flags: Union[Qt.WindowFlags, Qt.WindowType] = Qt.WindowFlags()): argument 1 has unexpected type 'QWindow'
gdementen commented 1 year ago

I have further refined the issue... If the plot window is closed before mousing over it, it works.

It seems like after a mouse over, some junk is left behind. The coordinates label maybe???