console
pdwidgets.console
pdwidgets.console.py
Adapted from https://github.com/boochow/FBConsole
MIT License
Copyright (c) 2017 boochow, 2024 Brad Barnett
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Console(parent, fg=None, bg=None, visible=True, value=None, by_char=False, margin=1, text_height=TEXT_SIZE.LARGE, scale=1, font_data=None)
Bases: IOBase, Widget
Framebuffer text console with optional vertical scrolling.
Initialize a text console in the display's vertical scroll area.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parent
|
Widget
|
Parent widget (usually a :class: |
required |
fg
|
int | None
|
Default text color. |
None
|
bg
|
int | None
|
Console background color. |
None
|
visible
|
bool
|
Initial visibility. |
True
|
value
|
str | None
|
Unused; kept for :class: |
None
|
by_char
|
bool
|
When |
False
|
margin
|
int
|
Character margin in cells from the left edge. |
1
|
text_height
|
int
|
Romfont height ( |
LARGE
|
scale
|
int
|
Pixel scale factor for romfont glyphs. |
1
|
font_data
|
str | None
|
Alternate romfont data source. |
None
|
clear()
Erase the console and reset the text cursor.
draw()
Flush accumulated dirty console regions to the display.
readinto(buf, nbytes=0)
Read bytes into buf (io.IOBase interface).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
buf
|
bytearray
|
Destination buffer. |
required |
nbytes
|
int
|
Maximum bytes to read. |
0
|
Returns:
| Type | Description |
|---|---|
int | None
|
int | None: Number of bytes read, or |
write(buf, fg=None, bg=None)
Write text to the console (io.IOBase interface).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
buf
|
bytes | str
|
Text or bytes to render. |
required |
fg
|
int | None
|
Foreground color override. |
None
|
bg
|
int | None
|
Background color override. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
Number of bytes written. |