pyguiadapter.adapter.uoutput
模块级方法
uprint(*args: Any, sep: str = ' ', end: str = '\n', html: bool = False, scroll_to_bottom: bool = True) -> None
打印信息到输出浏览器
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*args |
Any
|
要打印的信息 |
()
|
sep |
str
|
每条信息之间的分隔字符串 |
' '
|
end |
str
|
添加到最后一条信息后面的字符串 |
'\n'
|
html |
bool
|
要打印的信息是否为 |
False
|
scroll_to_bottom |
bool
|
打印信息后是否将 |
True
|
Returns:
Type | Description |
---|---|
None
|
无返回值 |
clear_output() -> None
清除输出浏览器
中所有内容
Returns:
Type | Description |
---|---|
None
|
无返回值 |
print_image(img: Union[str, bytes], img_type: str = 'jpeg', embed_base64: bool = False, width: Optional[int] = None, height: Optional[int] = None, centered: bool = True) -> None
模块级函数。打印图片。
Parameters:
Name | Type | Description | Default |
---|---|---|---|
img |
Union[str, bytes]
|
待打印的图片。可以为图片文件的路径( |
required |
img_type |
str
|
图片类型。 |
'jpeg'
|
embed_base64 |
bool
|
是否使用 |
False
|
width |
Optional[int]
|
图片的宽度。若未指定,则显示图片的原始宽度。 |
None
|
height |
Optional[int]
|
图片的高度。若未指定,则显示图片的原始高度。 |
None
|
centered |
bool
|
是否将图片居中显示。 |
True
|
Returns:
Type | Description |
---|---|
None
|
无返回值。 |
info(msg: str) -> None
模块级函数。打印info
级别的消息。info
消息颜色值默认为:#00FF00
。
Parameters:
Name | Type | Description | Default |
---|---|---|---|
msg |
str
|
要打印的消息 |
required |
Returns:
Type | Description |
---|---|
None
|
无返回值 |
debug(msg: str) -> None
模块级函数。打印debug
级别的消息。debug
消息颜色值默认为:#909399
。
Parameters:
Name | Type | Description | Default |
---|---|---|---|
msg |
str
|
要打印的消息 |
required |
Returns:
Type | Description |
---|---|
None
|
无返回值 |
warning(msg: str) -> None
模块级函数。打印warning
级别的消息。warning
消息颜色值默认为:#FFFF00
。
Parameters:
Name | Type | Description | Default |
---|---|---|---|
msg |
str
|
要打印的消息 |
required |
Returns:
Type | Description |
---|---|
None
|
无返回值 |
critical(msg: str) -> None
模块级函数。打印critical
级别的消息。critical
消息颜色值默认为:#A61C00
。
Parameters:
Name | Type | Description | Default |
---|---|---|---|
msg |
str
|
要打印的消息 |
required |
Returns:
Type | Description |
---|---|
None
|
无返回值 |
fatal(msg: str) -> None
模块级函数。打印fatal
级别的消息。fatal
消息颜色值默认为:#FF0000
。
Parameters:
Name | Type | Description | Default |
---|---|---|---|
msg |
str
|
要打印的消息 |
required |
Returns:
Type | Description |
---|---|
None
|
无返回值 |
Logger
Bases: object
该类用于向函数执行窗口的输出浏览器
区域打印日志消息。不同级别的日志消息,主要以颜色进行区分。可以使用LoggerConfig
实例指定各消息级别的颜色值。
示例:
from pyguiadapter.adapter import GUIAdapter
from pyguiadapter.adapter.uoutput import Logger, LoggerConfig
logger = Logger(
config=LoggerConfig(
info_color="green",
debug_color="blue",
warning_color="yellow",
critical_color="red",
fatal_color="magenta",
)
)
def output_log_msg(
info_msg: str = "info message",
debug_msg: str = "debug message",
warning_msg: str = "warning message",
critical_msg: str = "critical message",
fatal_msg: str = "fatal message",
):
logger.info(info_msg)
logger.debug(debug_msg)
logger.warning(warning_msg)
logger.critical(critical_msg)
logger.fatal(fatal_msg)
if __name__ == "__main__":
adapter = GUIAdapter()
adapter.add(output_log_msg)
adapter.run()
critical(msg: str) -> None
打印critical
级别的消息。
Parameters:
Name | Type | Description | Default |
---|---|---|---|
msg |
str
|
要打印的消息 |
required |
Returns:
Type | Description |
---|---|
None
|
无返回值 |
debug(msg: str) -> None
打印debug
级别的消息。
Parameters:
Name | Type | Description | Default |
---|---|---|---|
msg |
str
|
要打印的消息 |
required |
Returns:
Type | Description |
---|---|
None
|
无返回值 |
fatal(msg: str) -> None
打印fatal
级别的消息。
Parameters:
Name | Type | Description | Default |
---|---|---|---|
msg |
str
|
要打印的消息 |
required |
Returns:
Type | Description |
---|---|
None
|
无返回值 |
info(msg: str) -> None
打印info
级别的消息。
Parameters:
Name | Type | Description | Default |
---|---|---|---|
msg |
str
|
要打印的消息 |
required |
Returns:
Type | Description |
---|---|
None
|
无返回值 |
warning(msg: str) -> None
打印warning
级别的消息。
Parameters:
Name | Type | Description | Default |
---|---|---|---|
msg |
str
|
要打印的消息 |
required |
Returns:
Type | Description |
---|---|
None
|
无返回值 |
LoggerConfig
dataclass
Bases: object
Logger
的配置类,用于配置Logger
的颜色等属性。
Source code in pyguiadapter\adapter\uoutput.py
critical_color: str = COLOR_CRITICAL
class-attribute
instance-attribute
critical
级别消息的颜色值
debug_color: str = COLOR_DEBUG
class-attribute
instance-attribute
debug
级别消息的颜色值
fatal_color: str = COLOR_FATAL
class-attribute
instance-attribute
fatal
级别消息的颜色值
info_color: str = COLOR_INFO
class-attribute
instance-attribute
info
级别消息的颜色值
warning_color: str = COLOR_WARNING
class-attribute
instance-attribute
warning
级别消息的颜色值