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

# Class Window

source code

      object --+
               |
    _BaseConsole --+
                   |
                  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._BaseConsole) | 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._BaseConsole) | source code
__repr__(self) repr(x) | source code
drawChar(*args, **kargs) Deprecated version of the function draw_char, you should prefer calling that function instead of this one. | source code
drawFrame(*args, **kargs) Deprecated version of the function draw_frame, you should prefer calling that function instead of this one. | source code
drawRect(*args, **kargs) Deprecated version of the function draw_rect, you should prefer calling that function instead of this one. | 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
(width, height) |
get_size(self) Return the size of the console as (width, height) (Inherited from tdl._BaseConsole) | source code
iter((x, y), ...) |
scroll(self, x, y) Scroll the contents of the console in the direction of x,y. (Inherited from tdl._BaseConsole) | source code
Inherited from `object`: `__delattr__`, `__format__`, `__getattribute__`, `__hash__`, `__new__`, `__reduce__`, `__reduce_ex__`, `__setattr__`, `__sizeof__`, `__str__`, `__subclasshook__`
Drawing Methods
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._BaseConsole) | source code
clear(self, fg=Ellipsis, bg=Ellipsis) Clears the entire Console/Window. | source code
draw_char(self, x, y, char, fg=Ellipsis, bg=Ellipsis) Draws a single character. | source code
draw_frame(self, x, y, width, height, string, fg=Ellipsis, bg=Ellipsis) Similar to draw_rect but only draws the outline of the rectangle. | source code
draw_rect(self, x, y, width, height, string, fg=Ellipsis, bg=Ellipsis) Draws a rectangle starting from x and y and extending to width and height. | source code
draw_str(self, x, y, string, fg=Ellipsis, bg=Ellipsis) Draws a string starting at x and y. (Inherited from tdl._BaseConsole) | source code
Printing Methods
(x, y) |
get_cursor(self) Return the virtual cursor position. (Inherited from tdl._BaseConsole) | source code
move(self, x, y) Move the virtual cursor. (Inherited from tdl._BaseConsole) | source code
print_str(self, string) Print a string at the virtual cursor. (Inherited from tdl._BaseConsole) | source code
set_colors(self, fg=None, bg=None) Sets the colors to be used with the print_str and draw_* methods. (Inherited from tdl._BaseConsole) | source code
set_mode(self, mode) Configure how this console will react to the cursor writing past the end if the console. (Inherited from tdl._BaseConsole) | source code
write(self, string) This method mimics basic file-like behaviour. (Inherited from tdl._BaseConsole) | source code

Instance Variables
| height The height of this console in tiles. (Inherited from tdl._BaseConsole)
| width The width of this console in tiles. (Inherited from tdl._BaseConsole)

Properties
| parent
| 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, fg=Ellipsis, bg=Ellipsis) | source code
Clears the entire Console/Window. Unlike other drawing functions, fg and bg can not be None. Parameters: `fg` - Can not be None. See Drawing and Colors at the module level docs `bg` - See fg `fg` - Foreground color. Must be a 3-item list with integers that range 0-255. Unlike most other operations you cannot use None here. To clear only the foreground or background use draw_rect. `bg` - Background color. See fg. Overrides: _BaseConsole.clear (inherited documentation)

### drawChar(*args, **kargs) | source code
Deprecated version of the function draw_char, you should prefer calling that function instead of this one. Overrides: _BaseConsole.drawChar

### drawFrame(*args, **kargs) | source code
Deprecated version of the function draw_frame, you should prefer calling that function instead of this one. Overrides: _BaseConsole.drawFrame

### drawRect(*args, **kargs) | source code
Deprecated version of the function draw_rect, you should prefer calling that function instead of this one. Overrides: _BaseConsole.drawRect

### draw_char(self, x, y, char, fg=Ellipsis, bg=Ellipsis) | 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. `fg` - See Drawing and Colors at the module level docs `bg` - See Drawing and Colors at the module level docs 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: _BaseConsole.draw_char (inherited documentation)

### draw_frame(self, x, y, width, height, string, fg=Ellipsis, bg=Ellipsis) | 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 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. `fg` - See Drawing and Colors at the module level docs `bg` - See Drawing and Colors at the module level docs 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: _BaseConsole.draw_frame (inherited documentation)

### draw_rect(self, x, y, width, height, string, fg=Ellipsis, bg=Ellipsis) | 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. `fg` - See Drawing and Colors at the module level docs `bg` - See Drawing and Colors at the module level docs 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: _BaseConsole.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: _BaseConsole.get_char (inherited documentation)