Hi Eric and Tom,

Thanks for the pointers - I figured there was some kind of loop that needed to be kicked off.

I have modified the script to call `session.update_loop.start_redraw_timer()` before firing up the IPython shell.

I haven't noticed any unpredictability (yet) but I'm now able to directly evaluate Python code from Emacs and ChimeraX seems to behave like normal with 3D graphics!
This should save me a lot of time!

Thanks again,

Tom





From: "Eric Pettersen" <pett@cgl.ucsf.edu>
To: "Tom Mulvaney" <thomas.mulvaney@cssb-hamburg.de>
Cc: "ChimeraX Users Help" <chimerax-users@cgl.ucsf.edu>
Sent: Thursday, 21 October, 2021 23:54:23
Subject: Re: [chimerax-users] Running ChimeraX and a REPL

Hi Tom,
Your shell runs its own event loop, which prevents ChimeraX's normal event loop from running, which will make using the interface directly unpredictable.  For instance, the Model Panel never shows any models open.  The redrawing of the 3D graphics depends on a QTimer event, which it never receives, so it never gets drawn.  You can force it to draw however.  You can either use the "wait" command (I recommend "wait 2", i.e. draw two frames, which might be necessary to get the Rapid Access interface to disappear and a redraw to happen), or directly in Python with session.update_loop.draw_new_frame().
Note that you can concatenate commands by separating them with semi-colon (;), so you could open 1gcn and get the redraw with "open 1gcn ; wait 2".

--Eric

Eric Pettersen
UCSF Computer Graphics Lab


On Oct 21, 2021, at 4:00 AM, Tom Mulvaney via ChimeraX-users <chimerax-users@cgl.ucsf.edu> wrote:

Hi all,

I'm wondering if anyone has any experience running ChimeraX with either a standard REPL or IPython REPL?

ChimeraX already has a 'shell' tool that allows interacting with ChimeraX through a Python REPL which I've found invaluable for testing out ideas and poking around in ChimeraX in general.

It would be really nice though if I could send Python code directly from my IDE to be evaluated.  In order to make this work, it would be great if ChimeraX could be run from a terminal and provide a Python (or preferably IPython) REPL.  As it stands, I've managed to nearly make this work with the following script:

 import IPython.terminal.embed
 IPython.terminal.embed.embed()

I then run:

 ChimeraX --script repl.py

After typing, `%gui qt5`, the ChimeraX GUI appears.  

I can then interact with the REPL directly from the comfort of Emacs and evaluate things - but! - the main 3D view does not end up being displayed.

Does anyone know how to get the REPL and 3D stuff to work side-by-side?


Kind regards,

Tom

_______________________________________________
ChimeraX-users mailing list
ChimeraX-users@cgl.ucsf.edu
Manage subscription:
https://plato.cgl.ucsf.edu/mailman/listinfo/chimerax-users