| |
- exceptions.Exception(exceptions.BaseException)
-
- TDLError
- _MetaConsole(__builtin__.object)
-
- Console
- Window
class Console(_MetaConsole) |
|
The Console is the main class of the tdl library.
The console created by the init function is the root console and is the
consle that is rendered to the screen with flush.
Any console made from Console is an off-screen console that can be drawn
on and then blited to the root console. |
|
- Method resolution order:
- Console
- _MetaConsole
- __builtin__.object
Methods defined here:
- __del__(self)
- If the main console is garbage collected then the window will be closed as well
- __init__(self, width, height)
- __repr__(self)
- clear(self, fgcolor=(255, 255, 255), bgcolor=(0, 0, 0))
- Clears the entire console.
- getChar(self, x, y)
- Return the character and colors of a cell as (ch, fg, bg)
The charecter is returned as a number.
each color is returned as a tuple
Methods inherited from _MetaConsole:
- blit(self, source, x=0, y=0, width=None, height=None, srcx=0, srcy=0)
- Blit another console or Window onto the current console.
By default it blits the entire source to the topleft corner.
If nothing is blited then TDLError is raised
- drawChar(self, x, y, char=None, fgcolor=(255, 255, 255), bgcolor=(0, 0, 0))
- Draws a single character.
char 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.
For fgcolor and bgcolor you use a 3 item list or None. None will
keep the current color at this position unchanged.
Having the x or y values outside of the console will raise an
AssertionError.
- drawFrame(self, x, y, width, height, string=None, fgcolor=(255, 255, 255), bgcolor=(0, 0, 0))
- Similar to drawRect but only draws the outline of the rectangle
- drawRect(self, x, y, width, height, string=None, fgcolor=(255, 255, 255), bgcolor=(0, 0, 0))
- 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.
- drawStr(self, x, y, string, fgcolor=(255, 255, 255), bgcolor=(0, 0, 0))
- 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.
- getSize(self)
- Return the size of the console as (width, height)
- scroll(self, x, y)
- Scroll the contents of the console in the direction of x,y.
Uncovered areas will be cleared.
Data descriptors inherited from _MetaConsole:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
- height
- width
|
class Window(_MetaConsole) |
|
A Window contains a small isolated part of a Console.
Drawing on the Window draws on the Console.
Making a Window and setting its width or height to None will extend it to
the edge of the console. |
|
- Method resolution order:
- Window
- _MetaConsole
- __builtin__.object
Methods defined here:
- __init__(self, console, x, y, width, height)
- __repr__(self)
- clear(self, fgcolor=(255, 255, 255), bgcolor=(0, 0, 0))
- Clears the entire Window.
- getChar(self, x, y)
- Return the character and colors of a cell as (ch, fg, bg)
Data descriptors defined here:
- console
- parent
- x
- y
Methods inherited from _MetaConsole:
- blit(self, source, x=0, y=0, width=None, height=None, srcx=0, srcy=0)
- Blit another console or Window onto the current console.
By default it blits the entire source to the topleft corner.
If nothing is blited then TDLError is raised
- drawChar(self, x, y, char=None, fgcolor=(255, 255, 255), bgcolor=(0, 0, 0))
- Draws a single character.
char 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.
For fgcolor and bgcolor you use a 3 item list or None. None will
keep the current color at this position unchanged.
Having the x or y values outside of the console will raise an
AssertionError.
- drawFrame(self, x, y, width, height, string=None, fgcolor=(255, 255, 255), bgcolor=(0, 0, 0))
- Similar to drawRect but only draws the outline of the rectangle
- drawRect(self, x, y, width, height, string=None, fgcolor=(255, 255, 255), bgcolor=(0, 0, 0))
- 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.
- drawStr(self, x, y, string, fgcolor=(255, 255, 255), bgcolor=(0, 0, 0))
- 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.
- getSize(self)
- Return the size of the console as (width, height)
- scroll(self, x, y)
- Scroll the contents of the console in the direction of x,y.
Uncovered areas will be cleared.
Data descriptors inherited from _MetaConsole:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
- height
- width
| |