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

make the icon of header configurable #5358

Open
python-and-fiction opened this issue Dec 8, 2024 · 1 comment
Open

make the icon of header configurable #5358

python-and-fiction opened this issue Dec 8, 2024 · 1 comment

Comments

@python-and-fiction
Copy link

python-and-fiction commented Dec 8, 2024

After I set ENABLE_COMMAND_PALETTE = False, I founded that the icon in header is still showing the tooltip about palette.
Maybe we can do something like the following code make the icon of header configurable.

from textual.widgets import Header
from textual.widgets._header import HeaderTitle, HeaderClock, HeaderClockSpace, HeaderIcon

class HeaderWithIcon(Header):
    def __init__(self, show_clock: bool = False, show_icon: bool = True, *, name: str | None = None, id: str | None = None, classes: str | None = None, icon: str | None = None, time_format: str | None = None):
        super().__init__(show_clock, name=name, id=id, classes=classes, icon=icon, time_format=time_format)
        self._show_icon = show_icon
        self.header_icon = HeaderIcon()
        self.header_icon.visible = self._show_icon    

    def compose(self):
        self.header_icon.data_bind(Header.icon)
        yield self.header_icon
        yield HeaderTitle()
        yield (
            HeaderClock().data_bind(Header.time_format)
            if self._show_clock
            else HeaderClockSpace()
        )
Header = HeaderWithIcon

By the hack way, I can change the visible and the tooltip of the icon:

h = Header()
h.header_icon.tooltip = 'No palette'
Copy link

github-actions bot commented Dec 8, 2024

We found the following entries in the FAQ which you may find helpful:

Feel free to close this issue if you found an answer in the FAQ. Otherwise, please give us a little time to review.

This is an automated reply, generated by FAQtory

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant