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

# Class Window

source code

      object --+
               |
    _MetaConsole --+
                   |
                  Window

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.

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
__init__(self, console, x, y, width, height) Isolate part of a Console or Window instance. | source code
iter((x, y), ...) |
__iter__(self) Return an iterator with every possible (x, y) value for this console. (Inherited from tdl._MetaConsole) | 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=`(`0`,` 0`,` 0`)`, bgcolor=`(`0`,` 0`,` 0`)`) Clears the entire Window. | 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. (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
(x, y) |
getCursor(self) Return the virtual cursor position. (Inherited from tdl._MetaConsole) | source code
(width, height) |
getSize(self) Return the size of the console as (width, height) (Inherited from tdl._MetaConsole) | source code
move(self, x, y) Move the virtual cursor. (Inherited from tdl._MetaConsole) | source code
printStr(self, string) Print a string at the virtual cursor. (Inherited from tdl._MetaConsole) | source code
iter((x, y), ...) |
scroll(self, x, y) Scroll the contents of the console in the direction of x,y. (Inherited from tdl._MetaConsole) | source code
setColors(self, fg=None, bg=None) Sets the colors to be used with the printStr function. (Inherited from tdl._MetaConsole) | source code
setMode(self, mode) Configure how this console will react to the cursor writing past the end if the console. (Inherited from tdl._MetaConsole) | source code
write(self, string) This method mimics basic file-like behaviour. (Inherited from tdl._MetaConsole) | source code
Inherited from `object`: `__delattr__`, `__format__`, `__getattribute__`, `__hash__`, `__new__`, `__reduce__`, `__reduce_ex__`, `__setattr__`, `__sizeof__`, `__str__`, `__subclasshook__`

Properties
| console (Inherited from tdl._MetaConsole)
| height (Inherited from tdl._MetaConsole)
| parent
| width (Inherited from tdl._MetaConsole)
| x
| y
Inherited from `object`: `__class__`

Method Details

### __init__(self, console, x, y, width, height) (Constructor) | source code
Isolate part of a Console or Window instance. Parameters: `console` (Console or Window) - The parent object which can be a Console or another Window instance. `x` (int) - X coordinate to place the Window. This follows the normal rules for indexing so you can use a negative integer to place the Window relative to the bottom right of the parent Console instance. `y` (int) - Y coordinate to place the Window. See x. `width` (int or None) - Width of the Window. Can be None to extend as far as possible to the bottom right corner of the parent Console or can be a negative number to be sized reltive to the Consoles total size. `height` (int or None) - Height of the Window. See width. 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 Window. 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.

### drawChar(self, x, y, char, fgcolor=`(`255`,` 255`,` 255`)`, bgcolor=`(`0`,` 0`,` 0`)`) | source code
Draws a single character. Parameters: `x` - X coordinate to draw at. `y` - Y coordinate to draw at. `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. `fgcolor` - 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. `bgcolor` - Background color. See fgcolor Raises: `AssertionError` - Having x or y values that can't be placed inside of the console will raise an AssertionError. You can use always use ((x, y) in console) to check if a tile is drawable. Overrides: _MetaConsole.drawChar (inherited documentation)

### 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: `x` - x coordinate to draw at. `y` - y coordinate to draw at. `width` - Width of the rectangle. Can be None to extend to the bottom right of the console or can be a negative number to be sized reltive to the total size of the console. `height` - Height of the rectangle. See width. `string` - 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 an area. `fgcolor` - 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. `bgcolor` - Background color. See fgcolor Raises: `AssertionError` - Having x or y values that can't be placed inside of the console will raise an AssertionError. You can use always use ((x, y) in console) to check if a tile is drawable. Overrides: _MetaConsole.drawFrame (inherited documentation)

### 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. Parameters: `x` - x coordinate to draw at. `y` - y coordinate to draw at. `width` - Width of the rectangle. Can be None to extend to the bottom right of the console or can be a negative number to be sized reltive to the total size of the console. `height` - Height of the rectangle. See width. `string` - 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 an area. `fgcolor` - 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. `bgcolor` - Background color. See fgcolor Raises: `AssertionError` - Having x or y values that can't be placed inside of the console will raise an AssertionError. You can use always use ((x, y) in console) to check if a tile is drawable. Overrides: _MetaConsole.drawRect (inherited documentation)

### 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)