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

Class Console

source code

  object --+    
           |    
_BaseConsole --+
               |
              Console

Contains character and color data and can be drawn to.

The console created by the tdl.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 tdl._BaseConsole)
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 tdl._BaseConsole)
source code
 
__repr__(self)
repr(x)
source code
 
__setstate__(self, state) 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
(width, height)
get_size(self)
Return the size of the console as (width, height) (Inherited from tdl._BaseConsole)
source code
iter((x, y), ...)
scroll(self, x, y)
Scroll the contents of the console in the direction of x,y. (Inherited from tdl._BaseConsole)
source code

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

    Drawing Methods
 
blit(self, source, x=0, y=0, width=None, height=None, srcX=0, srcY=0)
Blit another console or Window onto the current console. (Inherited from tdl._BaseConsole)
source code
 
clear(self, fg=Ellipsis, bg=Ellipsis)
Clears the entire Console/Window.
source code
 
draw_char(self, x, y, char, fg=Ellipsis, bg=Ellipsis)
Draws a single character. (Inherited from tdl._BaseConsole)
source code
 
draw_frame(self, x, y, width, height, string, fg=Ellipsis, bg=Ellipsis)
Similar to draw_rect but only draws the outline of the rectangle. (Inherited from tdl._BaseConsole)
source code
 
draw_rect(self, x, y, width, height, string, fg=Ellipsis, bg=Ellipsis)
Draws a rectangle starting from x and y and extending to width and height. (Inherited from tdl._BaseConsole)
source code
 
draw_str(self, x, y, string, fg=Ellipsis, bg=Ellipsis)
Draws a string starting at x and y. (Inherited from tdl._BaseConsole)
source code
    Printing Methods
(x, y)
get_cursor(self)
Return the virtual cursor position. (Inherited from tdl._BaseConsole)
source code
 
move(self, x, y)
Move the virtual cursor. (Inherited from tdl._BaseConsole)
source code
 
print_str(self, string)
Print a string at the virtual cursor. (Inherited from tdl._BaseConsole)
source code
 
set_colors(self, fg=None, bg=None)
Sets the colors to be used with the print_str and draw_* methods. (Inherited from tdl._BaseConsole)
source code
 
set_mode(self, mode)
Configure how this console will react to the cursor writing past the end if the console. (Inherited from tdl._BaseConsole)
source code
 
write(self, string)
This method mimics basic file-like behaviour. (Inherited from tdl._BaseConsole)
source code
Instance Variables
  height
The height of this console in tiles. (Inherited from tdl._BaseConsole)
  tcod_console
Public interface to the cffi TCOD_console_t object of this instance.
  width
The width of this console in tiles. (Inherited from tdl._BaseConsole)
Properties

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, fg=Ellipsis, bg=Ellipsis)

source code 

Clears the entire Console/Window.

Unlike other drawing functions, fg and bg can not be None.

Parameters:
  • fg - Can not be None. See Drawing and Colors at the module level docs
  • bg - See fg
  • fg - Foreground color.

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

    Unlike most other operations you cannot use None here. To clear only the foreground or background use draw_rect.

  • bg - Background color. See fg.
Overrides: _BaseConsole.clear
(inherited documentation)

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: _BaseConsole.get_char
(inherited documentation)

Instance Variable Details

tcod_console

Public interface to the cffi TCOD_console_t object of this instance.

Feel free to pass this variable to libtcod-cffi calls but keep in mind that as soon as Console instance is garbage collected the tcod_console will be deleted.