Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add execute_code #768

Merged
merged 2 commits into from
Feb 8, 2019
Merged

add execute_code #768

merged 2 commits into from
Feb 8, 2019

Conversation

hainm
Copy link
Collaborator

@hainm hainm commented Feb 8, 2019

Aim:

  • Quickly test new idea without recompile js code
  • JS user can play around with NGL in python.
code = """
var stage = this.stage;
var view = this.stage.viewer;
for (x in view){
    console.log(x)
}
"""

v._remote_call('execute_code', target='Widget', args=[code])

or using shortcut
v._execute_js_code(code)

@hainm hainm merged commit 422fa1d into nglviewer:master Feb 8, 2019
@hainm hainm deleted the execute_code branch February 8, 2019 05:56
@hainm
Copy link
Collaborator Author

hainm commented Feb 8, 2019

Some example:

Ligand viewer:

execute_code_ligand-viewer.txt (rename .txt to .ipynb)

code

@hainm
Copy link
Collaborator Author

hainm commented Feb 8, 2019

We can copy and paste any code from here: http://nglviewer.org/ngl/gallery/index.html
to quickly create view in the notebook. Make sure to replace

var stage = new NGL.Stage( "viewport" );

by

var stage = this.stage; // Using existing stage from Widget.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant