Pickers#
These are the dialog classes behind Querybox.get_date(),
Querybox.get_color(), and Querybox.get_font(). Querybox
constructs them for you and hands back the result, but you can construct any of
them directly when you want more control over placement, styling, or lifecycle.
DatePickerDialog#
A calendar popup for choosing a date. It opens near the parent widget, lets the user page through months, and returns the selected day.
Options#
Set these on the constructor —
DatePickerDialog(parent=None, title=" ", first_weekday=6, start_date=None, bootstyle="primary", autoshow=True, show_outside_days=True).
Option |
Type |
Description |
|---|---|---|
|
|
The window to position near and block. Defaults to the application root. |
|
|
The text shown on the window’s title bar. |
|
|
The leftmost weekday column, |
|
|
The date shown selected initially. Defaults to today. |
|
|
The calendar’s accent color. Default |
|
|
Display immediately on construction. Default |
|
|
Show days spilling in from the adjacent months. Default |
Methods#
- show(position=None, wait_for_result=True)
Display the dialog. Blocks until the user picks a date or cancels, then stores the outcome on
result.- Parameters:
position – An
(x, y)top-left screen position. Positioned nearparentby default.wait_for_result – Block until the dialog closes. Default
True.
- Returns:
None— readresultafter it returns.
- result
The chosen
datetime.date, orNoneif cancelled.
FontDialog#
A font selector for choosing a family, size, weight, slant, and effects, with a
live preview of the current selection. A Dialog subclass, so it also carries
the base Dialog interface
(close(), the create_* build hooks, …).
Options#
Set these on the constructor —
FontDialog(title="Font Selector", parent=None, default_font="TkDefaultFont").
Option |
Type |
Description |
|---|---|---|
|
|
The text shown on the window’s title bar. Default |
|
|
The window to center over and block. Defaults to the application root. |
|
|
The named font shown selected initially. Default |
Methods#
- show(position=None, wait_for_result=True)
Display the dialog. Blocks until the user picks a font or cancels, then stores the outcome on
result.- Parameters:
position – An
(x, y)top-left screen position. Centered onparentby default.wait_for_result – Block until the dialog closes. Default
True.
- Returns:
None— readresultafter it returns.
- result
The chosen
Font, orNoneif cancelled.
ColorChooserDialog#
A color picker with color-model sliders and a preview. The user can adjust the
sliders, enter a value, or reach the eyedropper (ColorDropperDialog)
to sample a color from the screen. A Dialog subclass, so it also carries
the base Dialog interface
(close(), the create_* build hooks, …).
Options#
Set these on the constructor —
ColorChooserDialog(parent=None, title="Color Chooser", initialcolor=None).
Option |
Type |
Description |
|---|---|---|
|
|
The window to center over and block. Defaults to the application root. |
|
|
The text shown on the window’s title bar. Default |
|
|
The color selected initially, a hex string like |
Methods#
- show(position=None, wait_for_result=True)
Display the dialog. Blocks until the user picks a color or cancels, then stores the outcome on
result.- Parameters:
position – An
(x, y)top-left screen position. Centered onparentby default.wait_for_result – Block until the dialog closes. Default
True.
- Returns:
None— readresultafter it returns.
- result
The chosen color, or
Noneif cancelled.
ColorDropperDialog#
An eyedropper that picks the color of any pixel on screen — the same dropper
reachable from ColorChooserDialog. It takes over the screen so the
next click samples the color under the cursor.
Methods#
The constructor takes no arguments — ColorDropperDialog().
- show()
Take over the screen; the next click picks the color under the cursor. A right-click or
Escapecancels. The outcome is stored onresult.- Returns:
None— readresultafter it returns.
- result
The picked color, or
Noneif cancelled.