QueryDialog
Bases: Dialog
A simple modal dialog class for collecting user input.
Source code in src/ttkbootstrap/dialogs/query.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 | |
__init__(prompt, title=' ', initialvalue='', minvalue=None, maxvalue=None, width=65, datatype=str, padding=(20, 20), parent=None, items=None)
Create a query dialog for collecting user input.
Parameters:
prompt (str):
The prompt text to display above the input field. Supports
multiline strings (separated by \n).
title (str):
The dialog window title (default=' ').
initialvalue (Any):
The initial value to populate in the input field (default='').
minvalue (Any):
Minimum allowed value for numeric data types (int, float, complex).
Ignored for strings.
maxvalue (Any):
Maximum allowed value for numeric data types (int, float, complex).
Ignored for strings.
width (int):
Maximum width in characters for text wrapping of the prompt
(default=65).
datatype (type):
Expected data type for validation (str, int, float, complex).
When set to int, float, or complex, the input will be validated
and converted (default=str).
padding (int | tuple):
Padding around the dialog content. Can be a single int or
tuple (horizontal, vertical) (default=(20, 20)).
parent (Widget):
Parent widget. The dialog will be centered on this widget.
items (List[str]):
Optional list of items for dropdown selection. If provided,
shows a Combobox instead of Entry. The Combobox supports
filtering by typing. If items are provided, the input must
match one from the list.
Source code in src/ttkbootstrap/dialogs/query.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | |
apply()
Process the data after closing (no-op by default).
Source code in src/ttkbootstrap/dialogs/query.py
203 204 205 | |
validate()
Validate the data before closing.
Source code in src/ttkbootstrap/dialogs/query.py
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 | |