Python console support

From ASCEND
Jump to: navigation, search
This page documents an experimental feature. Please tell us if you experience any problems.

When using the PyGTK GUI, press 'F12' to access an IPython prompt. This python prompt will allow you to access various scripting functionality in ASCEND. Currently the only object added to the console's namespace is browser which corresponds to the Browser class in the file pygtk/gtkbrowser.py. Using the prompt, try the following:

To see what is broadly possible under Python at present, take a look at test.pyalert! and the .py and .h files in the pygtkalert! directory of the source code.

M = browser.sim
M.T_amb
float(M.T_amb)
M.T_amb.setRealValue(350)
browser.modelview.refreshtree()
M.T_amb.setRealValueWithUnits(350,"R")
browser.modelview.refreshtree()

At present the GUI does not automatically update after each IPython command. We plan to fix this.

The approach used here is derived from a technique described on the IPython wiki. Note that the IPython console supports 'tab completion'... you can press tab any time during the input of a command to see available options.

We plan to improve the usability of the commands possible from the IPython console, hopefully to gradually approach the syntax of the Tcl/Tk 'Script' window.

Error creating thumbnail: convert: unable to open image `/srv/ascend/d/up/8/82/Ipython-embed.png': No such file or directory @ error/blob.c/OpenBlob/2638.
convert: unable to open file `/srv/ascend/d/up/8/82/Ipython-embed.png' @ error/png.c/ReadPNGImage/3667.
convert: no images defined `/tmp/transform_24db40e-1.png' @ error/convert.c/ConvertImageCommand/3044.
Screenshot of a short IPython session within ASCEND.

See also Plotting in ASCEND (the console can be used for customized plots in conjunction with Observer tabs).

Personal tools
Namespaces

Variants
Actions
Navigation
tools
Tools