Python console support: Difference between revisions

From ASCEND
Jump to navigation Jump to search
No edit summary
No edit summary
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
<div class="pageexperimental">''This page documents an '''experimental''' feature. You can help out by '''testing it''' and <span class="plainlinks">[http://ascendwiki.cheme.cmu.edu/index.php?title=Python_console_support&action=edit recording]</span> your experiences.''</div>
{{experimental}}


When using the PyGTK GUI, press 'F12' to access an [http://ipython.scipy.org 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 <tt>browser</tt> which corresponds to the <tt>Browser</tt> class in the file <tt>pygtk/gtkbrowser.py</tt>. Using the prompt, try the following:
When using the PyGTK GUI, press 'F12' to access an [http://ipython.scipy.org 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 <tt>browser</tt> which corresponds to the <tt>Browser</tt> class in the file <tt>pygtk/gtkbrowser.py</tt>. Using the prompt, try the following:
Line 17: Line 17:
At present the GUI does not automatically update after each IPython command. We plan to fix this.
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 [http://ipython.scipy.org/moin/Cookbook/EmbeddingInGTK IPython wiki].
The approach used here is derived from a technique described on the [http://ipython.scipy.org/moin/Cookbook/EmbeddingInGTK 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.
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.


<div class="thumb tnone"><div class="thumbinner" style="width:402px;">[[Image:Ipython-embed.png]] <div class="thumbcaption"><div class="magnify">[[File:Ipython-embed.png|<img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" />]]</div>Screenshot of a short IPython session within ASCEND.</div></div></div>
[[Image:Ipython-embed.png|400px|thumb|none|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).
 
[[Category:Experimental]]

Latest revision as of 07:49, 26 May 2010

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.py and the .py and .h files in the pygtk directory of the source code.

Invalid language.

You need to specify a language like this: <source lang="html">...</source>

Supported languages for syntax highlighting:

a4c, abap, abc, abnf, actionscript, ada, agda, alan, algol, ampl, amtrix, applescript, arc, arm, as400cl, ascend, asciidoc, asp, aspect, assembler, ats, autohotkey, autoit, avenue, awk, ballerina, bat, bbcode, bcpl, bibtex, biferno, bison, blitzbasic, bms, bnf, boo, c, carbon, ceylon, charmm, chill, chpl, clean, clearbasic, clipper, clojure, clp, cmake, cobol, coffeescript, coldfusion, conf, cpp2, critic, crk, crystal, cs_block_regex, csharp, css, d, dart, delphi, diff, dockerfile, dts, dylan, ebnf, ebnf2, eiffel, elixir, elm, email, erb, erlang, euphoria, exapunks, excel, express, factor, fame, fasm, felix, fish, fortran77, fortran90, frink, fsharp, fstab, fx, gambas, gdb, gdscript, go, graphviz, haml, hare, haskell, haxe, hcl, html, httpd, hugo, icon, idl, idlang, inc_luatex, informix, ini, innosetup, interlis, io, jam, jasmin, java, javascript, js_regex, json, jsp, jsx, julia, kotlin, ldif, less, lhs, lilypond, limbo, lindenscript, lisp, logtalk, lotos, lotus, lua, luban, makefile, maple, markdown, matlab, maya, mercury, meson, miranda, mod2, mod3, modelica, moon, ms, msl, mssql, mxml, n3, nasal, nbc, nemerle, netrexx, nginx, nice, nim, nix, nsis, nxc, oberon, objc, ocaml, octave, oorexx, org, os, oz, paradox, pas, pdf, perl, php, pike, pl1, plperl, plpython, pltcl, po, polygen, pony, pov, powershell, pro, progress, ps, psl, pure, purebasic, purescript, pyrex, python, q, qmake, qml, qu, r, rebol, rego, rexx, rnc, rpg, rpl, rst, ruby, rust, s, sam, sas, scad, scala, scilab, scss, shellscript, slim, small, smalltalk, sml, snmp, snobol, solidity, spec, spn, sql, squirrel, styl, svg, swift, sybase, tcl, tcsh, terraform, tex, toml, tsql, tsx, ttcn3, txt, typescript, upc, vala, vb, verilog, vhd, vimscript, vue, wat, whiley, wren, xml, xpp, yaiff, yaml, yaml_ansible, yang, zig, znn

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: File missing
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).