Skip to content

fix: add tooltips to help/close #203

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

Merged
merged 1 commit into from
Jul 22, 2025
Merged
Show file tree
Hide file tree
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
36 changes: 36 additions & 0 deletions src/uproot_browser/tui/browser.css
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,39 @@ HelpScreen {
height: 3;
background: $surface-lighten-1;
}


HeaderCloseIcon {
dock: left;
border: none;
min-width: 3;
}

HeaderCloseIcon:hover {
background: $panel-lighten-2;
}

HeaderHelpIcon {
dock: right;
padding: 0 1;
border: none;
min-width: 4;
content-align: right middle;
}

HeaderHelpIcon:hover {
background: $panel-lighten-2;
}

HeaderTitle {
content-align: center middle;
width: 100%;
}

Header {
dock: top;
width: 100%;
background: $foreground 5%;
color: $text;
height: 1;
}
56 changes: 5 additions & 51 deletions src/uproot_browser/tui/header.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,61 +7,25 @@
import textual.app
import textual.reactive
import textual.widget
import textual.widgets

if typing.TYPE_CHECKING:
from .browser import Browser


class HeaderCloseIcon(textual.widget.Widget):
DEFAULT_CSS = """
HeaderCloseIcon {
dock: left;
padding: 0 1;
width: 4;
content-align: left middle;
}
HeaderCloseIcon:hover {
background: $panel-lighten-2;
}
"""

def render(self) -> textual.app.RenderResult:
return "❌"

class HeaderCloseIcon(textual.widgets.Button):
def on_click(self) -> None:
self.app.exit()


class HeaderHelpIcon(textual.widget.Widget):
DEFAULT_CSS = """
HeaderHelpIcon {
dock: right;
padding: 0 1;
width: 4;
content-align: right middle;
}
HeaderHelpIcon:hover {
background: $panel-lighten-2;
}
"""

class HeaderHelpIcon(textual.widgets.Button):
app: Browser

def render(self) -> textual.app.RenderResult:
return "❓"

def on_click(self) -> None:
self.app.action_help()


class HeaderTitle(textual.widget.Widget):
DEFAULT_CSS = """
HeaderTitle {
content-align: center middle;
width: 100%;
}
"""

text = textual.reactive.Reactive("")
sub_text = textual.reactive.Reactive("")

Expand All @@ -74,26 +38,16 @@ def render(self) -> textual.app.RenderResult:


class Header(textual.widget.Widget):
DEFAULT_CSS = """
Header {
dock: top;
width: 100%;
background: $foreground 5%;
color: $text;
height: 1;
}
"""

DEFAULT_CLASSES = ""

def __init__(self, title: str, **kwargs: Any):
super().__init__(**kwargs)
self.title = title

def compose(self) -> textual.app.ComposeResult:
yield HeaderCloseIcon()
yield HeaderCloseIcon("❌", tooltip="Close")
yield HeaderTitle()
yield HeaderHelpIcon()
yield HeaderHelpIcon("❓", tooltip="Help")

def on_mount(self) -> None:
self.query_one(HeaderTitle).text = self.title
Loading