charbj / wiggle

Graphical user interface to integrate cryoEM flexibility analyses with ChimeraX
GNU General Public License v3.0
21 stars 4 forks source link

Make Wiggle work with PyQt6 in ChimeraX 1.4 #4

Open tomgoddard opened 1 year ago

tomgoddard commented 1 year ago

I see Wiggle is directly using PyQt5 which is what ChimeraX 1.3 used. But the current ChimeraX 1.4 (released in June 2022) uses PyQt6. The way this is handled in ChimeraX is anywhere you would import from PyQt5 instead import from Qt. For example instead of

from PyQt5 import QtCore, QtGui, QtWidgets

use

from Qt import QtCore, QtGui, QtWidgets

This relies on the fact that PyQt6 and PyQt5 are almost compatible. Hopefully they will be fully compatible for the uses Wiggle makes. I changed the imports in wiggle and also changed QtCore.pyqtSignal to QtCore.Signal and the user interface displayed but I have not tested that it all functions.

Here is the error trying to use Wiggle in a current ChimeraX daily build (that will become ChimeraX 1.5 expected to be released at the end of October or in November 2022).

UCSF ChimeraX version: 1.5.dev202209210054 (2022-09-21)
© 2016-2022 Regents of the University of California. All rights reserved.
How to cite UCSF ChimeraX
ui tool show wiggle
Traceback (most recent call last):
  File "/Users/goddard/ucsf/chimerax/ChimeraX.app/Contents/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/chimerax/core/toolshed/info.py", line 559, in start_tool
    ti = api._api_caller.start_tool(api, session, self, tool_info)
  File "/Users/goddard/ucsf/chimerax/ChimeraX.app/Contents/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/chimerax/core/toolshed/__init__.py", line 1325, in start_tool
    return cls._get_func(api, "start_tool")(session, bi, ti)
  File "/Users/goddard/Library/Application Support/ChimeraX/1.5/site-packages/chimerax/wiggle/__init__.py", line 29, in start_tool
    from . import tool
  File "/Users/goddard/Library/Application Support/ChimeraX/1.5/site-packages/chimerax/wiggle/tool.py", line 15, in <module>
    from PyQt5 import QtCore, QtGui, QtWidgets
ModuleNotFoundError: No module named 'PyQt5'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/goddard/ucsf/chimerax/ChimeraX.app/Contents/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/chimerax/ui/gui.py", line 1660, in <lambda>
    run(ses, "ui tool show %s" % StringArg.unparse(tool_name)))
  File "/Users/goddard/ucsf/chimerax/ChimeraX.app/Contents/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/chimerax/core/commands/run.py", line 38, in run
    results = command.run(text, log=log, return_json=return_json)
  File "/Users/goddard/ucsf/chimerax/ChimeraX.app/Contents/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/chimerax/core/commands/cli.py", line 2897, in run
    result = ci.function(session, **kw_args)
  File "/Users/goddard/ucsf/chimerax/ChimeraX.app/Contents/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/chimerax/ui/cmd.py", line 219, in ui_tool_show
    bi.start_tool(session, name)
  File "/Users/goddard/ucsf/chimerax/ChimeraX.app/Contents/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/chimerax/core/toolshed/info.py", line 564, in start_tool
    raise ToolshedError(
chimerax.core.toolshed.ToolshedError: start_tool() failed for tool wiggle in bundle wiggle:
No module named 'PyQt5'

chimerax.core.toolshed.ToolshedError: start_tool() failed for tool wiggle in bundle wiggle:
No module named 'PyQt5'

File "/Users/goddard/ucsf/chimerax/ChimeraX.app/Contents/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/chimerax/core/toolshed/info.py", line 564, in start_tool
raise ToolshedError(
charbj commented 1 year ago

Thanks! This is what I have done in the 0.2.2X1.4 branch in response to this issue https://github.com/charbj/wiggle/issues/1.

I have been testing that for a while, and it seems to be okay (nothing has broken so far). So I may merge this into the main branch and close this issue.

CBJ

tomgoddard commented 1 year ago

Oops! I should have checked earlier issues to see if this was already discussed. I do think it is pretty safe to switch over to the imports from Qt instead of PyQt6. Most ChimeraX users should be using ChimeraX 1.4 so having the main branch only work on 1.3 will discourage some people.