Package untdl :: Class Console
[frames] | no frames]

Class Console

source code

  object --+    
           |    
_MetaConsole --+
               |
              Console

Contains character and color data and can be drawn to.

The console created by the untdl.init function is the root console and is the console that is rendered to the screen with flush.

Any console created from the Console class is an off-screen console that can be drawn on before being blit to the root console.

Instance Methods
 
__contains__(self, position)
Use ((x, y) in console) to check if a position is drawable on this console. (Inherited from untdl._MetaConsole)
source code
 
__copy__(self) source code
 
__del__(self)
If the main console is garbage collected then the window will be closed as well
source code
 
__getstate__(self) source code
 
__init__(self, width, height)
Create a new offscreen console.
source code
iter((x, y), ...)
__iter__(self)
Return an iterator with every possible (x, y) value for this console. (Inherited from untdl._MetaConsole)
source code
 
__repr__(self)
repr(x)
source code
 
__setstate__(self, state) source code
 
blit(self, source, x=0, y=0, width=None, height=None, src_x=0, src_y=0)
Blit another console or Window onto the current console. (Inherited from untdl._MetaConsole)
source code
 
clear(self, fgcolor=(0, 0, 0), bgcolor=(0, 0, 0))
Clears the entire Console.
source code
 
draw_char(self, x, y, char, fgcolor=(255, 255, 255), bgcolor=(0, 0, 0))
Draws a single character. (Inherited from untdl._MetaConsole)
source code
 
draw_frame(self, x, y, width, height, string, fgcolor=(255, 255, 255), bgcolor=(0, 0, 0))
Similar to draw_rect but only draws the outline of the rectangle. (Inherited from untdl._MetaConsole)
source code
 
draw_rect(self, x, y, width, height, string, fgcolor=(255, 255, 255), bgcolor=(0, 0, 0))
Draws a rectangle starting from x and y and extending to width and height. (Inherited from untdl._MetaConsole)
source code
 
draw_str(self, x, y, string, fgcolor=(255, 255, 255), bgcolor=(0, 0, 0))
Draws a string starting at x and y. (Inherited from untdl._MetaConsole)
source code
(int, (r, g, b), (r, g, b))
get_char(self, x, y)
Return the character and colors of a tile as (ch, fg, bg)
source code
(x, y)
get_cursor(self)
Return the virtual cursor position. (Inherited from untdl._MetaConsole)
source code
(width, height)
get_size(self)
Return the size of the console as (width, height) (Inherited from untdl._MetaConsole)
source code
 
move(self, x, y)
Move the virtual cursor. (Inherited from untdl._MetaConsole)
source code
 
print_str(self, string)
Print a string at the virtual cursor. (Inherited from untdl._MetaConsole)
source code
iter((x, y), ...)
scroll(self, x, y)
Scroll the contents of the console in the direction of x,y. (Inherited from untdl._MetaConsole)
source code
 
set_colors(self, fg=None, bg=None)
Sets the colors to be used with the print_str function. (Inherited from untdl._MetaConsole)
source code
 
set_mode(self, mode)
Configure how this console will react to the cursor writing past the end if the console. (Inherited from untdl._MetaConsole)
source code
 
write(self, string)
This method mimics basic file-like behaviour. (Inherited from untdl._MetaConsole)
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties
  _as_parameter_
  console (Inherited from untdl._MetaConsole)
  height (Inherited from untdl._MetaConsole)
  width (Inherited from untdl._MetaConsole)

Inherited from object: __class__

Method Details

__init__(self, width, height)
(Constructor)

source code 

Create a new offscreen console.

Parameters:
  • width (int) - Width of the console in tiles
  • height (int) - Height of the console in tiles
Overrides: object.__init__

__repr__(self)
(Representation operator)

source code 

repr(x)

Overrides: object.__repr__
(inherited documentation)

clear(self, fgcolor=(0, 0, 0), bgcolor=(0, 0, 0))

source code 

Clears the entire Console.

Parameters:
  • fgcolor ((r, g, b)) - Foreground color.

    Must be a 3-item list with integers that range 0-255.

    Unlike most other operations you cannot use None here.

  • bgcolor ((r, g, b)) - Background color. See fgcolor.

get_char(self, x, y)

source code 

Return the character and colors of a tile as (ch, fg, bg)

This method runs very slowly as is not recommended to be called frequently.

Returns: (int, (r, g, b), (r, g, b))
Returns a 3-item tuple. The first item is an integer of the character at the position (x, y) the second and third are the foreground and background colors respectfully.
Overrides: _MetaConsole.get_char
(inherited documentation)