-
Notifications
You must be signed in to change notification settings - Fork 815
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add month calendar #3667
Draft
TomJGooding
wants to merge
97
commits into
Textualize:main
Choose a base branch
from
TomJGooding:feat-add-month-calendar
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
feat: add month calendar #3667
Changes from 66 commits
Commits
Show all changes
97 commits
Select commit
Hold shift + click to select a range
38e3fb6
feat: add month calendar
TomJGooding 9c9d4c2
impoort future annotations
TomJGooding d4fb00c
update reactives and remove compute method
TomJGooding acdfc87
remove unused var import
TomJGooding 073c3cd
add provisional watch methods for year and month
TomJGooding ab1aa6d
add show cursor
TomJGooding 684b2be
add previous and next year methods
TomJGooding c0d44e8
add previous and next month methods
TomJGooding 5cc2b85
add method to get date coordinate
TomJGooding 055d788
add move cursor method
TomJGooding 5bd8bc2
experiment with adding pauses to tests for ci
TomJGooding 7939c54
Merge branch 'main' into feat-add-month-calendar
TomJGooding 53b1ae6
precommit isort
TomJGooding 7a7266e
remove old pauses in tests
TomJGooding 56b380a
add is_current_month property
TomJGooding 4e139c9
watch reactive first weekday change
TomJGooding d6cec28
add default cursor date
TomJGooding 42de0f9
update cursor date on cell highlighted
TomJGooding 726274b
add bindings to example
TomJGooding cfcac14
add basic default css
TomJGooding caea6eb
Merge branch 'main' into feat-add-month-calendar
TomJGooding 334e771
update cursor date with relative delta
TomJGooding 5a5eed2
Merge branch 'main' of github.com:Textualize/textual into feat-add-mo…
darrenburns 9779e63
Merge branch 'main' into feat-add-month-calendar
TomJGooding c75950c
change to single date reactive
TomJGooding 2d5e5c3
fix unnecessarily rebuilding table
TomJGooding 0af9260
persist hover after table updates
TomJGooding 66812c1
add option to show other months
TomJGooding d08c0b3
center example
TomJGooding 5c14a92
add date selected message
TomJGooding 8a8733f
make calendar dates property private
TomJGooding 3d659dc
simplify calendar dates
TomJGooding 20f0875
change calendar to six weeks
TomJGooding 86640ef
update calendar dates docstring
TomJGooding cbde850
add date highlighted message
TomJGooding 4298ae1
add pause to messages test
TomJGooding ea45e94
Merge branch 'main' into feat-add-month-calendar
TomJGooding f85e8b5
stop table header selected message
TomJGooding 1a3d851
fix typing in test app
TomJGooding e16cb16
cache calendar dates
TomJGooding 80a5f08
fix coordinate search when unnecessary
TomJGooding 2cd2fd6
make cursor coord unpacking consistent
TomJGooding 7f8e432
add binding to test app to toggle show other months
TomJGooding 3c2153e
watch hover coordinate to hide cursor for blank cell
TomJGooding d690d86
hide hover cursor if blank cell clicked
TomJGooding ddbb109
check if cell selected is blank
TomJGooding a28279e
extend hide other months tests
TomJGooding ca82691
attempt to improve typing
TomJGooding 87e956e
Merge branch 'main' into feat-add-month-calendar
TomJGooding 9574f4c
Merge branch 'main' into feat-add-month-calendar
TomJGooding 3da2661
Merge branch 'main' into feat-add-month-calendar
TomJGooding ec1fa19
add note about python-dateutil
TomJGooding 6d56462
Merge branch 'main' into feat-add-month-calendar
TomJGooding f4549ca
fix performance issues using set_reactive
TomJGooding 1e3678d
add custom month calendar table
TomJGooding fa9ad42
add bindings for previous/next month and year
TomJGooding 5d90bfd
rename private table message handlers
TomJGooding 1a826f4
add todo for handling blank cells
TomJGooding f4ecbd8
update calendar when up/down pressed on first/last row
TomJGooding 1689d31
add cursor wrap around to previous/next date
TomJGooding 1e1168a
refactor tests with reusable app class
TomJGooding dc253f3
improve tests for up/down pressed on first/last row
TomJGooding 6a01d11
rename cursor key actions
TomJGooding a513aef
fix pageup/pagedown bindings
TomJGooding a2a7af4
Merge branch 'main' into feat-add-month-calendar
TomJGooding df43416
check show_other_months in prev/next month/year actions
TomJGooding 8662cab
change show_other_months to styling only
TomJGooding 4c8e701
Merge branch 'main' into feat-add-month-calendar
TomJGooding 631cde7
tweak styling and add todo for component classes
TomJGooding 07e8c5a
Merge branch 'main' into feat-add-month-calendar
TomJGooding 5cb7b7e
change to keyword arguments except date
TomJGooding 7e8b621
tidy ordering of methods
TomJGooding 3f7d56f
replace relativedelta with timedelta for days and weeks
TomJGooding e72df0b
add tests that prev/next month methods account for leap years
TomJGooding 6fa86ac
replace relativedelta in prev/next year methods
TomJGooding 328bf84
add tests that prev/next month methods account for leap/non-leap years
TomJGooding d44e3e5
replace relativedelta in prev/next month methods
TomJGooding 077bd63
replace remaining relativedelta instances and remove import
TomJGooding a7d13ab
tidy tests to help readability
TomJGooding 530adec
refactor _get_calendar_dates method
TomJGooding aec97b0
rename calendar table to grid
TomJGooding 6789b01
Merge branch 'main' into feat-add-month-calendar
TomJGooding c6efdde
Merge branch 'main' into feat-add-month-calendar
TomJGooding 694a24d
change to relative imports
TomJGooding 172fbbe
fix `today` by dropping the `()`
TomJGooding c9b7bd0
add class docstrings
TomJGooding ed0f127
Revert "change to relative imports"
TomJGooding e59d91c
add docstrings to messages
TomJGooding 69a1b2a
add docstrings for methods
TomJGooding 52e2f38
add docstrings for action methods
TomJGooding 9a92dee
Merge branch 'main' into feat-add-month-calendar
TomJGooding de46d7a
fix AttributeError by restoring order in init
TomJGooding 5c9c2be
Merge branch 'main' into feat-add-month-calendar
TomJGooding a6c38bb
update casing for binding descriptions
TomJGooding 6bf3b0a
improve handling of clicking blank cells
TomJGooding 773e8a0
fix crash when header clicked
TomJGooding cbf7540
Merge branch 'main' into feat-add-month-calendar
TomJGooding File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import datetime | ||
|
||
from textual.app import App, ComposeResult | ||
from textual.binding import Binding | ||
from textual.widgets import MonthCalendar | ||
|
||
|
||
class MonthCalendarApp(App): | ||
CSS = """ | ||
Screen { | ||
align: center middle; | ||
} | ||
""" | ||
|
||
BINDINGS = [ | ||
Binding("ctrl+s", "toggle_show_other_months"), | ||
] | ||
|
||
def compose(self) -> ComposeResult: | ||
yield MonthCalendar(datetime.date(year=2021, month=6, day=3)) | ||
|
||
def action_toggle_show_other_months(self) -> None: | ||
calendar = self.query_one(MonthCalendar) | ||
calendar.show_other_months = not calendar.show_other_months | ||
|
||
|
||
if __name__ == "__main__": | ||
app = MonthCalendarApp() | ||
app.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding a
CSS
variable containing the following CSS to this app yields better results. I reckon we should add the equivalent CSS to the widget itself to override the default DataTable behaviour (unless you can think of a reason not to).We don't do this in the
DataTable
itself because it's intended to scroll, but this widget has a very constrained height compared to theDataTable
which can be arbitrarily large.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I should have mentioned, I haven't started looking at the
DEFAULT_CSS
yet as I wanted to focus on the core functionality first. Do you think the table/columns widths should just be static, or allow the developer to specify the column width (or perhaps even grow dynamically according to the widget width)?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems sensible.
I think static for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've now added some basic
DEFAULT_CSS
in cfcac14. I've flaggedmin-width
as TODO as this might depend on locale?