diff --git a/src/uproot_browser/tree.py b/src/uproot_browser/tree.py index c9330c2..bf89dc5 100644 --- a/src/uproot_browser/tree.py +++ b/src/uproot_browser/tree.py @@ -10,6 +10,8 @@ from typing import Any import uproot +import uproot.behaviors +import uproot.interpretation import uproot.reading from rich.console import Console from rich.markup import escape @@ -65,8 +67,9 @@ def label(self) -> Text: def tree_args(self) -> dict[str, Any]: d: dict[str, Text | str] = {"label": self.label()} - if "guide_style" in self.meta(): - d["guide_style"] = self.meta()["guide_style"] + meta = self.meta() + if "guide_style" in meta: + d["guide_style"] = meta["guide_style"] return d @property @@ -84,7 +87,10 @@ def children(self) -> list[UprootEntry]: else: items = {obj.name.split(";")[0] for obj in self.item.branches} return [ - UprootEntry(f"{self.path}/{key}", self.item[key]) for key in sorted(items) + UprootEntry( + key if self.path == "/" else f"{self.path}/{key}", self.item[key] + ) + for key in sorted(items) ] @@ -108,6 +114,7 @@ def process_item(uproot_object: Any) -> MetaDict: """ name = getattr(uproot_object, "name", "") classname = getattr(uproot_object, "classname", uproot_object.__class__.__name__) + assert isinstance(classname, str) label_text = Text.assemble( (f"{name} ", "bold"), (classname, "italic"), diff --git a/src/uproot_browser/tui/browser.css b/src/uproot_browser/tui/browser.css index 7c41d8a..ee8cfff 100644 --- a/src/uproot_browser/tui/browser.css +++ b/src/uproot_browser/tui/browser.css @@ -46,6 +46,14 @@ Browser.-show-tree #tree-view { content-align: center middle; } +#plot-input-container { + height: 3; +} + +#plot-button { + dock: right; +} + Footer > .footer--highlight { background: $secondary-darken-2; diff --git a/src/uproot_browser/tui/browser.py b/src/uproot_browser/tui/browser.py index 4cb5c1a..631974b 100644 --- a/src/uproot_browser/tui/browser.py +++ b/src/uproot_browser/tui/browser.py @@ -86,6 +86,10 @@ def compose(self) -> textual.app.ComposeResult: id="main-view", initial="logo", ) + with textual.containers.Container(id="plot-input-container"): + yield textual.widgets.Input(id="plot-input") + yield textual.widgets.Button("Plot", id="plot-button") + yield textual.widgets.Footer() def on_mount(self, _event: textual.events.Mount) -> None: @@ -147,6 +151,9 @@ def on_uproot_selected(self, message: UprootSelected) -> None: make_plot(message.upfile[message.path], theme, 20) self.plot_widget.item = Plotext(message.upfile, message.path, theme) content_switcher.current = "plot" + self.query_one( + "#plot-input", textual.widgets.Input + ).value = f"f[{message.path!r}]" except EmptyTreeError: content_switcher.current = "empty" diff --git a/src/uproot_browser/tui/right_panel.py b/src/uproot_browser/tui/right_panel.py index 994af3d..3375b49 100644 --- a/src/uproot_browser/tui/right_panel.py +++ b/src/uproot_browser/tui/right_panel.py @@ -12,6 +12,7 @@ import textual.widget import textual.widgets +import uproot_browser.dirs import uproot_browser.plot LOGO = """\