Reference
Window
Bases: _LayoutMixin
, _WindowBaseClass
Basic Window class from which all windows are derived
Notes
Classes which inherit from window should implement handle_event, setup, and teardown as needed
Source code in guitk/window.py
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 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 |
|
root
property
Return Tk root instance
widgets: list[BaseWidget]
property
"Return list of all widgets belonging to the window
add_widget(widget, row, col)
Add a widget to the window's mainframe
Source code in guitk/window.py
318 319 320 321 322 323 |
|
bind_timer_event(delay, event_name, repeat=False, command=None)
Create a new virtual event event_name
that fires after delay
ms,
repeats every delay
ms if repeat=True, otherwise fires once
Source code in guitk/window.py
263 264 265 266 267 268 269 270 |
|
cancel_timer_event(timer_id)
Cancel a timer event created with bind_timer_event
Source code in guitk/window.py
299 300 301 302 303 304 305 306 307 308 309 |
|
children()
Return child windows
Source code in guitk/window.py
377 378 379 |
|
get(key)
Get widget with key or raise KeyError if not found
Source code in guitk/window.py
381 382 383 384 385 386 |
|
handle_event(event)
Handle event objects, inheriting classes should implement handle_event
Source code in guitk/window.py
212 213 214 |
|
quit(return_value=None)
Called when closing the window
Source code in guitk/window.py
230 231 232 233 234 235 |
|
remove(key_or_widget)
Remove widget from window and destroy it.
Source code in guitk/window.py
325 326 327 328 329 330 331 332 333 334 335 336 |
|
setup()
Perform any needed setup for the window. Gets called immediately after init
Source code in guitk/window.py
218 219 220 221 222 |
|
teardown()
Perform any cleanup before the window closes. Gets called immediately before the window is destroyed
Source code in guitk/window.py
224 225 226 227 228 |
|
HLayout
A Layout manager that aligns widgets horizontally
Source code in guitk/layout.py
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 |
|
layout: LayoutType
property
Return the layout list
append(widget)
Add a widget to the end of the HLayout
Source code in guitk/layout.py
84 85 86 87 88 89 90 91 92 |
|
remove(key_or_widget)
Remove widget from layout" and destroy it.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key_or_widget |
Hashable | Widget
|
The key or widget to remove. If a key is given, the first widget with that key will be removed. |
required |
Raises:
Type | Description |
---|---|
RuntimeError
|
If called and the layout was not created in a Window. |
ValueError
|
If the widget is not found in the layout. |
Source code in guitk/layout.py
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
|
VLayout
Bases: HLayout
A Layout manager that aligns widgets vertically
Source code in guitk/layout.py
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
|
append(widget)
Add a widget to the bottom of the VLayout
Source code in guitk/layout.py
161 162 163 164 165 166 167 168 169 |
|
HStack
Bases: _Stack
A container that stacks widgets horizontally when added to a Layout
Source code in guitk/containers.py
335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 |
|
layout: list[list[BaseWidget]]
property
writable
Return the layout of the HStack
__init__(key=None, height=None, padding=None, disabled=False, sticky='nsew', valign=None, halign=None, vexpand=True, hexpand=True, distribute=False, vspacing=None, hspacing=None, vscrollbar=False, autohide_scrollbars=True)
A container that stacks widgets horizontally when added to a Layout
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key |
Hashable
|
The key to use for the HStack. Defaults to None. |
None
|
height |
int
|
The height of the HStack. Defaults to None. |
None
|
padding |
PaddingType
|
The padding around the HStack. Defaults to None. |
None
|
disabled |
bool
|
Whether the HStack is disabled. Defaults to False. |
False
|
sticky |
str
|
The sticky value for the HStack. Defaults to "nsew". |
'nsew'
|
valign |
VAlign
|
The vertical alignment for the widgets in the HStack. Defaults to None. |
None
|
halign |
HAlign
|
The horizontal alignment for the widgets in the HStack. Defaults to None. |
None
|
vexpand |
bool
|
Whether the Stack should expand vertically. Defaults to True. |
True
|
hexpand |
bool
|
Whether the Stack should expand horizontally. Defaults to True. |
True
|
distribute |
bool
|
Whether the HStack should distribute widgets evenly. |
False
|
vspacing |
PadType
|
Vertical spacing between widgets. Defaults to None. |
None
|
hspacing |
PadType
|
Horizontal spacing between widgets. Defaults to None. |
None
|
vscrollbar |
bool
|
Whether to include a vertical scrollbar. Defaults to False. |
False
|
autohide_scrollbars |
bool
|
Whether to hide scrollbars when not needed. Defaults to True. |
True
|
Note
If height is specified, the HStack will not expand to fill the available space and the expand parameter will be ignored.
Source code in guitk/containers.py
338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 |
|
VStack
Bases: _Stack
A container that stacks widgets vertically when added to a Layout
Source code in guitk/containers.py
267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 |
|
__init__(key=None, width=None, padding=None, disabled=False, sticky='nsew', valign=None, halign=None, vexpand=True, hexpand=True, distribute=False, vspacing=None, hspacing=None, vscrollbar=False, autohide_scrollbars=True)
Base container container that stacks widgets vertically when added to a Layout
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key |
Hashable
|
The key to use for the VStack. Defaults to None. |
None
|
width |
int
|
The width of the VStack. Defaults to None. |
None
|
padding |
PaddingType
|
The padding around the VStack. Defaults to None. |
None
|
disabled |
bool
|
Whether the VStack is disabled. Defaults to False. |
False
|
sticky |
str
|
The sticky value for the VStack. Defaults to "nsew". |
'nsew'
|
valign |
VAlign
|
The vertical alignment for the widgets in the VStack. Defaults to None. |
None
|
halign |
HAlign
|
The horizontal alignment for the widgets in the VStack. Defaults to None. |
None
|
vexpand |
bool
|
Whether the Stack should expand vertically. Defaults to True. |
True
|
hexpand |
bool
|
Whether the Stack should expand horizontally. Defaults to True. |
True
|
distribute |
bool
|
Whether the VStack should distribute widgets evenly. |
False
|
vspacing |
PadType
|
Vertical spacing between widgets. Defaults to None. |
None
|
hspacing |
PadType
|
Horizontal spacing between widgets. Defaults to None. |
None
|
vscrollbar |
bool
|
Whether to include a vertical scrollbar. Defaults to False. |
False
|
autohide_scrollbars |
bool
|
Whether to hide scrollbars when not needed. Defaults to True. |
True
|
Note
If width is specified, the VStack will not expand to fill the available space and the expand parameter will be ignored.
Source code in guitk/containers.py
270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 |
|
HSpacer
Bases: Label
HSpacer widget that expands to fill the horizontal space in the layout
Source code in guitk/spacer.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
|
VSpacer
Bases: Label
"HSpacer widget that expands to fill the vertical space in the layout
Source code in guitk/spacer.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
|
Button
Bases: BaseWidget
Basic button
Source code in guitk/ttk_button.py
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 |
|
button
property
Return the Tk button widget
__init__(text, image=None, key=None, disabled=False, columnspan=None, rowspan=None, padx=None, pady=None, events=True, sticky=None, tooltip=None, command=None, weightx=None, weighty=None, focus=False, **kwargs)
Initialize a Button widget.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text |
str
|
Text for the button. |
required |
image |
str | None
|
Image for the button. Defaults to None. |
None
|
key |
Hashable
|
Unique key for this widget. Defaults to None. |
None
|
disabled |
bool
|
If True, widget is disabled. Defaults to False. |
False
|
columnspan |
int | None
|
Number of columns to span. Defaults to None. |
None
|
rowspan |
int | None
|
Number of rows to span. Defaults to None. |
None
|
padx |
PadType | None
|
X padding. Defaults to None. |
None
|
pady |
PadType | None
|
Y padding. Defaults to None. |
None
|
events |
bool
|
Enable events for this widget. Defaults to False. |
True
|
sticky |
str | None
|
Sticky direction for widget layout. Defaults to None. |
None
|
tooltip |
TooltipType | None
|
Tooltip text or callback to generate tooltip text. Defaults to None. |
None
|
command |
CommandType | None
|
Command callback. Defaults to None. |
None
|
weightx |
int | None
|
Weight in x direction. Defaults to None. |
None
|
weighty |
int | None
|
Weight in y direction. Defaults to None. |
None
|
focus |
bool
|
If True, widget has focus. Defaults to False. Only one widget in a window can have focus.HLayout |
False
|
**kwargs |
Additional keyword arguments are passed to ttk.Button. |
{}
|
Note
Emits EventType.ButtonPress event.
Source code in guitk/ttk_button.py
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 |
|
BrowseFileButton
Bases: Button
Button that opens a file dialog to select a file.
Source code in guitk/ttk_button.py
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 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 |
|
__init__(text='Browse', key=None, target_key=None, disabled=False, columnspan=None, rowspan=None, padx=None, pady=None, events=True, sticky=None, tooltip=None, filename_only=False, weightx=None, weighty=None, focus=False, **kwargs)
Initialize a BrowseFileButton widget.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text |
str
|
Text for the button. |
'Browse'
|
key |
Hashable
|
Unique key for this widget. Defaults to None. |
None
|
target_key |
Hashable
|
Unique key for the target widget. Defaults to None. If set, the target widget's value is set to the selected filename. |
None
|
disabled |
bool
|
If True, widget is disabled. Defaults to False. |
False
|
columnspan |
int | None
|
Number of columns to span. Defaults to None. |
None
|
rowspan |
int | None
|
Number of rows to span. Defaults to None. |
None
|
padx |
PadType | None
|
X padding. Defaults to None. |
None
|
pady |
PadType | None
|
Y padding. Defaults to None. |
None
|
events |
bool
|
Enable events for this widget. Defaults to False. |
True
|
sticky |
str | None
|
Sticky direction for widget layout. Defaults to None. |
None
|
tooltip |
TooltipType | None
|
Tooltip text or callback to generate tooltip text. Defaults to None. |
None
|
filename_only |
bool
|
If True, only the filename is returned. Defaults to False. |
False
|
weightx |
int | None
|
Weight in x direction. Defaults to None. |
None
|
weighty |
int | None
|
Weight in y direction. Defaults to None. |
None
|
focus |
bool
|
If True, widget has focus. Defaults to False. Only one widget in a window can have focus.HLayout |
False
|
**kwargs |
Additional keyword arguments are passed to ttk.Button or filedialog.askopenfilename as appropriate. |
{}
|
Note
Emits a EventType.BrowseFile event after the file dialog is closed.
Source code in guitk/ttk_button.py
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 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 |
|
browse_dialog()
Open a file dialog to select a file
Source code in guitk/ttk_button.py
264 265 266 267 268 269 270 271 272 273 274 275 276 |
|
BrowseDirectoryButton
Bases: Button
Button that opens a file dialog to select a directory.
Source code in guitk/ttk_button.py
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 |
|
__init__(text='Browse', key=None, target_key=None, disabled=False, columnspan=None, rowspan=None, padx=None, pady=None, events=True, sticky=None, tooltip=None, weightx=None, weighty=None, focus=False, **kwargs)
Initialize a BrowseDirectoryButton widget.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text |
str
|
Text for the button. |
'Browse'
|
key |
Hashable
|
Unique key for this widget. Defaults to None. |
None
|
target_key |
Hashable
|
Unique key for the target widget. Defaults to None. If set, the target widget's value is set to the selected directory. |
None
|
disabled |
bool
|
If True, widget is disabled. Defaults to False. |
False
|
columnspan |
int | None
|
Number of columns to span. Defaults to None. |
None
|
rowspan |
int | None
|
Number of rows to span. Defaults to None. |
None
|
padx |
PadType | None
|
X padding. Defaults to None. |
None
|
pady |
PadType | None
|
Y padding. Defaults to None. |
None
|
events |
bool
|
Enable events for this widget. Defaults to False. |
True
|
sticky |
str | None
|
Sticky direction for widget layout. Defaults to None. |
None
|
tooltip |
TooltipType | None
|
Tooltip text or callback to generate tooltip text. Defaults to None. |
None
|
weightx |
int | None
|
Weight in x direction. Defaults to None. |
None
|
weighty |
int | None
|
Weight in y direction. Defaults to None. |
None
|
focus |
bool
|
If True, widget has focus. Defaults to False. Only one widget in a window can have focus.HLayout |
False
|
**kwargs |
Additional keyword arguments are passed to ttk.Button or filedialog.askopenfilename as appropriate. |
{}
|
Note
Emits a EventType.BrowseDirectory event after the file dialog is closed.
Source code in guitk/ttk_button.py
282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 |
|
browse_dialog()
Open a file dialog to select a directory.
Source code in guitk/ttk_button.py
364 365 366 367 368 369 370 371 372 373 374 375 |
|
Checkbutton
Bases: BaseWidget
Checkbox / checkbutton
Source code in guitk/ttk_checkbutton.py
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 |
|
checkbutton
property
Return the ttk.Checkbutton widget
__init__(text, key=None, checked=False, disabled=False, columnspan=None, rowspan=None, padx=None, pady=None, events=True, sticky=None, tooltip=None, command=None, weightx=None, weighty=None, focus=False, **kwargs)
Initialize a ttk.Checkbutton widget.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text |
str
|
Text for the checkbutton. |
required |
key |
Hashable
|
Unique key for this widget. Defaults to None. |
None
|
checked |
bool
|
Initial state. Defaults to False (not checked). |
False
|
disabled |
bool
|
If True, widget is disabled. Defaults to False. |
False
|
columnspan |
int | None
|
Number of columns to span. Defaults to None. |
None
|
rowspan |
int | None
|
Number of rows to span. Defaults to None. |
None
|
padx |
PadType | None
|
X padding. Defaults to None. |
None
|
pady |
PadType | None
|
Y padding. Defaults to None. |
None
|
events |
bool
|
Enable events for this widget. Defaults to False. |
True
|
sticky |
str | None
|
Sticky direction for widget layout. Defaults to None. |
None
|
tooltip |
TooltipType | None
|
Tooltip text or callback to generate tooltip text. Defaults to None. |
None
|
command |
CommandType | None
|
Command callback. Defaults to None. |
None
|
weightx |
int | None
|
Weight of widget in X direction. Defaults to None. |
None
|
weighty |
int | None
|
Weight of widget in Y direction. Defaults to None. |
None
|
focus |
bool
|
If True, widget has focus. Defaults to False. Only one widget in a window can have focus.HLayout |
False
|
**kwargs |
Additional keyword arguments are passed to ttk.Checkbutton. |
{}
|
Notes
Unlike a regular ttk.Checkbutton, the onvalue and offvalue are always True and False. Emits an EventType.Checkbutton event when the checkbutton is clicked.
Source code in guitk/ttk_checkbutton.py
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 |
|
Combobox
Bases: BaseWidget
ttk Combobox
Source code in guitk/ttk_combobox.py
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 |
|
combobox
property
Return the Tk combobox widget
Entry
Bases: BaseWidget
ttk.Entry text entry / input box
Source code in guitk/ttk_entry.py
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 |
|
entry
property
Return the Tk entry widget
__init__(key=None, default=None, disabled=False, columnspan=None, rowspan=None, padx=None, pady=None, events=True, keyrelease=False, sticky=None, tooltip=None, command=None, hscrollbar=False, weightx=None, weighty=None, focus=False, **kwargs)
Initialize an Entry widget.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key |
Hashable
|
Unique key for this widget. Defaults to None. |
None
|
default |
str | None
|
Default text for the entry box. Defaults to None. |
None
|
disabled |
bool
|
If True, widget is disabled. Defaults to False. |
False
|
columnspan |
int | None
|
Number of columns to span. Defaults to None. |
None
|
rowspan |
int | None
|
Number of rows to span. Defaults to None. |
None
|
padx |
PadType | None
|
X padding. Defaults to None. |
None
|
pady |
PadType | None
|
Y padding. Defaults to None. |
None
|
events |
bool
|
Enable events for this widget. Defaults to True. |
True
|
keyrelease |
bool
|
If True, generate events on key release. Defaults to False. |
False
|
sticky |
str | None
|
Sticky direction for widget layout. Defaults to None. |
None
|
tooltip |
TooltipType | None
|
Tooltip text or callback to generate tooltip text. Defaults to None. |
None
|
command |
CommandType | None
|
Command callback. Defaults to None. |
None
|
hscrollbar |
bool
|
Show horizontal scrollbar. Defaults to False. |
False
|
weightx |
int | None
|
Weight for horizontal resizing. Defaults to None. |
None
|
weighty |
int | None
|
Weight for vertical resizing. Defaults to None. |
None
|
focus |
bool
|
If True, widget has focus. Defaults to False. Only one widget in a window can have focus.HLayout |
False
|
**kwargs |
Additional keyword arguments are passed to ttk.Entry. |
{}
|
Note
Emits EventType.EntryReturn event on return key press. If keyrelease is True, emits EventType.KeyRelease event on every key release.
Source code in guitk/ttk_entry.py
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 |
|
LabelEntry
Bases: Entry
Text entry / input box with a label
Source code in guitk/ttk_entry.py
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 |
|
entry
property
Return the Tk entry widget
__init__(text, key=None, default=None, disabled=False, columnspan=None, rowspan=None, padx=None, pady=None, events=True, keyrelease=False, sticky=None, tooltip=None, command=None, hscrollbar=False, weightx=None, weighty=None, focus=False, **kwargs)
Initialize an Entry widget.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text |
str
|
Label text. |
required |
key |
Hashable
|
Unique key for this widget. Defaults to None. |
None
|
default |
str | None
|
Default text for the entry box. Defaults to None. |
None
|
disabled |
bool
|
If True, widget is disabled. Defaults to False. |
False
|
columnspan |
int | None
|
Number of columns to span. Defaults to None. |
None
|
rowspan |
int | None
|
Number of rows to span. Defaults to None. |
None
|
padx |
PadType | None
|
X padding. Defaults to None. |
None
|
pady |
PadType | None
|
Y padding. Defaults to None. |
None
|
events |
bool
|
Enable events for this widget. Defaults to True. |
True
|
keyrelease |
bool
|
If True, emits EventType.KeyRelease event on every key release. |
False
|
sticky |
str | None
|
Sticky direction for widget layout. Defaults to None. |
None
|
tooltip |
TooltipType | None
|
Tooltip text or callback to generate tooltip text. Defaults to None. |
None
|
command |
CommandType | None
|
Command callback. Defaults to None. |
None
|
hscrollbar |
bool
|
Show horizontal scrollbar. Defaults to False. |
False
|
weightx |
int | None
|
Weight for horizontal resizing. Defaults to None. |
None
|
weighty |
int | None
|
Weight for vertical resizing. Defaults to None. |
None
|
focus |
bool
|
If True, widget will have focus. Defaults to False. Only one widget can have focus. |
False
|
**kwargs |
Additional keyword arguments are passed to ttk.Entry. |
{}
|
Note
Emits EventType.EntryReturn event on return key press. If keyrelease is True, emits EventType.KeyRelease event on every key release.
Source code in guitk/ttk_entry.py
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 |
|
Label
Bases: BaseWidget
ttk.Label widget
Source code in guitk/ttk_label.py
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 |
|
label
property
Return the Tk label widget
__init__(text, image=None, key=None, disabled=False, columnspan=None, rowspan=None, padx=None, pady=None, events=False, sticky=None, tooltip=None, weightx=None, weighty=None, **kwargs)
Initialize a Label widget.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key |
Hashable
|
Unique key for this widget. Defaults to None. |
None
|
text |
str
|
Text to display in the label. |
required |
image |
str | None
|
(str, optional): Path to image to display in the label. Defaults to None. |
None
|
disabled |
bool
|
If True, widget is disabled. Defaults to False. |
False
|
columnspan |
int | None
|
Number of columns to span. Defaults to None. |
None
|
rowspan |
int | None
|
Number of rows to span. Defaults to None. |
None
|
padx |
PadType | None
|
X padding. Defaults to None. |
None
|
pady |
PadType | None
|
Y padding. Defaults to None. |
None
|
events |
bool
|
Enable events for this widget. Defaults to False. |
False
|
sticky |
str | None
|
Sticky direction for widget layout. Defaults to None. |
None
|
tooltip |
TooltipType | None
|
Tooltip text or callback to generate tooltip text. Defaults to None. |
None
|
weightx |
int | None
|
Weight of this widget in the horizontal direction. Defaults to None. |
None
|
weighty |
int | None
|
Weight of this widget in the vertical direction. Defaults to None. |
None
|
**kwargs |
Additional keyword arguments are passed to ttk.Entry. |
{}
|
Source code in guitk/ttk_label.py
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 |
|
Notebook
Bases: _Container
ttk.Notebook widget
Source code in guitk/ttk_notebook.py
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 |
|
current_tab
property
Return the name of the currently selected tab
notebook
property
Return the ttk.Notebook widget
__init__(key=None, tabs=None, disabled=False, columnspan=None, rowspan=None, padx=None, pady=None, events=False, sticky=None, tooltip=None, command=None, weightx=None, weighty=None, focus=False, **kwargs)
Initialize a Notebook widget.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key |
Hashable
|
Unique key for this widget. Defaults to None. |
None
|
tabs |
list[HTab] | None
|
(list[Tab], optional): Tabs to add to the notebook. Defaults to None. |
None
|
disabled |
bool
|
If True, widget is disabled. Defaults to False. |
False
|
columnspan |
int | None
|
Number of columns to span. Defaults to None. |
None
|
rowspan |
int | None
|
Number of rows to span. Defaults to None. |
None
|
padx |
PadType | None
|
X padding. Defaults to None. |
None
|
pady |
PadType | None
|
Y padding. Defaults to None. |
None
|
events |
bool
|
Enable events for this widget. Defaults to False. |
False
|
sticky |
str | None
|
Sticky direction for widget layout. Defaults to None. |
None
|
tooltip |
TooltipType | None
|
Tooltip text or callback to generate tooltip text. Defaults to None. |
None
|
command |
CommandType | None
|
Command to execute when clicked. Defaults to None. |
None
|
weightx |
int | None
|
Horizontal weight. Defaults to None. |
None
|
weighty |
int | None
|
Vertical weight. Defaults to None. |
None
|
focus |
bool
|
If True, widget will have focus. Defaults to False. Only one widget in a window can have focus.HLayout |
False
|
**kwargs |
Additional keyword arguments are passed to ttk.Entry. |
{}
|
Note
Emits EventType.NotebookTabChanged event.
Source code in guitk/ttk_notebook.py
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 |
|
add(tab)
Add a Tab to the Notebook as new tab
Source code in guitk/ttk_notebook.py
162 163 164 165 166 |
|
insert(pos, tab)
Insert a layout to the Notebook as new tab at position pos
Source code in guitk/ttk_notebook.py
168 169 170 171 172 |
|
HTab
Bases: _Container
Tab for Notebook widget that arranges its widgets horizontally
Source code in guitk/ttk_notebook.py
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 |
|
__init__(name=None, sticky='nsew', valign=None, halign=None, **kwargs)
Initialize a horizontal Tab
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
Name of the tab. Defaults to None. |
None
|
sticky |
str | None
|
Sticky direction for widget layout. Defaults to None. |
'nsew'
|
valign |
VAlign | None
|
Vertical alignment of widgets in the tab. Defaults to None. |
None
|
halign |
HAlign | None
|
Horizontal alignment of widgets in the tab. Defaults to None. |
None
|
**kwargs |
Additional keyword arguments are passed to ttk.Frame. |
{}
|
Source code in guitk/ttk_notebook.py
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 |
|
VTab
Bases: HTab
, _VerticalContainer
Tab for Notebook widget that arranges its widgets vertically
Source code in guitk/ttk_notebook.py
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 |
|
__init__(name=None, sticky='nsew', valign=None, halign=None, **kwargs)
Initialize a vertical Tab
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
Name of the tab. Defaults to None. |
None
|
sticky |
str | None
|
Sticky direction for widget layout. Defaults to None. |
'nsew'
|
valign |
VAlign | None
|
Vertical alignment of widgets in the tab. Defaults to None. |
None
|
halign |
HAlign | None
|
Horizontal alignment of widgets in the tab. Defaults to None. |
None
|
**kwargs |
Additional keyword arguments are passed to ttk.Frame. |
{}
|
Source code in guitk/ttk_notebook.py
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 |
|
Text
Bases: BaseWidget
A tk Text box
Source code in guitk/tk_text.py
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 |
|
text
property
Return the Tk text widget
__init__(text=None, key=None, width=40, height=20, disabled=False, columnspan=None, rowspan=None, padx=None, pady=None, events=False, sticky=None, tooltip=None, command=None, vscrollbar=False, hscrollbar=False, weightx=None, weighty=None, focus=False, **kwargs)
Initialize a Text widget.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text |
str | None
|
Default text for the text box. Defaults to None. |
None
|
key |
Hashable
|
Unique key for this widget. Defaults to None. |
None
|
width |
int
|
Width of the text box. Defaults to 40. |
40
|
height |
int
|
Height of the text box. Defaults to 20. |
20
|
disabled |
bool
|
If True, widget is disabled. Defaults to False. |
False
|
columnspan |
int | None
|
Number of columns to span. Defaults to None. |
None
|
rowspan |
int | None
|
Number of rows to span. Defaults to None. |
None
|
padx |
PadType | None
|
X padding. Defaults to None. |
None
|
pady |
PadType | None
|
Y padding. Defaults to None. |
None
|
events |
bool
|
Enable events for this widget. Defaults to False. |
False
|
sticky |
str | None
|
Sticky direction for widget layout. Defaults to None. |
None
|
tooltip |
TooltipType | None
|
Tooltip text or callback to generate tooltip text. Defaults to None. |
None
|
command |
CommandType | None
|
Command callback. Defaults to None. |
None
|
vscrollbar |
bool
|
Show vertical scrollbar. Defaults to False. |
False
|
hscrollbar |
bool
|
Show horizontal scrollbar. Defaults to False. |
False
|
weightx |
int | None
|
Weight of the widget in the x direction. Defaults to None. |
None
|
weighty |
int | None
|
Weight of the widget in the y direction. Defaults to None. |
None
|
focus |
bool
|
If True, widget has focus. Defaults to False. Only one widget in a window can have focus.HLayout |
False
|
**kwargs |
Additional keyword arguments are passed to tk Text. |
{}
|
Note
Emits EventType.KeyRelease events when the text is changed and events is True.
Source code in guitk/tk_text.py
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 |
|
Output
Bases: Text
Text box that redirects stderr and/or stdout to the text box.
Source code in guitk/tk_text.py
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 |
|
echo
property
writable
Return True if stdout and stderr are echoed to the console.
__init__(text=None, key=None, width=40, height=20, disabled=False, columnspan=None, rowspan=None, padx=None, pady=None, events=False, sticky=None, tooltip=None, vscrollbar=True, hscrollbar=False, stdout=True, stderr=True, echo=False, weightx=None, weighty=None, focus=False, **kwargs)
Initialize an Output widget.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text |
str | None
|
Default text for the text box. Defaults to None. |
None
|
key |
Hashable
|
Unique key for this widget. Defaults to None. |
None
|
width |
int
|
Width of the text box. Defaults to 40. |
40
|
height |
int
|
Height of the text box. Defaults to 20. |
20
|
disabled |
bool
|
If True, widget is disabled. Defaults to False. |
False
|
columnspan |
int | None
|
Number of columns to span. Defaults to None. |
None
|
rowspan |
int | None
|
Number of rows to span. Defaults to None. |
None
|
padx |
PadType | None
|
X padding. Defaults to None. |
None
|
pady |
PadType | None
|
Y padding. Defaults to None. |
None
|
events |
bool
|
Enable events for this widget. Defaults to False. |
False
|
sticky |
str | None
|
Sticky direction for widget layout. Defaults to None. |
None
|
tooltip |
TooltipType | None
|
Tooltip text or callback to generate tooltip text. Defaults to None. |
None
|
command |
CommandType | None
|
Command callback. Defaults to None. |
required |
vscrollbar |
bool
|
Show vertical scrollbar. Defaults to False. |
True
|
hscrollbar |
bool
|
Show horizontal scrollbar. Defaults to False. |
False
|
stdout |
bool
|
Redirect stdout to the text box. Defaults to True. |
True
|
stderr |
bool
|
Redirect stderr to the text box. Defaults to True. |
True
|
echo |
bool
|
Echo stdout and stderr to the console. Defaults to False. |
False
|
weightx |
int | None
|
Weight of the widget in the x direction. Defaults to None. |
None
|
weighty |
int | None
|
Weight of the widget in the y direction. Defaults to None. |
None
|
focus |
bool
|
If True, widget has focus. Defaults to False. Only one widget in a window can have focus.HLayout |
False
|
**kwargs |
Additional keyword arguments are passed to tk Text. |
{}
|
Source code in guitk/tk_text.py
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 |
|
disable_redirect()
Disable redirecting stdout and stderr to the text box.
Source code in guitk/tk_text.py
327 328 329 330 |
|
enable_redirect()
Enable redirecting stdout and stderr to the text box.
Source code in guitk/tk_text.py
332 333 334 335 |
|
MenuBar
Menu bar manager that can be used to create a menu bar for a Window
Source code in guitk/menu.py
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 |
|
__init__()
Create a new MenuBar.
Examples:
import guitk as ui
class MenuDemo(ui.Window):
def config(self):
with ui.VLayout():
ui.Label("This window has menus!")
with ui.MenuBar():
with ui.Menu("File"):
ui.Command("Open...", shortcut="Ctrl+O")
with ui.SubMenu("Open Recent"):
ui.Command("File 1")
ui.Command("File 2")
ui.Command("File 3")
ui.MenuSeparator()
ui.Command("Save", key="File|Save", disabled=True)
ui.Command("Save As")
with ui.Menu("Edit", key="Edit", disabled=True):
ui.Command("Cut", shortcut="Ctrl+X")
ui.Command("Copy", shortcut="Ctrl+C")
ui.Command("Paste", shortcut="Ctrl+V")
Source code in guitk/menu.py
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 |
|
Menu
Bases: _BaseMenu
Source code in guitk/menu.py
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 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 |
|
__init__(label, underline=None, key=None, disabled=False)
Create a new Menu.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
label |
str
|
The label for the menu |
required |
underline |
int
|
The index of the character to underline in the label. Defaults to None. |
None
|
key |
Hashable
|
The key to use to access the menu from parent Window. Defaults to f"Menu:{label}" for top level menus and f"Menu:{parent_label|label...}" for submenus. |
None
|
disabled |
bool
|
Create menu in disabled state. Defaults to False. |
False
|
Note
If the menu is created within a MenuBar context manager, the menu will be added to the MenuBar. If the menu is created within a Menu context manager, the menu will be added to the parent Menu as a submenu.
Examples:
import guitk as ui
class MenuDemo(ui.Window):
def config(self):
with ui.VLayout():
ui.Label("This window has menus!")
with ui.MenuBar():
with ui.Menu("File"):
ui.Command("Open...", shortcut="Ctrl+O")
with ui.SubMenu("Open Recent"):
ui.Command("File 1")
ui.Command("File 2")
ui.Command("File 3")
ui.MenuSeparator()
ui.Command("Save", key="File|Save", disabled=True)
ui.Command("Save As")
with ui.Menu("Edit", key="Edit", disabled=True):
ui.Command("Cut", shortcut="Ctrl+X")
ui.Command("Copy", shortcut="Ctrl+C")
ui.Command("Paste", shortcut="Ctrl+V")
Source code in guitk/menu.py
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 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 |
|
Command
Bases: Menu
Source code in guitk/menu.py
379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 |
|
__init__(label, shortcut=None, key=None, command=None, disabled=False)
Create a new menu command
Parameters:
Name | Type | Description | Default |
---|---|---|---|
label |
str
|
The label for the menu command |
required |
shortcut |
str
|
The shortcut for the menu command |
None
|
key |
Hashable
|
Optional key for the menu command (defaults to the path to the menu command) |
None
|
command |
CommandType
|
The command to run when the menu command is selected |
None
|
disabled |
bool
|
Create command in disabled state. Defaults to False. |
False
|
Note
Emits EventType.MenuCommand when command is selected or shortcut is pressed.
Examples:
import guitk as ui
class MenuDemo(ui.Window):
def config(self):
with ui.VLayout():
ui.Label("This window has menus!")
with ui.MenuBar():
with ui.Menu("File"):
ui.Command("Open...", shortcut="Ctrl+O")
with ui.SubMenu("Open Recent"):
ui.Command("File 1")
ui.Command("File 2")
ui.Command("File 3")
ui.MenuSeparator()
ui.Command("Save", key="File|Save", disabled=True)
ui.Command("Save As")
with ui.Menu("Edit", key="Edit", disabled=True):
ui.Command("Cut", shortcut="Ctrl+X")
ui.Command("Copy", shortcut="Ctrl+C")
ui.Command("Paste", shortcut="Ctrl+V")
Source code in guitk/menu.py
380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 |
|
MenuSeparator
Bases: Menu
Separator that adds a dividing line between menu items.
Examples:
import guitk as ui
class MenuDemo(ui.Window):
def config(self):
with ui.VLayout():
ui.Label("This window has menus!")
with ui.MenuBar():
with ui.Menu("File"):
ui.Command("Open...", shortcut="Ctrl+O")
with ui.SubMenu("Open Recent"):
ui.Command("File 1")
ui.Command("File 2")
ui.Command("File 3")
ui.MenuSeparator()
ui.Command("Save", key="File|Save", disabled=True)
ui.Command("Save As")
with ui.Menu("Edit", key="Edit", disabled=True):
ui.Command("Cut", shortcut="Ctrl+X")
ui.Command("Copy", shortcut="Ctrl+C")
ui.Command("Paste", shortcut="Ctrl+V")
Source code in guitk/menu.py
329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 |
|
__init__()
Create a new MenuSeparator
Source code in guitk/menu.py
359 360 361 |
|