untdl.Window

Package untdl :: 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 untdl._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 untdl._MetaConsole) | source code
__repr__(self) repr(x) | source code
blit(self, source, x=0, y=0, width=None, height=None, src_x=0, src_y=0) Blit another console or Window onto the current console. (Inherited from untdl._MetaConsole) | source code
clear(self, fgcolor=`(`0`,` 0`,` 0`)`, bgcolor=`(`0`,` 0`,` 0`)`) Clears the entire Window. | source code
draw_char(self, x, y, char, fgcolor=`(`255`,` 255`,` 255`)`, bgcolor=`(`0`,` 0`,` 0`)`) Draws a single character. | source code
draw_frame(self, x, y, width, height, string, fgcolor=`(`255`,` 255`,` 255`)`, bgcolor=`(`0`,` 0`,` 0`)`) Similar to draw_rect but only draws the outline of the rectangle. | source code
draw_rect(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
draw_str(self, x, y, string, fgcolor=`(`255`,` 255`,` 255`)`, bgcolor=`(`0`,` 0`,` 0`)`) Draws a string starting at x and y. (Inherited from untdl._MetaConsole) | 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
(x, y) |
get_cursor(self) Return the virtual cursor position. (Inherited from untdl._MetaConsole) | source code
(width, height) |
get_size(self) Return the size of the console as (width, height) (Inherited from untdl._MetaConsole) | source code
move(self, x, y) Move the virtual cursor. (Inherited from untdl._MetaConsole) | source code
print_str(self, string) Print a string at the virtual cursor. (Inherited from untdl._MetaConsole) | source code
iter((x, y), ...) |
scroll(self, x, y) Scroll the contents of the console in the direction of x,y. (Inherited from untdl._MetaConsole) | source code
set_colors(self, fg=None, bg=None) Sets the colors to be used with the print_str function. (Inherited from untdl._MetaConsole) | source code
set_mode(self, mode) Configure how this console will react to the cursor writing past the end if the console. (Inherited from untdl._MetaConsole) | source code
write(self, string) This method mimics basic file-like behaviour. (Inherited from untdl._MetaConsole) | source code
Inherited from `object`: `__delattr__`, `__format__`, `__getattribute__`, `__hash__`, `__new__`, `__reduce__`, `__reduce_ex__`, `__setattr__`, `__sizeof__`, `__str__`, `__subclasshook__`

Properties
| console (Inherited from untdl._MetaConsole)
| height (Inherited from untdl._MetaConsole)
| parent
| width (Inherited from untdl._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 relative 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.

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

### draw_frame(self, x, y, width, height, string, fgcolor=`(`255`,` 255`,` 255`)`, bgcolor=`(`0`,` 0`,` 0`)`) | source code
Similar to draw_rect 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 relative 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.draw_frame (inherited documentation)

### draw_rect(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 relative 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.draw_rect (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: _MetaConsole.get_char (inherited documentation)