跳转至

pyguiadapter.adapter.uinput

模块级方法

get_string(title: str = 'Input Text', label: str = '', echo: Optional[EchoMode] = None, text: str = '') -> Optional[str]

弹出单行文本输入框,返回用户输入的字符串。

Parameters:

Name Type Description Default
title str

对话框标题

'Input Text'
label str

提示标签

''
echo Optional[EchoMode]

回显模式

None
text str

初始文本

''

Returns:

Type Description
Optional[str]

用户输入的字符串,如果用户取消输入则返回None。

get_text(title: str = 'Input Text', label: str = '', text: str = '') -> Optional[str]

弹出多行文本输入框,返回用户输入的字符串。

Parameters:

Name Type Description Default
title str

对话框标题

'Input Text'
label str

提示标签

''
text str

初始文本

''

Returns:

Type Description
Optional[str]

用户输入的字符串,如果用户取消输入则返回None。

get_int(title: str = 'Input Integer', label: str = '', value: int = 0, min_value: int = -2147483647, max_value: int = 2147483647, step: int = 1) -> Optional[int]

弹出整数输入框,返回用户输入的整数。

Parameters:

Name Type Description Default
title str

对话框标题

'Input Integer'
label str

提示标签

''
value int

初始值

0
min_value int

最小值

-2147483647
max_value int

最大值

2147483647
step int

步长

1

Returns:

Type Description
Optional[int]

用户输入的整数,如果用户取消输入则返回None。

get_float(title: str = 'Input Float', label: str = '', value: float = 0.0, min_value: float = -2147483647.0, max_value: float = 2147483647.0, decimals: int = 3, step: float = 1.0) -> Optional[float]

弹出浮点数输入框,返回用户输入的浮点数。

Parameters:

Name Type Description Default
title str

对话框标题

'Input Float'
label str

提示标签

''
value float

初始值

0.0
min_value float

最小值

-2147483647.0
max_value float

最大值

2147483647.0
decimals int

小数位数

3
step float

步长

1.0

Returns:

Type Description
Optional[float]

用户输入的浮点数,如果用户取消输入则返回None。

get_selected_item(items: List[str], title: str = 'Select Item', label: str = '', current: int = 0, editable: bool = False) -> Optional[str]

弹出选项列表,返回用户选择的项目。

Parameters:

Name Type Description Default
items List[str]

项目列表

required
title str

对话框标题

'Select Item'
label str

提示标签

''
current int

当前选择项索引

0
editable bool

是否可编辑

False

Returns:

Type Description
Optional[str]

用户选择的项目,如果用户取消输入则返回None。

get_json_object(title: str = 'Input Json', icon: IconType = None, size: Tuple[int, int] = (600, 400), ok_button_text: str = 'Ok', cancel_button_text: Optional[str] = 'Cancel', initial_text: str = '', auto_indent: bool = True, indent_size: int = 4, auto_parentheses: bool = True, line_wrap_mode: LineWrapMode = LineWrapMode.WidgetWidth, line_wrap_width: int = 88, font_family: Union[str, Sequence[str], None] = None, font_size: Optional[int] = None, **kwargs) -> Any

弹出Json输入框,返回用户输入的Json对象。

Parameters:

Name Type Description Default
title str

对话框标题

'Input Json'
icon IconType

窗口图标

None
size Tuple[int, int]

窗口大小

(600, 400)
ok_button_text str

确定按钮文本

'Ok'
cancel_button_text Optional[str]

取消按钮文本

'Cancel'
initial_text str

初始文本

''
auto_indent bool

是否自动缩进

True
indent_size int

缩进大小

4
auto_parentheses bool

是否自动匹配括号

True
line_wrap_mode LineWrapMode

换行模式

WidgetWidth
line_wrap_width int

换行宽度

88
font_family Union[str, Sequence[str], None]

字体

None
font_size Optional[int]

字体大小

None
**kwargs

其他参数

{}

Returns:

Type Description
Any

用户输入的Json对象,如果用户取消输入则返回None。

Raises:

Type Description
Exception

如果输入了非法的Json文本,则会抛出异常。

get_py_literal(title: str = 'Input Python Literal', icon: IconType = None, size: Tuple[int, int] = (600, 400), ok_button_text: str = 'Ok', cancel_button_text: Optional[str] = 'Cancel', initial_text: str = '', auto_indent: bool = True, indent_size: int = 4, auto_parentheses: bool = True, line_wrap_mode: LineWrapMode = LineWrapMode.WidgetWidth, line_wrap_width: int = 88, font_family: Union[str, Sequence[str], None] = None, font_size: Optional[int] = None, **kwargs) -> PyLiteralType

弹出Python字面量输入框,返回用户输入的Python字面量。

Parameters:

Name Type Description Default
title str

对话框标题

'Input Python Literal'
icon IconType

窗口图标

None
size Tuple[int, int]

窗口大小

(600, 400)
ok_button_text str

确定按钮文本

'Ok'
cancel_button_text Optional[str]

取消按钮文本

'Cancel'
initial_text str

初始文本

''
auto_indent bool

是否自动缩进

True
indent_size int

缩进大小

4
auto_parentheses bool

是否自动匹配括号

True
line_wrap_mode LineWrapMode

换行模式

WidgetWidth
line_wrap_width int

换行宽度

88
font_family Union[str, Sequence[str], None]

字体

None
font_size Optional[int]

字体大小

None
**kwargs

其他参数

{}

Returns:

Type Description
PyLiteralType

用户输入的Python字面量,如果用户取消输入则返回None。

Raises:

Type Description
Exception

如果输入了非法的Python字面量(即ast.literal_eval()无法解析的内容),则会抛出异常。

get_existing_directory(title: str = '', start_dir: str = '') -> Optional[str]

弹出选择文件夹对话框,返回用户选择的目录。

Parameters:

Name Type Description Default
title str

对话框标题

''
start_dir str

起始目录

''

Returns:

Type Description
Optional[str]

用户选择的目录,如果用户取消输入则返回None。

get_open_file(title: str = '', start_dir: str = '', filters: str = '') -> Optional[str]

弹出打开文件对话框,返回用户选择的文件。

Parameters:

Name Type Description Default
title str

对话框标题

''
start_dir str

起始目录

''
filters str

文件过滤器

''

Returns:

Type Description
Optional[str]

用户选择的文件路径,如果用户取消输入则返回None。

get_open_files(title: str = '', start_dir: str = '', filters: str = '') -> Optional[List[str]]

弹出打开文件对话框,返回用户选择的多个文件。 Args: title: 对话框标题 start_dir: 起始目录 filters: 文件过滤器

Returns:

Type Description
Optional[List[str]]

用户选择的文件路径列表,如果用户取消输入则返回None。

get_save_file(title: str = '', start_dir: str = '', filters: str = '') -> Optional[str]

弹出保存文件对话框,返回用户输入或选择的文件路径。

Parameters:

Name Type Description Default
title str

对话框标题

''
start_dir str

起始目录

''
filters str

文件过滤器

''

Returns:

Type Description
Optional[str]

用户输入或选择的文件路径,如果用户取消输入则返回None。

get_custom_input(input_dialog_class: Type[UniversalInputDialog], **input_dialog_args) -> Any

弹出自定义输入框,返回用户输入的内容。

Parameters:

Name Type Description Default
input_dialog_class Type[UniversalInputDialog]

自定义输入框类

required
**input_dialog_args

自定义输入框参数

{}

Returns:

Type Description
Any

用户输入的内容,如果用户取消输入则返回None。