-
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
Header Expansion #4611
Comments
This issue from some months ago might be relevant here - unfortunately I know that Textual haven't had the resources to review the |
Might be worth noting you can make the time in the Header toggleable between 12hr and 24hr like this from rich.text import Text
BINDINGS = [ ( "F12", "toggle_12hr_time", "Toggle 12/24 HR")]
def compose(self) -> ComposeResult:
yield Header()
def on_mount(self):
self.timefmt = False
def render_12hour_format(self):
return Text(datetime.now().time().strftime("%I:%M %p"))
def render_24hour_format(self):
return Text(datetime.now().time().strftime("%X"))
def action_toggle_12hr_time(self) -> None:
self.timefmt = not self.timefmt
self.query_one('Header HeaderClock').render = self.render_12hour_format if self.timefmt else self.render_24hour_format In theory you can do the same for the command palette |
Okay but what about the icon |
It could be done like this. from textual.app import App, ComposeResult
from textual.widgets import Header
from rich.text import Text
class MyApp(App):
def on_mount(self) -> None:
self.query_one("Header HeaderIcon").render = self.change_button
def change_button(self):
return Text("🦕")
def compose(self) -> ComposeResult:
yield Header()
if __name__ == "__main__":
MyApp().run() However I suggest you look at the widget files here I say that because this is how you can learn to tweak things. I knew I could change the header Icon by looking at the code here the HeaderIcon is a class inside the header so i know that I can find it in a query This approach is known as Monkey Patching
you may want to read up on Monkey Patching |
Don't forget to star the repository! Follow @textualizeio for Textual updates. |
Hi everyone!
So I was working on a project using textual, and I saw that 'Header' compared to other elements like 'Button' or 'Static' is neglected. So I want to add a little of work to the Header. First of the icon of the header '⭘' should be customizable so you can enter as an argument to header -> 'yield Header(header_icon='your_icon_here')', second I would change the clock to be possible to show in these formats:
so for example you want the 6 format so you do -> 'yield Header(show_clock=True,clock_style="full_date time_12h")'
That's all. I think I can do that my self. Let me know what you think.
The text was updated successfully, but these errors were encountered: