Skip to content
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

Allow header clock to display dates #4671

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/textual/widgets/_header.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class HeaderClockSpace(Widget):
DEFAULT_CSS = """
HeaderClockSpace {
dock: right;
width: 10;
width: auto;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this cause the title to change position, with a long date?

padding: 0 1;
}
"""
Expand Down Expand Up @@ -89,7 +89,7 @@ def render(self) -> RenderResult:
Returns:
The rendered clock.
"""
return Text(datetime.now().time().strftime(self.time_format))
return Text(datetime.now().strftime(self.time_format))


class HeaderTitle(Widget):
Expand Down Expand Up @@ -146,7 +146,7 @@ class Header(Widget):
"""A character for the icon at the top left."""

time_format: Reactive[str] = Reactive("%X")
"""Time format of the clock."""
"""Datetime format of the clock."""

def __init__(
self,
Expand All @@ -166,7 +166,7 @@ def __init__(
id: The ID of the header widget in the DOM.
classes: The CSS classes of the header widget.
icon: Single character to use as an icon, or `None` for default.
time_format: Time format (used by strftime) for clock, or `None` for default.
time_format: Time/date format (used by strftime) for clock, or `None` for default.
"""
super().__init__(name=name, id=id, classes=classes)
self._show_clock = show_clock
Expand Down