Bundle development for chimeraX - svg onClick event to run command from QWebEngineView

Hello, Apologies if this is the wrong email address to contact about this. I am currently working on a privateer bundle for carbohydrate validation in chimeraX. At present, I have it so that the privateer tool will display SNFGs of glycans present in the structure using svgs displayed in a QWebEngineView(). I would like, if possible, on clicking elements of the svg to run a chimeraX command (view /chainID:resID) to centre the view window on the residue in question. At present, I can implement an onClick event to display the command that should be run, but haven't managed to figure out how to just run the command from within that QWebEngineView. Is there a mechanism already in place for doing something like this that I could take advantage of? I'd considered using the "log html" to display the svgs in the log instead of the WebEngineView() so that I could take advantage of the href="cxcmd" functionality, but the svgs are long, with semicolons and new-line characters which interfere with this. Best wishes, Lou Holland (Pronouns: they/them) Research Associate York Structural Biology Laboratory, Department of Chemistry, University of York, Heslington, YO10 5DD, York, UK

Apologies, just realised I should have sent this to the developer mailing list. I'll do so now. On Tue, 18 Feb 2025, 12:03 Lou Holland, <lou.holland@york.ac.uk> wrote:
Hello,
Apologies if this is the wrong email address to contact about this. I am currently working on a privateer bundle for carbohydrate validation in chimeraX. At present, I have it so that the privateer tool will display SNFGs of glycans present in the structure using svgs displayed in a QWebEngineView().
I would like, if possible, on clicking elements of the svg to run a chimeraX command (view /chainID:resID) to centre the view window on the residue in question. At present, I can implement an onClick event to display the command that should be run, but haven't managed to figure out how to just run the command from within that QWebEngineView. Is there a mechanism already in place for doing something like this that I could take advantage of?
I'd considered using the "log html" to display the svgs in the log instead of the WebEngineView() so that I could take advantage of the href="cxcmd" functionality, but the svgs are long, with semicolons and new-line characters which interfere with this.
Best wishes, Lou Holland (Pronouns: they/them)
Research Associate York Structural Biology Laboratory, Department of Chemistry, University of York, Heslington, YO10 5DD, York, UK

Hi Lou, You should be able to run commands by doing something like: ```python from chimerax.core.commands import run run(session, "view /coolChain:coolResidue", log=True) ``` Best, Tom From: "ChimeraX Users Help" <chimerax-users@cgl.ucsf.edu> To: "ChimeraX Users Help" <chimerax-users@cgl.ucsf.edu> Sent: Tuesday, 18 February, 2025 14:09:49 Subject: [chimerax-users] Re: Bundle development for chimeraX - svg onClick event to run command from QWebEngineView Apologies, just realised I should have sent this to the developer mailing list. I'll do so now. On Tue, 18 Feb 2025, 12:03 Lou Holland, < [ mailto:lou.holland@york.ac.uk | lou.holland@york.ac.uk ] > wrote: Hello, Apologies if this is the wrong email address to contact about this. I am currently working on a privateer bundle for carbohydrate validation in chimeraX. At present, I have it so that the privateer tool will display SNFGs of glycans present in the structure using svgs displayed in a QWebEngineView(). I would like, if possible, on clicking elements of the svg to run a chimeraX command (view /chainID:resID) to centre the view window on the residue in question. At present, I can implement an onClick event to display the command that should be run, but haven't managed to figure out how to just run the command from within that QWebEngineView. Is there a mechanism already in place for doing something like this that I could take advantage of? I'd considered using the "log html" to display the svgs in the log instead of the WebEngineView() so that I could take advantage of the href="cxcmd" functionality, but the svgs are long, with semicolons and new-line characters which interfere with this. Best wishes, Lou Holland (Pronouns: they/them) Research Associate York Structural Biology Laboratory, Department of Chemistry, University of York, Heslington, YO10 5DD, York, UK _______________________________________________ ChimeraX-users mailing list -- chimerax-users@cgl.ucsf.edu To unsubscribe send an email to chimerax-users-leave@cgl.ucsf.edu Archives: https://mail.cgl.ucsf.edu/mailman/archives/list/chimerax-users@cgl.ucsf.edu/

Hi Lou, Tom Mulvaney explains how to run a ChimeraX command from Python. But I think you are better off using the "cxcmd" scheme that you mentioned and it should work even when the SVG expression in the HTML is complicated. First you would use the ChimeraX class ChimeraXHtmlView which is a subclass of QWebEngineView that makes the cxcmd links work. from chimerax.ui.widgets import ChimeraXHtmlView chv = ChimeraXHtmlView(session, parent) chv.setHtml('string with html that shows svg images') In the html you define links in the usual HTML way but instead of linking to another web page it runs ChimeraX commands using the "cxcmd" scheme <a href="cxcmd:view /A:57"> <svg>define svg</svg> </a> The thumbnails of recently opened files that you see in the ChimeraX graphics area when you start ChimeraX works exactly this way and is implented in this code https://github.com/RBVI/ChimeraX/blob/develop/src/bundles/ui/src/file_histor... It is best to ask this question on this chimerax-users mailing list. The chimera-dev list was for developer questions about the old Chimera program. For ChimeraX we just use one mailing list for both user and developer questions. Tom
On Feb 18, 2025, at 8:09 AM, Tom Mulvaney via ChimeraX-users <chimerax-users@cgl.ucsf.edu> wrote:
Hi Lou,
You should be able to run commands by doing something like:
```python from chimerax.core.commands import run
run(session, "view /coolChain:coolResidue", log=True) ```
Best, Tom
From: "ChimeraX Users Help" <chimerax-users@cgl.ucsf.edu> To: "ChimeraX Users Help" <chimerax-users@cgl.ucsf.edu> Sent: Tuesday, 18 February, 2025 14:09:49 Subject: [chimerax-users] Re: Bundle development for chimeraX - svg onClick event to run command from QWebEngineView
Apologies, just realised I should have sent this to the developer mailing list. I'll do so now.
On Tue, 18 Feb 2025, 12:03 Lou Holland, <lou.holland@york.ac.uk <mailto:lou.holland@york.ac.uk>> wrote:
Hello,
Apologies if this is the wrong email address to contact about this. I am currently working on a privateer bundle for carbohydrate validation in chimeraX. At present, I have it so that the privateer tool will display SNFGs of glycans present in the structure using svgs displayed in a QWebEngineView().
I would like, if possible, on clicking elements of the svg to run a chimeraX command (view /chainID:resID) to centre the view window on the residue in question. At present, I can implement an onClick event to display the command that should be run, but haven't managed to figure out how to just run the command from within that QWebEngineView. Is there a mechanism already in place for doing something like this that I could take advantage of?
I'd considered using the "log html" to display the svgs in the log instead of the WebEngineView() so that I could take advantage of the href="cxcmd" functionality, but the svgs are long, with semicolons and new-line characters which interfere with this.
Best wishes, Lou Holland (Pronouns: they/them)
Research Associate York Structural Biology Laboratory, Department of Chemistry, University of York, Heslington, YO10 5DD, York, UK
_______________________________________________ ChimeraX-users mailing list -- chimerax-users@cgl.ucsf.edu To unsubscribe send an email to chimerax-users-leave@cgl.ucsf.edu Archives: https://mail.cgl.ucsf.edu/mailman/archives/list/chimerax-users@cgl.ucsf.edu/ _______________________________________________ ChimeraX-users mailing list -- chimerax-users@cgl.ucsf.edu To unsubscribe send an email to chimerax-users-leave@cgl.ucsf.edu Archives: https://mail.cgl.ucsf.edu/mailman/archives/list/chimerax-users@cgl.ucsf.edu/
participants (3)
-
Lou Holland
-
Tom Goddard
-
Tom Mulvaney