Pickers
Note
These widgets are composed through a combination of selector and input widgets. To fully understand the picker functionality, it is recommended to read the aforementioned pages.
Info
All widgets have a .mini
CSS class which you can assign to these widgets, to convert them to a single line.
DatePicker¶
textual_timepiece.pickers.DatePicker
¶
Bases: BasePicker[DateInput, Date, DateOverlay]
Single date picker with an input and overlay.
PARAMETER | DESCRIPTION |
---|---|
date
|
Initial date for the picker.
TYPE:
|
name
|
Name for the widget.
TYPE:
|
id
|
DOM identifier for widget.
TYPE:
|
classes
|
Classes to add the widget.
TYPE:
|
date_range
|
Date range to lock the widget to.
TYPE:
|
disabled
|
Disable the widget.
TYPE:
|
validator
|
A callable that will validate and adjust the date if needed.
TYPE:
|
tooltip
|
A tooltip to show when hovering the widget.
TYPE:
|
Examples:
>>> def limit_dates(date: Date | None) -> Date | None:
>>> if date is None:
>>> return None
>>> return min(Date(2025, 2, 20), max(Date(2025, 2, 6), date))
>>> yield DatePicker(validator=limit_dates)
>>> yield DatePicker(
>>> Date.today_in_system_tz(),
>>> date_range=DateDelta(days=5),
>>> )
CLASS | DESCRIPTION |
---|---|
DateChanged |
Message sent when the date changed. |
METHOD | DESCRIPTION |
---|---|
action_clear |
Clear the date. |
to_default |
Reset the date to today. |
ATTRIBUTE | DESCRIPTION |
---|---|
DEFAULT_CSS |
TYPE:
|
BINDINGS |
All bindings for
TYPE:
|
DateValidator |
Callable type for validating date types.
TYPE:
|
date |
Current date for the picker. This is bound to every other subwidget.
|
Source code in src/textual_timepiece/pickers/_date_picker.py
966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 |
|
DEFAULT_CSS
class-attribute
¶
AbstractPicker {
layers: base dialog;
layout: vertical;
height: 3;
width: auto;
&.mini {
max-height: 1;
& > #input-control {
border: none;
height: 1;
padding: 0;
&:blur {
padding: 0;
}
&:focus-within {
padding: 0;
border: none;
}
Button, AbstractInput {
border: none;
padding: 0;
height: 1;
&:focus {
color: $accent;
text-style: none;
}
&:disabled {
opacity: 50%;
text-style: italic;
}
}
}
}
& > #input-control {
background: $surface;
width: auto;
&:blur {
padding: 1;
}
&:focus-within {
border: tall $primary;
padding: 0;
}
Button, AbstractInput {
border: none;
padding: 0;
height: 1;
&:focus {
color: $accent;
text-style: none;
}
}
& > TargetButton {
min-width: 1;
max-width: 3;
}
& > AbstractInput {
padding: 0 2;
&.-invalid {
color: $error;
text-style: italic;
}
&:focus {
tint: $primary 2%;
}
}
}
& > BaseOverlay {
border: round $secondary;
overlay: screen !important;
constrain: inside;
position: absolute;
height: auto;
width: auto;
background: $surface;
box-sizing: content-box;
opacity: 0;
&:focus,
&:focus-within {
border: round $primary;
}
& > BaseOverlayWidget {
width: 40;
height: auto;
}
}
}
BINDINGS
class-attribute
¶
BINDINGS: list[BindingType] = [
Binding(
"ctrl+shift+d",
"clear",
"Clear Value",
tooltip="Clear the current value.",
),
Binding(
"ctrl+t",
"target_default",
"To Default Value",
tooltip="Reset to the default value.",
),
]
All bindings for BasePicker
classes.
Key(s) | Description |
---|---|
ctrl+shift+d | Clear the current value. |
ctrl+t | Reset to the default value. |
DateValidator
class-attribute
instance-attribute
¶
Callable type for validating date types.
date
class-attribute
instance-attribute
¶
Current date for the picker. This is bound to every other subwidget.
DateChanged
dataclass
¶
Bases: BaseMessage
Message sent when the date changed.
Source code in src/textual_timepiece/pickers/_date_picker.py
992 993 994 995 996 997 |
|
action_clear
¶
action_clear() -> None
Clear the date.
Source code in src/textual_timepiece/pickers/_date_picker.py
1080 1081 1082 |
|
to_default
¶
to_default() -> None
Reset the date to today.
Source code in src/textual_timepiece/pickers/_date_picker.py
1084 1085 1086 1087 |
|
DurationPicker¶
textual_timepiece.pickers.DurationPicker
¶
Bases: BasePicker[DurationInput, TimeDelta, DurationOverlay]
Picker widget for picking durations.
Duration is limited 99 hours, 59 minutes and 59 seconds.
PARAMETER | DESCRIPTION |
---|---|
value
|
Initial duration value for the widget.
TYPE:
|
name
|
Name for the widget.
TYPE:
|
id
|
DOM identifier for the widget.
TYPE:
|
classes
|
CSS classes for the widget
TYPE:
|
disabled
|
Whether to disable the widget.
TYPE:
|
tooltip
|
Tooltip to show on hover.
TYPE:
|
CLASS | DESCRIPTION |
---|---|
DurationChanged |
Message sent when the duration changes. |
METHOD | DESCRIPTION |
---|---|
to_default |
Reset the duration to 00:00:00. |
ATTRIBUTE | DESCRIPTION |
---|---|
DEFAULT_CSS |
TYPE:
|
BINDINGS |
All bindings for
TYPE:
|
duration |
Current duration. Bound to all the child widgets.
|
Source code in src/textual_timepiece/pickers/_time_picker.py
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 |
|
DEFAULT_CSS
class-attribute
¶
AbstractPicker {
layers: base dialog;
layout: vertical;
height: 3;
width: auto;
&.mini {
max-height: 1;
& > #input-control {
border: none;
height: 1;
padding: 0;
&:blur {
padding: 0;
}
&:focus-within {
padding: 0;
border: none;
}
Button, AbstractInput {
border: none;
padding: 0;
height: 1;
&:focus {
color: $accent;
text-style: none;
}
&:disabled {
opacity: 50%;
text-style: italic;
}
}
}
}
& > #input-control {
background: $surface;
width: auto;
&:blur {
padding: 1;
}
&:focus-within {
border: tall $primary;
padding: 0;
}
Button, AbstractInput {
border: none;
padding: 0;
height: 1;
&:focus {
color: $accent;
text-style: none;
}
}
& > TargetButton {
min-width: 1;
max-width: 3;
}
& > AbstractInput {
padding: 0 2;
&.-invalid {
color: $error;
text-style: italic;
}
&:focus {
tint: $primary 2%;
}
}
}
& > BaseOverlay {
border: round $secondary;
overlay: screen !important;
constrain: inside;
position: absolute;
height: auto;
width: auto;
background: $surface;
box-sizing: content-box;
opacity: 0;
&:focus,
&:focus-within {
border: round $primary;
}
& > BaseOverlayWidget {
width: 40;
height: auto;
}
}
}
BINDINGS
class-attribute
¶
BINDINGS: list[BindingType] = [
Binding(
"ctrl+shift+d",
"clear",
"Clear Value",
tooltip="Clear the current value.",
),
Binding(
"ctrl+t",
"target_default",
"To Default Value",
tooltip="Reset to the default value.",
),
]
All bindings for BasePicker
classes.
Key(s) | Description |
---|---|
ctrl+shift+d | Clear the current value. |
ctrl+t | Reset to the default value. |
duration
class-attribute
instance-attribute
¶
Current duration. Bound to all the child widgets.
DurationChanged
dataclass
¶
Bases: BaseMessage
Message sent when the duration changes.
Source code in src/textual_timepiece/pickers/_time_picker.py
402 403 404 405 406 407 |
|
to_default
¶
to_default() -> None
Reset the duration to 00:00:00.
Source code in src/textual_timepiece/pickers/_time_picker.py
470 471 472 |
|
TimePicker¶
textual_timepiece.pickers.TimePicker
¶
Bases: BasePicker[TimeInput, Time, TimeOverlay]
Time picker for a 24 hour clock.
PARAMETER | DESCRIPTION |
---|---|
value
|
Initial time for the widget.
TYPE:
|
name
|
Name for the widget.
TYPE:
|
id
|
DOM identifier for the widget.
TYPE:
|
classes
|
CSS classes for the widget
TYPE:
|
disabled
|
Whether to disable the widget.
TYPE:
|
tooltip
|
Tooltip to show on hover.
TYPE:
|
CLASS | DESCRIPTION |
---|---|
TimeChanged |
Sent when the time is changed with the overlay or other means. |
METHOD | DESCRIPTION |
---|---|
to_default |
Reset time to the local current time. |
ATTRIBUTE | DESCRIPTION |
---|---|
DEFAULT_CSS |
TYPE:
|
BINDINGS |
All bindings for
TYPE:
|
time |
Currently set time that is bound to the subwidgets. None if empty.
|
Source code in src/textual_timepiece/pickers/_time_picker.py
583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 |
|
DEFAULT_CSS
class-attribute
¶
AbstractPicker {
layers: base dialog;
layout: vertical;
height: 3;
width: auto;
&.mini {
max-height: 1;
& > #input-control {
border: none;
height: 1;
padding: 0;
&:blur {
padding: 0;
}
&:focus-within {
padding: 0;
border: none;
}
Button, AbstractInput {
border: none;
padding: 0;
height: 1;
&:focus {
color: $accent;
text-style: none;
}
&:disabled {
opacity: 50%;
text-style: italic;
}
}
}
}
& > #input-control {
background: $surface;
width: auto;
&:blur {
padding: 1;
}
&:focus-within {
border: tall $primary;
padding: 0;
}
Button, AbstractInput {
border: none;
padding: 0;
height: 1;
&:focus {
color: $accent;
text-style: none;
}
}
& > TargetButton {
min-width: 1;
max-width: 3;
}
& > AbstractInput {
padding: 0 2;
&.-invalid {
color: $error;
text-style: italic;
}
&:focus {
tint: $primary 2%;
}
}
}
& > BaseOverlay {
border: round $secondary;
overlay: screen !important;
constrain: inside;
position: absolute;
height: auto;
width: auto;
background: $surface;
box-sizing: content-box;
opacity: 0;
&:focus,
&:focus-within {
border: round $primary;
}
& > BaseOverlayWidget {
width: 40;
height: auto;
}
}
}
BINDINGS
class-attribute
¶
BINDINGS: list[BindingType] = [
Binding(
"ctrl+shift+d",
"clear",
"Clear Value",
tooltip="Clear the current value.",
),
Binding(
"ctrl+t",
"target_default",
"To Default Value",
tooltip="Reset to the default value.",
),
]
All bindings for BasePicker
classes.
Key(s) | Description |
---|---|
ctrl+shift+d | Clear the current value. |
ctrl+t | Reset to the default value. |
time
class-attribute
instance-attribute
¶
Currently set time that is bound to the subwidgets. None if empty.
TimeChanged
dataclass
¶
Bases: BaseMessage
Sent when the time is changed with the overlay or other means.
Source code in src/textual_timepiece/pickers/_time_picker.py
595 596 597 598 599 600 |
|
to_default
¶
to_default() -> None
Reset time to the local current time.
Source code in src/textual_timepiece/pickers/_time_picker.py
641 642 643 |
|
DateTimePicker¶
textual_timepiece.pickers.DateTimePicker
¶
Bases: BasePicker[DateTimeInput, LocalDateTime, DateTimeOverlay]
Datetime picker with a date and time in one input.
PARAMETER | DESCRIPTION |
---|---|
value
|
Initial datetime value for the widget.
TYPE:
|
name
|
Name for the widget.
TYPE:
|
id
|
DOM identifier for the widget.
TYPE:
|
classes
|
CSS classes for the widget
TYPE:
|
disabled
|
Whether to disable the widget.
TYPE:
|
tooltip
|
Tooltip to show on hover.
TYPE:
|
CLASS | DESCRIPTION |
---|---|
DateTimeChanged |
Message sent when the datetime is updated. |
METHOD | DESCRIPTION |
---|---|
to_default |
Reset the picker datetime to the current time. |
ATTRIBUTE | DESCRIPTION |
---|---|
DEFAULT_CSS |
TYPE:
|
BINDINGS |
All bindings for
TYPE:
|
datetime |
The current set datetime. Bound of to all subwidgets.
|
date |
Computed date based on the datetime for the overlay.
|
Source code in src/textual_timepiece/pickers/_datetime_picker.py
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 |
|
DEFAULT_CSS
class-attribute
¶
AbstractPicker {
layers: base dialog;
layout: vertical;
height: 3;
width: auto;
&.mini {
max-height: 1;
& > #input-control {
border: none;
height: 1;
padding: 0;
&:blur {
padding: 0;
}
&:focus-within {
padding: 0;
border: none;
}
Button, AbstractInput {
border: none;
padding: 0;
height: 1;
&:focus {
color: $accent;
text-style: none;
}
&:disabled {
opacity: 50%;
text-style: italic;
}
}
}
}
& > #input-control {
background: $surface;
width: auto;
&:blur {
padding: 1;
}
&:focus-within {
border: tall $primary;
padding: 0;
}
Button, AbstractInput {
border: none;
padding: 0;
height: 1;
&:focus {
color: $accent;
text-style: none;
}
}
& > TargetButton {
min-width: 1;
max-width: 3;
}
& > AbstractInput {
padding: 0 2;
&.-invalid {
color: $error;
text-style: italic;
}
&:focus {
tint: $primary 2%;
}
}
}
& > BaseOverlay {
border: round $secondary;
overlay: screen !important;
constrain: inside;
position: absolute;
height: auto;
width: auto;
background: $surface;
box-sizing: content-box;
opacity: 0;
&:focus,
&:focus-within {
border: round $primary;
}
& > BaseOverlayWidget {
width: 40;
height: auto;
}
}
}
BINDINGS
class-attribute
¶
BINDINGS: list[BindingType] = [
Binding(
"ctrl+shift+d",
"clear",
"Clear Value",
tooltip="Clear the current value.",
),
Binding(
"ctrl+t",
"target_default",
"To Default Value",
tooltip="Reset to the default value.",
),
]
All bindings for BasePicker
classes.
Key(s) | Description |
---|---|
ctrl+shift+d | Clear the current value. |
ctrl+t | Reset to the default value. |
datetime
class-attribute
instance-attribute
¶
datetime = var[LocalDateTime | None](None, init=False)
The current set datetime. Bound of to all subwidgets.
date
class-attribute
instance-attribute
¶
Computed date based on the datetime for the overlay.
DateTimeChanged
dataclass
¶
Bases: BaseMessage
Message sent when the datetime is updated.
Source code in src/textual_timepiece/pickers/_datetime_picker.py
227 228 229 230 231 232 |
|
to_default
¶
to_default() -> None
Reset the picker datetime to the current time.
Source code in src/textual_timepiece/pickers/_datetime_picker.py
313 314 315 316 |
|
DateRangePicker¶
textual_timepiece.pickers.DateRangePicker
¶
Bases: AbstractPicker[DateRangeOverlay]
Date range picker for picking inclusive date ranges.
PARAMETER | DESCRIPTION |
---|---|
start
|
Initial start date for the picker.
TYPE:
|
end
|
Initial end date for the picker.
TYPE:
|
name
|
Name for the widget.
TYPE:
|
id
|
DOM identifier for the widget.
TYPE:
|
classes
|
CSS classes for the widget
TYPE:
|
date_range
|
Date range to restrict the date to. If provided the picker lock will be permanently on for the widgets lifetime or when re-enabled programmatically.
TYPE:
|
disabled
|
Whether to disable the widget
TYPE:
|
tooltip
|
Tooltip to show on hover.
TYPE:
|
Examples:
def compose(self) -> ComposeResult:
yield DateRangePicker(Date(2025, 2, 1), Date(2025, 3, 1))
def compose(self) -> ComposeResult:
yield DateRangePicker(Date.today_in_system_tz()).disable_end()
def action_stop(self) -> None:
pick = self.query_one(DateRangePicker)
pick.disable_end(disable=False)
pick.end_date = Date.today_in_system_tz()
CLASS | DESCRIPTION |
---|---|
DateRangeChanged |
Message sent when the date range has changed. |
METHOD | DESCRIPTION |
---|---|
action_clear |
Clear the start and end dates. |
disable_start |
Utility method to disable start input widgets. |
disable_end |
Utility method to disable end input widgets. |
ATTRIBUTE | DESCRIPTION |
---|---|
DEFAULT_CSS |
TYPE:
|
BINDINGS |
All bindings for
TYPE:
|
start_date |
Picker start date. Bound to sub widgets.
|
end_date |
Picker end date. Bound to sub widgets.
|
Source code in src/textual_timepiece/pickers/_timerange_picker.py
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 |
|
DEFAULT_CSS
class-attribute
¶
AbstractPicker {
layers: base dialog;
layout: vertical;
height: 3;
width: auto;
&.mini {
max-height: 1;
& > #input-control {
border: none;
height: 1;
padding: 0;
&:blur {
padding: 0;
}
&:focus-within {
padding: 0;
border: none;
}
Button, AbstractInput {
border: none;
padding: 0;
height: 1;
&:focus {
color: $accent;
text-style: none;
}
&:disabled {
opacity: 50%;
text-style: italic;
}
}
}
}
& > #input-control {
background: $surface;
width: auto;
&:blur {
padding: 1;
}
&:focus-within {
border: tall $primary;
padding: 0;
}
Button, AbstractInput {
border: none;
padding: 0;
height: 1;
&:focus {
color: $accent;
text-style: none;
}
}
& > TargetButton {
min-width: 1;
max-width: 3;
}
& > AbstractInput {
padding: 0 2;
&.-invalid {
color: $error;
text-style: italic;
}
&:focus {
tint: $primary 2%;
}
}
}
& > BaseOverlay {
border: round $secondary;
overlay: screen !important;
constrain: inside;
position: absolute;
height: auto;
width: auto;
background: $surface;
box-sizing: content-box;
opacity: 0;
&:focus,
&:focus-within {
border: round $primary;
}
& > BaseOverlayWidget {
width: 40;
height: auto;
}
}
}
BINDINGS
class-attribute
¶
BINDINGS: list[BindingType] = [
Binding(
"ctrl+shift+d",
"clear",
"Clear Dates",
tooltip="Clear both the start and end date.",
),
Binding(
"ctrl+t",
"target_default_start",
"Start To Today",
tooltip="Set the start date to todays date.",
),
Binding(
"alt+ctrl+t",
"target_default_end",
"End To Today",
tooltip="Set the end date to today or the start date.",
),
]
All bindings for DateTimeRangePicker
.
Key(s) | Description |
---|---|
ctrl+shift+d | Clear end and start datetime. |
ctrl+t | Set the start date to todays date. |
alt+ctrl+t | Set the end date to today or the start date. |
start_date
class-attribute
instance-attribute
¶
Picker start date. Bound to sub widgets.
end_date
class-attribute
instance-attribute
¶
Picker end date. Bound to sub widgets.
DateRangeChanged
dataclass
¶
Bases: BaseMessage
Message sent when the date range has changed.
Source code in src/textual_timepiece/pickers/_timerange_picker.py
102 103 104 105 106 107 108 |
|
action_clear
¶
action_clear() -> None
Clear the start and end dates.
Source code in src/textual_timepiece/pickers/_timerange_picker.py
270 271 272 273 |
|
disable_start
¶
Utility method to disable start input widgets.
Source code in src/textual_timepiece/pickers/_timerange_picker.py
275 276 277 278 279 280 281 282 |
|
disable_end
¶
Utility method to disable end input widgets.
Source code in src/textual_timepiece/pickers/_timerange_picker.py
284 285 286 287 288 289 290 291 |
|
DateTimeRangePicker¶
textual_timepiece.pickers.DateTimeRangePicker
¶
Bases: AbstractPicker[DateTimeRangeOverlay]
Datetime range picker with two datetime inputs.
PARAMETER | DESCRIPTION |
---|---|
start
|
Initial start datetime for the picker.
TYPE:
|
end
|
Initial end datetime for the picker.
TYPE:
|
name
|
Name for the widget.
TYPE:
|
id
|
DOM identifier for the widget.
TYPE:
|
classes
|
CSS classes for the widget
TYPE:
|
time_range
|
Time range to restrict the datetimes to. If provided the picker lock will be permanently on for the widgets lifetime or re-enabled programmatically.
TYPE:
|
disabled
|
Whether to disable the widget
TYPE:
|
tooltip
|
Tooltip to show on hover.
TYPE:
|
Examples:
def compose(self) -> ComposeResult:
now = SystemDateTime.now().local()
yield DateTimeRangePicker(now, time_range=TimeDelta(hours=5))
def compose(self) -> ComposeResult:
yield DateTimeRangePicker(SystemDateTime.now().local())
def action_stop(self) -> None:
pick = self.query_one(DateTimeRangePicker)
pick.end_dt = SystemDateTime.now().local()
CLASS | DESCRIPTION |
---|---|
DTRangeChanged |
Message sent when the datetime range has changed. |
METHOD | DESCRIPTION |
---|---|
adjust_start_date |
Set or clear the current start date depending on the input. |
adjust_end_date |
Set or clear the current end date depending on the input. |
action_clear |
Clear the start and end datetimes. |
disable_start |
Utility method to disable start input widgets. |
disable_end |
Utility method to disable end input widgets. |
ATTRIBUTE | DESCRIPTION |
---|---|
DEFAULT_CSS |
TYPE:
|
BINDINGS |
All bindings for
TYPE:
|
start_dt |
Picker start datetime. Bound to all the parent widgets.
|
end_dt |
Picker end datetime. Bound to all the parent widgets.
|
start_date |
Start date dynamically computed depending on start datetime.
|
end_date |
End date dynamically computed depending on the end datetime.
|
Source code in src/textual_timepiece/pickers/_timerange_picker.py
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 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 |
|
DEFAULT_CSS
class-attribute
¶
AbstractPicker {
layers: base dialog;
layout: vertical;
height: 3;
width: auto;
&.mini {
max-height: 1;
& > #input-control {
border: none;
height: 1;
padding: 0;
&:blur {
padding: 0;
}
&:focus-within {
padding: 0;
border: none;
}
Button, AbstractInput {
border: none;
padding: 0;
height: 1;
&:focus {
color: $accent;
text-style: none;
}
&:disabled {
opacity: 50%;
text-style: italic;
}
}
}
}
& > #input-control {
background: $surface;
width: auto;
&:blur {
padding: 1;
}
&:focus-within {
border: tall $primary;
padding: 0;
}
Button, AbstractInput {
border: none;
padding: 0;
height: 1;
&:focus {
color: $accent;
text-style: none;
}
}
& > TargetButton {
min-width: 1;
max-width: 3;
}
& > AbstractInput {
padding: 0 2;
&.-invalid {
color: $error;
text-style: italic;
}
&:focus {
tint: $primary 2%;
}
}
}
& > BaseOverlay {
border: round $secondary;
overlay: screen !important;
constrain: inside;
position: absolute;
height: auto;
width: auto;
background: $surface;
box-sizing: content-box;
opacity: 0;
&:focus,
&:focus-within {
border: round $primary;
}
& > BaseOverlayWidget {
width: 40;
height: auto;
}
}
}
BINDINGS
class-attribute
¶
BINDINGS: list[BindingType] = [
Binding(
"ctrl+shift+d",
"clear",
"Clear",
tooltip="Clear end and start datetime.",
),
Binding(
"ctrl+t",
"target_default_start",
"Start To Today",
tooltip="Set the start datetime to now.",
),
Binding(
"alt+ctrl+t",
"target_default_end",
"End To Today",
tooltip="Set the end datetime to now or the start datetime.",
),
]
All bindings for DateTimeRangePicker
.
Key(s) | Description |
---|---|
ctrl+shift+d | Clear end and start datetime. |
ctrl+t | Set the start datetime to now. |
alt+ctrl+t | Set the end datetime to now or the start datetime. |
start_dt
class-attribute
instance-attribute
¶
start_dt = var[LocalDateTime | None](None, init=False)
Picker start datetime. Bound to all the parent widgets.
end_dt
class-attribute
instance-attribute
¶
end_dt = var[LocalDateTime | None](None, init=False)
Picker end datetime. Bound to all the parent widgets.
start_date
class-attribute
instance-attribute
¶
Start date dynamically computed depending on start datetime.
end_date
class-attribute
instance-attribute
¶
End date dynamically computed depending on the end datetime.
DTRangeChanged
dataclass
¶
Bases: BaseMessage
Message sent when the datetime range has changed.
Source code in src/textual_timepiece/pickers/_timerange_picker.py
375 376 377 378 379 380 381 |
|
adjust_start_date
¶
adjust_start_date(date: Date | None) -> None
Set or clear the current start date depending on the input.
Source code in src/textual_timepiece/pickers/_timerange_picker.py
534 535 536 537 538 539 540 541 |
|
adjust_end_date
¶
adjust_end_date(date: Date | None) -> None
Set or clear the current end date depending on the input.
Source code in src/textual_timepiece/pickers/_timerange_picker.py
543 544 545 546 547 548 549 550 |
|
action_clear
¶
action_clear() -> None
Clear the start and end datetimes.
Source code in src/textual_timepiece/pickers/_timerange_picker.py
552 553 554 555 |
|
disable_start
¶
Utility method to disable start input widgets.
Source code in src/textual_timepiece/pickers/_timerange_picker.py
601 602 603 604 605 606 |
|
disable_end
¶
Utility method to disable end input widgets.
Source code in src/textual_timepiece/pickers/_timerange_picker.py
608 609 610 611 612 613 |
|
DateTimeDurationPicker¶
textual_timepiece.pickers.DateTimeDurationPicker
¶
Bases: DateTimeRangePicker
Datetime range with a duration input in the middle.
Duration display up to 99:99:99. Use the DateTimeRangePicker picker if a longer duration is required.
PARAMETER | DESCRIPTION |
---|---|
start
|
Initial start datetime for the picker.
TYPE:
|
end
|
Initial end datetime for the picker.
TYPE:
|
name
|
Name for the widget.
TYPE:
|
id
|
DOM identifier for the widget.
TYPE:
|
classes
|
CSS classes for the widget
TYPE:
|
time_range
|
Time range to restrict the datetimes to. If provided the picker lock will be permanently on for the widgets lifetime or re-enabled programmatically.
TYPE:
|
disabled
|
Whether to disable the widget
TYPE:
|
tooltip
|
Tooltip to show on hover.
TYPE:
|
ATTRIBUTE | DESCRIPTION |
---|---|
DEFAULT_CSS |
TYPE:
|
BINDINGS |
All bindings for
TYPE:
|
duration |
Duration between start and end datetimes. Computed dynamically.
|
Source code in src/textual_timepiece/pickers/_timerange_picker.py
650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 |
|
DEFAULT_CSS
class-attribute
¶
AbstractPicker {
layers: base dialog;
layout: vertical;
height: 3;
width: auto;
&.mini {
max-height: 1;
& > #input-control {
border: none;
height: 1;
padding: 0;
&:blur {
padding: 0;
}
&:focus-within {
padding: 0;
border: none;
}
Button, AbstractInput {
border: none;
padding: 0;
height: 1;
&:focus {
color: $accent;
text-style: none;
}
&:disabled {
opacity: 50%;
text-style: italic;
}
}
}
}
& > #input-control {
background: $surface;
width: auto;
&:blur {
padding: 1;
}
&:focus-within {
border: tall $primary;
padding: 0;
}
Button, AbstractInput {
border: none;
padding: 0;
height: 1;
&:focus {
color: $accent;
text-style: none;
}
}
& > TargetButton {
min-width: 1;
max-width: 3;
}
& > AbstractInput {
padding: 0 2;
&.-invalid {
color: $error;
text-style: italic;
}
&:focus {
tint: $primary 2%;
}
}
}
& > BaseOverlay {
border: round $secondary;
overlay: screen !important;
constrain: inside;
position: absolute;
height: auto;
width: auto;
background: $surface;
box-sizing: content-box;
opacity: 0;
&:focus,
&:focus-within {
border: round $primary;
}
& > BaseOverlayWidget {
width: 40;
height: auto;
}
}
}
BINDINGS
class-attribute
¶
BINDINGS: list[BindingType] = [
Binding(
"ctrl+shift+d",
"clear",
"Clear",
tooltip="Clear end and start datetime.",
),
Binding(
"ctrl+t",
"target_default_start",
"Start To Today",
tooltip="Set the start datetime to now.",
),
Binding(
"alt+ctrl+t",
"target_default_end",
"End To Today",
tooltip="Set the end datetime to now or the start datetime.",
),
]
All bindings for DateTimeRangePicker
.
Key(s) | Description |
---|---|
ctrl+shift+d | Clear end and start datetime. |
ctrl+t | Set the start datetime to now. |
alt+ctrl+t | Set the end datetime to now or the start datetime. |