Package tdl :: 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 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._MetaConsole)
source code
 
__del__(self)
If the main console is garbage collected then the window will be closed as well
source code
 
__init__(self, width, height)
Create a new offscreen console.
source code
 
__repr__(self)
repr(x)
source code
 
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._MetaConsole)
source code
 
clear(self, fgcolor=(255, 255, 255), bgcolor=(0, 0, 0))
Clears the entire Console.
source code
 
drawChar(self, x, y, char, fgcolor=(255, 255, 255), bgcolor=(0, 0, 0))
Draws a single character. (Inherited from tdl._MetaConsole)
source code
 
drawFrame(self, x, y, width, height, string, fgcolor=(255, 255, 255), bgcolor=(0, 0, 0))
Similar to drawRect but only draws the outline of the rectangle. (Inherited from tdl._MetaConsole)
source code
 
drawRect(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 tdl._MetaConsole)
source code
 
drawStr(self, x, y, string, fgcolor=(255, 255, 255), bgcolor=(0, 0, 0))
Draws a string starting at x and y. (Inherited from tdl._MetaConsole)
source code
(int, (r, g, b), (r, g, b))
getChar(self, x, y)
Return the character and colors of a tile as (ch, fg, bg)
source code
(int, int)
getSize(self)
Return the size of the console as (width, height) (Inherited from tdl._MetaConsole)
source code
 
scroll(self, x, y)
Scroll the contents of the console in the direction of x,y. (Inherited from tdl._MetaConsole)
source code

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

Properties
  _as_parameter_
  console (Inherited from tdl._MetaConsole)
  height (Inherited from tdl._MetaConsole)
  width (Inherited from tdl._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=(255, 255, 255), 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 can not use None here.

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

getChar(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.getChar
(inherited documentation)