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

Class _MetaConsole

source code

object --+
         |
        _MetaConsole
Known Subclasses:

Contains methods shared by both the Console and Window classes.

Instance Methods
 
__contains__(self, position)
Use ((x, y) in console) to check if a position is drawable on this console.
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.
source code
 
drawChar(self, x, y, char, fgcolor=(255, 255, 255), bgcolor=(0, 0, 0))
Draws a single character.
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.
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.
source code
 
drawStr(self, x, y, string, fgcolor=(255, 255, 255), bgcolor=(0, 0, 0))
Draws a string starting at x and y.
source code
(int, int)
getSize(self)
Return the size of the console as (width, height)
source code
 
scroll(self, x, y)
Scroll the contents of the console in the direction of x,y.
source code

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

Properties
  height
  width

Inherited from object: __class__

Method Details

blit(self, source, x=0, y=0, width=None, height=None, srcX=0, srcY=0)

source code 

Blit another console or Window onto the current console.

By default it blits the entire source to the topleft corner.

Parameters:
  • width (int or None)
  • height (int or None)
  • source (Console or Window)
  • y (int)
  • x (int)
  • srcX (int)
  • srcY (int)

drawChar(self, x, y, char, fgcolor=(255, 255, 255), bgcolor=(0, 0, 0))

source code 

Draws a single character.

Parameters:
  • char (int, string, or None) - Should be an integer, single character string, or None.

    You can set the char parameter as None if you only want to change the colors of the tile.

  • fgcolor (3-item list or None) - For fgcolor and bgcolor you use a 3 item list with integers ranging 0 - 255 or None. None will keep the current color at this position unchanged.
  • y (int)
  • x (int)
  • bgcolor (3-item list or None)
Raises:
  • AssertionError - Having the x or y values outside of the console will raise an AssertionError. You can use ((x, y) in console) to check if a cell is drawable.

drawFrame(self, x, y, width, height, string, fgcolor=(255, 255, 255), bgcolor=(0, 0, 0))

source code 

Similar to drawRect but only draws the outline of the rectangle.

Parameters:
  • string (int, string, or None)
  • bgcolor (3-item list or None)
  • height (int or None)
  • width (int or None)
  • y (int)
  • x (int)
  • fgcolor (3-item list or None)

drawRect(self, x, y, width, height, string, fgcolor=(255, 255, 255), bgcolor=(0, 0, 0))

source code 

Draws a rectangle starting from x and y and extending to width and height. If width or height are None then it will extend to the edge of the console. The rest are the same as drawChar.

Parameters:
  • string (int, string, or None)
  • bgcolor (3-item list or None)
  • height (int or None)
  • width (int or None)
  • y (int)
  • x (int)
  • fgcolor (3-item list or None)

drawStr(self, x, y, string, fgcolor=(255, 255, 255), bgcolor=(0, 0, 0))

source code 

Draws a string starting at x and y. Optinally colored.

A string that goes past the right side will wrap around. A string wraping to below the console will raise a TDLError but will still be written out. This means you can safely ignore the errors with a try... except block if you're fine with partily written strings.

\r and \n are drawn on the console as normal character tiles. No special encoding is done and any string will translate to the character table as is.

fgcolor and bgcolor can be set to None to keep the colors unchanged.

Parameters:
  • y (int)
  • x (int)
  • string (string or iterable)
  • bgcolor (3-item list or None)
  • fgcolor (3-item list or None)

scroll(self, x, y)

source code 

Scroll the contents of the console in the direction of x,y.

Uncovered areas will be cleared.

Parameters:
  • y (int)
  • x (int)