46
46
PlotWidget ,
47
47
make_plot ,
48
48
)
49
+ from .tools import Info , Tools
49
50
50
51
51
52
class Browser (textual .app .App [object ]):
@@ -58,12 +59,13 @@ class Browser(textual.app.App[object]):
58
59
textual .binding .Binding ("b" , "toggle_files" , "Navbar" ),
59
60
textual .binding .Binding ("q" , "quit" , "Quit" ),
60
61
textual .binding .Binding ("d" , "quit_with_dump" , "Dump & Quit" ),
61
- textual .binding .Binding ("t" , "toggle_theme" , "Theme" ),
62
62
textual .binding .Binding ("f1" , "help" , "Help" ),
63
63
textual .binding .Binding ("?" , "help" , "Help" , show = False ),
64
+ textual .binding .Binding ("escape" , "quit" , "Quit" , show = False ),
64
65
]
65
66
66
67
show_tree = var (True )
68
+ show_tools = var (False )
67
69
68
70
def __init__ (self , path : str , ** kwargs : Any ) -> None :
69
71
self .path = path
@@ -77,24 +79,27 @@ def compose(self) -> textual.app.ComposeResult:
77
79
yield Header ("uproot-browser" )
78
80
with textual .containers .Container ():
79
81
# left_panel
80
- yield UprootTree (self .path , id = "tree-view" )
81
- # right_panel
82
- yield textual .widgets .ContentSwitcher (
83
- LogoWidget (id = "logo" ),
84
- self .plot_widget ,
85
- self .error_widget ,
86
- EmptyWidget (id = "empty" ),
87
- id = "main-view" ,
88
- initial = "logo" ,
89
- )
82
+ with textual .widgets .TabbedContent (id = "left-view" ):
83
+ with textual .widgets .TabPane ("Tree" ):
84
+ yield UprootTree (self .path , id = "tree-view" )
85
+ with textual .widgets .TabPane ("Tools" ):
86
+ yield Tools ()
87
+ with textual .widgets .TabPane ("Info" ):
88
+ yield Info ()
89
+ # main_panel
90
+ with textual .widgets .ContentSwitcher (id = "main-view" , initial = "logo" ):
91
+ yield LogoWidget (id = "logo" )
92
+ yield self .plot_widget
93
+ yield self .error_widget
94
+ yield EmptyWidget (id = "empty" )
90
95
yield textual .widgets .Footer ()
91
96
92
97
def on_mount (self , _event : textual .events .Mount ) -> None :
93
- self .query_one ("#tree-view" , UprootTree ).focus ()
98
+ self .query_one ("#tree-view" ).focus ()
94
99
95
100
def watch_show_tree (self , show_tree : bool ) -> None :
96
101
"""Called when show_tree is modified."""
97
- self .set_class (show_tree , "-show-tree " )
102
+ self .set_class (show_tree , "-show-panel " )
98
103
99
104
def action_help (self ) -> None :
100
105
self .push_screen (HelpScreen ())
@@ -133,14 +138,10 @@ def action_quit_with_dump(self) -> None:
133
138
134
139
self .exit (message = results )
135
140
136
- def action_toggle_theme (self ) -> None :
137
- """An action to toggle dark mode."""
138
- dark = self .theme != "textual-light"
139
- theme = "textual-light" if dark else "textual-dark"
140
-
141
+ def watch_theme (self , _old : str , new : str ) -> None :
142
+ dark = not new .endswith ("-light" )
141
143
if self .plot_widget .item :
142
- self .plot_widget .item .theme = "default" if dark else "dark"
143
- self .theme = theme
144
+ self .plot_widget .item .theme = "dark" if dark else "default"
144
145
145
146
def on_uproot_selected (self , message : UprootSelected ) -> None :
146
147
"""A message sent by the tree when a file is clicked."""
0 commit comments