Opened 8 years ago

Closed 8 years ago

#735 closed enhancement (fixed)

Need access to Python from Javascript in HTML pages

Reported by: Conrad Huang Owned by: Conrad Huang
Priority: blocker Milestone: 0.5
Component: Help System Version:
Keywords: Cc:
Blocked By: Blocking:
Notify when closed: Platform: all
Project: ChimeraX

Description

Using HTML pages as UI for tools may sometimes require access to ChimeraX state from the HTML page. For example, the toolshed app page should display "Install" for uninstalled bundles, "Update" if the installed bundle is older, or "Reinstall" if the installed bundle is the same as the latest.

A possible way to do this is QWebChannel. See attached files for example of how it can be implemented. For each chimerax.core.ui.widgets.htmlview.ChimeraXHtmlView instance, we can create a web channel with which custom QObject instances may be registered. Once registered, the custom QObject can be referenced from Javascript using the same API. We also need to define a *class* method to register objects since we frequently want access to the same functionality in different viewers. If we keep a weakref list of created ChimeraXHtmlView instances, the class method can register objects with all of them.

Attachments (2)

test.html (634 bytes ) - added by Conrad Huang 8 years ago.
test.py (696 bytes ) - added by Conrad Huang 8 years ago.

Download all attachments as: .zip

Change History (5)

by Conrad Huang, 8 years ago

Attachment: test.html added

by Conrad Huang, 8 years ago

Attachment: test.py added

comment:1 by Conrad Huang, 8 years ago

Owner: set to Conrad Huang
Status: newaccepted

comment:2 by Eric Pettersen, 8 years ago

Milestone: Beta Release0.5

Milestone renamed

comment:3 by Conrad Huang, 8 years ago

Resolution: fixed
Status: acceptedclosed

See tutorial GUI example

Note: See TracTickets for help on using tickets.