Skip to content

Commit 402f6f8

Browse files
committed
fixup! Port the tree reporter to textual
Don't use a ListView for the node details, since we don't want users to be able to hover or click individual detail rows
1 parent 35d2000 commit 402f6f8

File tree

2 files changed

+1290
-1297
lines changed

2 files changed

+1290
-1297
lines changed

src/memray/reporters/tree.py

+16-14
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525
from textual.widget import Widget
2626
from textual.widgets import Footer
2727
from textual.widgets import Label
28-
from textual.widgets import ListItem
29-
from textual.widgets import ListView
3028
from textual.widgets import TextArea
3129
from textual.widgets import Tree
3230
from textual.widgets.tree import TreeNode
@@ -120,23 +118,20 @@ def compose(self) -> ComposeResult:
120118
text.can_focus = False
121119
text.cursor_blink = False
122120

123-
list_view = ListView(
124-
ListItem(Label(f":compass: Function: {function}", id="function")),
125-
ListItem(Label(f":compass: Location: {file}:{line}", id="location")),
126-
ListItem(
127-
Label(
128-
f":floppy_disk: Allocations: {self.frame.n_allocations}",
129-
id="allocs",
130-
)
121+
node_metadata = Vertical(
122+
Label(f":compass: Function: {function}", id="function"),
123+
Label(f":compass: Location: {file}:{line}", id="location"),
124+
Label(
125+
f":floppy_disk: Allocations: {self.frame.n_allocations}",
126+
id="allocs",
131127
),
132-
ListItem(Label(f":package: Size: {size_fmt(self.frame.value)}", id="size")),
133-
ListItem(Label(f":thread: Thread: {self.frame.thread_id}", id="thread")),
128+
Label(f":package: Size: {size_fmt(self.frame.value)}", id="size"),
129+
Label(f":thread: Thread: {self.frame.thread_id}", id="thread"),
134130
)
135-
list_view.can_focus = False
136131

137132
yield Grid(
138133
text,
139-
list_view,
134+
node_metadata,
140135
id="frame-detail-grid",
141136
)
142137

@@ -178,6 +173,13 @@ class TreeApp(App[None]):
178173
padding: 1 3;
179174
}
180175
176+
#frame-detail-grid Label {
177+
color: $text;
178+
height: auto;
179+
width: 100%;
180+
background: $panel-lighten-1;
181+
}
182+
181183
#frame-detail-grid {
182184
grid-size: 1 2;
183185
grid-gutter: 1 2;

0 commit comments

Comments
 (0)