Package SimPy :: Module tkconsole :: Class Console

[hide private]
[frames] | no frames]

# Class Console

source code

      Tkinter.Misc --+
                     |
    Tkinter.BaseWidget --+
                         |
          Tkinter.Pack --+
                         |
         Tkinter.Place --+
                         |
          Tkinter.Grid --+
                         |
            Tkinter.Widget --+
                             |
                 Tkinter.Frame --+
                                 |
                                Console

Nested Classes | [hide private]

Inherited from `Tkinter.Misc`: `getdouble`, `getint`

Instance Methods | [hide private]

`` | __init__(self, parent=None, dict={}, **options) Construct from a parent widget, an optional dictionary to use as the namespace for execution, and any configuration options.
`` | __getitem__(self, key) Return the resource value for a KEY given as string.
`` | __setitem__(self, key, value)
`` | config(self, *args, **dict) Get or set configuration options in a Tkinter-like style.
`` | trim(self, command) Trim any matching prefix from the given command line, returning the amount trimmed and the trimmed result.
`` | getline(self, line=None, trim=0) Return the command on the current line.
`` | cursor(self) Get the current line and position of the cursor.
`` | write(self, data, tag=None) Show output from stdout or stderr in the console.
`` | cb_back(self, event) Step back in the history.
`` | cb_forward(self, event) Step forward in the history.
`` | recall(self, command=None) Show a command from the history on the current line.
`` | precontext(self)
`` | cb_complete(self, event) Attempt to complete the identifier currently being typed.
`` | postmenus(self, keys, skip, cut, object) Post a series of menus listing all the given keys, given the length of the existing part so we can position the menus under the cursor, and the index at which to insert the completion.
`` | unpostmenus(self) Unpost the completion menus.
`` | cb_cleanup(self, event=None)
`` | cb_select(self, event) Handle a menu selection event.
`` | cb_help(self, event)
`` | cb_position(self, event) Avoid moving into the prompt area.
`` | cb_backspace(self, event)
`` | cb_space(self, event)
`` | cb_home(self, event) Go to the first non-whitespace character in the line.
`` | cb_ctrlhome(self, event) Go to the beginning of the line just after the prompt.
`` | cb_nothing(self, event)
`` | cb_return(self, event, doindent=1) Handle a <Return> keystroke by running from the current line and generating a new prompt.
`` | autoindent(self, command)
`` | cb_paste(self, event) Handle a paste event (middle-click) in the text box.
`` | runline(self, line) Run some source code given the number of the last line in the text box.
`` | compile(self, source) Try to compile a piece of source code, returning a status code and the compiled result.
`` | run(self, code) Run a code object within the sandbox for this console.

Inherited from `Tkinter.BaseWidget`: `destroy`

Inherited from `Tkinter.BaseWidget` (private): `_do`, `_setup`

Inherited from `Tkinter.Misc`: `__str__`, `after`, `after_cancel`, `after_idle`, `bbox`, `bell`, `bind`, `bind_all`, `bind_class`, `bindtags`, `cget`, `clipboard_append`, `clipboard_clear`, `colormodel`, `columnconfigure`, `configure`, `deletecommand`, `event_add`, `event_delete`, `event_generate`, `event_info`, `focus`, `focus_displayof`, `focus_force`, `focus_get`, `focus_lastfor`, `focus_set`, `getboolean`, `getvar`, `grab_current`, `grab_release`, `grab_set`, `grab_set_global`, `grab_status`, `grid_bbox`, `grid_columnconfigure`, `grid_location`, `grid_propagate`, `grid_rowconfigure`, `grid_size`, `grid_slaves`, `image_names`, `image_types`, `keys`, `lift`, `lower`, `mainloop`, `nametowidget`, `option_add`, `option_clear`, `option_get`, `option_readfile`, `pack_propagate`, `pack_slaves`, `place_slaves`, `propagate`, `quit`, `register`, `rowconfigure`, `selection_clear`, `selection_get`, `selection_handle`, `selection_own`, `selection_own_get`, `send`, `setvar`, `size`, `slaves`, `tk_bisque`, `tk_focusFollowsMouse`, `tk_focusNext`, `tk_focusPrev`, `tk_menuBar`, `tk_setPalette`, `tk_strictMotif`, `tkraise`, `unbind`, `unbind_all`, `unbind_class`, `update`, `update_idletasks`, `wait_variable`, `wait_visibility`, `wait_window`, `waitvar`, `winfo_atom`, `winfo_atomname`, `winfo_cells`, `winfo_children`, `winfo_class`, `winfo_colormapfull`, `winfo_containing`, `winfo_depth`, `winfo_exists`, `winfo_fpixels`, `winfo_geometry`, `winfo_height`, `winfo_id`, `winfo_interps`, `winfo_ismapped`, `winfo_manager`, `winfo_name`, `winfo_parent`, `winfo_pathname`, `winfo_pixels`, `winfo_pointerx`, `winfo_pointerxy`, `winfo_pointery`, `winfo_reqheight`, `winfo_reqwidth`, `winfo_rgb`, `winfo_rootx`, `winfo_rooty`, `winfo_screen`, `winfo_screencells`, `winfo_screendepth`, `winfo_screenheight`, `winfo_screenmmheight`, `winfo_screenmmwidth`, `winfo_screenvisual`, `winfo_screenwidth`, `winfo_server`, `winfo_toplevel`, `winfo_viewable`, `winfo_visual`, `winfo_visualid`, `winfo_visualsavailable`, `winfo_vrootheight`, `winfo_vrootwidth`, `winfo_vrootx`, `winfo_vrooty`, `winfo_width`, `winfo_x`, `winfo_y`

Inherited from `Tkinter.Misc` (private): `_bind`, `_configure`, `_displayof`, `_getboolean`, `_getdoubles`, `_getints`, `_grid_configure`, `_nametowidget`, `_options`, `_register`, `_report_exception`, `_root`, `_substitute`

Inherited from `Tkinter.Pack`: `forget`, `info`, `pack`, `pack_configure`, `pack_forget`, `pack_info`

Inherited from `Tkinter.Place`: `place`, `place_configure`, `place_forget`, `place_info`

Inherited from `Tkinter.Grid`: `grid`, `grid_configure`, `grid_forget`, `grid_info`, `grid_remove`, `location`

Class Variables | [hide private]

Inherited from `Tkinter.Misc`: `_noarg_` Inherited from `Tkinter.Misc` (private): `_subst_format`, `_subst_format_str`, `_tclCommands`

Method Details | [hide private]

### __init__(self, parent=None, dict={}, **options)
(Constructor)

source code

Construct from a parent widget, an optional dictionary to use as the namespace for execution, and any configuration options.

  Overrides: Tkinter.Frame.__init__

### __getitem__(self, key)
(Indexing operator)

source code

Return the resource value for a KEY given as string.

  Overrides: Tkinter.Misc.cget
    (inherited documentation)

### __setitem__(self, key, value)
(Index assignment operator)

source code

None

  Overrides: Tkinter.Misc.__setitem__

### config(self, *args, **dict)

source code

Get or set configuration options in a Tkinter-like style.

  Overrides: Tkinter.Misc.configure

### trim(self, command)

source code

Trim any matching prefix from the given command line, returning the amount trimmed and the trimmed result.

### getline(self, line=None, trim=0)

source code

Return the command on the current line.

### cursor(self)

source code

Get the current line and position of the cursor.

### write(self, data, tag=None)

source code

Show output from stdout or stderr in the console.

### cb_back(self, event)

source code

Step back in the history.

### cb_forward(self, event)

source code

Step forward in the history.

### recall(self, command=None)

source code

Show a command from the history on the current line.

### precontext(self)

source code

None

### cb_complete(self, event)

source code

Attempt to complete the identifier currently being typed.

### postmenus(self, keys, skip, cut, object)

source code

Post a series of menus listing all the given keys, given the length of the existing part so we can position the menus under the cursor, and the index at which to insert the completion.

### unpostmenus(self)

source code

Unpost the completion menus.

### cb_cleanup(self, event=None)

source code

None

### cb_select(self, event)

source code

Handle a menu selection event. We have to check and invoke the completion menus manually because we are grabbing events to give the text box keyboard focus.

### cb_help(self, event)

source code

None

### cb_position(self, event)

source code

Avoid moving into the prompt area.

### cb_backspace(self, event)

source code

None

### cb_space(self, event)

source code

None

### cb_home(self, event)

source code

Go to the first non-whitespace character in the line.

### cb_ctrlhome(self, event)

source code

Go to the beginning of the line just after the prompt.

### cb_nothing(self, event)

source code

None

### cb_return(self, event, doindent=1)

source code

Handle a <Return> keystroke by running from the current line and generating a new prompt.

### autoindent(self, command)

source code

None

### cb_paste(self, event)

source code

Handle a paste event (middle-click) in the text box. Pasted text has any leading Python prompts stripped (at last!!).

### runline(self, line)

source code

Run some source code given the number of the last line in the text box. Scan backwards to get the entire piece of code to run if the line is a continuation of previous lines. Tag the compiled code so that it can be highlighted according to whether it is complete, incomplete, or illegal.

### compile(self, source)

source code

Try to compile a piece of source code, returning a status code and the compiled result. If the status code is "okay" the code is complete and compiled successfully; if it is "more" then the code can be compiled, but an interactive session should wait for more input; if it is "bad" then there is a syntax error in the code and the second returned value is the error message.

### run(self, code)

source code

Run a code object within the sandbox for this console. The sandbox redirects stdout and stderr to the console, and executes within the namespace associated with the console.