dataframe-textual 2.2.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,115 @@
1
+ """Help panel widget for displaying context-sensitive help."""
2
+
3
+ from textwrap import dedent
4
+
5
+ from textual.app import ComposeResult
6
+ from textual.containers import VerticalScroll
7
+ from textual.css.query import NoMatches
8
+ from textual.widget import Widget
9
+ from textual.widgets import Markdown
10
+
11
+
12
+ class DataFrameHelpPanel(Widget):
13
+ """
14
+ Shows context sensitive help for the currently focused widget.
15
+
16
+ Modified from Textual's built-in HelpPanel with KeyPanel removed.
17
+ """
18
+
19
+ DEFAULT_CSS = """
20
+ DataFrameHelpPanel {
21
+ split: right;
22
+ width: 33%;
23
+ min-width: 40;
24
+ max-width: 80;
25
+ border-left: vkey $foreground 30%;
26
+ padding: 0 1;
27
+ height: 1fr;
28
+ padding-right: 1;
29
+ layout: vertical;
30
+ height: 100%;
31
+
32
+ &:ansi {
33
+ background: ansi_default;
34
+ border-left: vkey ansi_black;
35
+
36
+ Markdown {
37
+ background: ansi_default;
38
+ }
39
+ .bindings-table--divide {
40
+ color: transparent;
41
+ }
42
+ }
43
+
44
+ #widget-help {
45
+ height: auto;
46
+ width: 1fr;
47
+ padding: 0;
48
+ margin: 0;
49
+ padding: 1 0;
50
+ margin-top: 1;
51
+ display: none;
52
+ background: $panel;
53
+
54
+ &:ansi {
55
+ background: ansi_default;
56
+ }
57
+
58
+ MarkdownBlock {
59
+ padding-left: 2;
60
+ padding-right: 2;
61
+ }
62
+ }
63
+
64
+ &.-show-help #widget-help {
65
+ display: block;
66
+ }
67
+ }
68
+ """
69
+
70
+ DEFAULT_CLASSES = "-textual-system"
71
+
72
+ def on_mount(self) -> None:
73
+ """Set up help panel when mounted.
74
+
75
+ Initializes the help panel by setting up a watcher for focused widget changes
76
+ to dynamically update help text based on which widget has focus.
77
+ """
78
+
79
+ # def update_help(focused_widget: Widget | None):
80
+ # self.update_help(focused_widget)
81
+
82
+ # self.watch(self.screen, "focused", update_help)
83
+
84
+ self.update_help(self.screen.focused)
85
+
86
+ def update_help(self, focused_widget: Widget | None) -> None:
87
+ """Update the help for the focused widget.
88
+
89
+ Args:
90
+ focused_widget: The currently focused widget, or `None` if no widget was focused.
91
+ """
92
+ if not self.app.app_focus:
93
+ return
94
+ if not self.screen.is_active:
95
+ return
96
+ self.set_class(focused_widget is not None, "-show-help")
97
+ if focused_widget is not None:
98
+ help = (self.app.HELP or "") + "\n" + (focused_widget.HELP or "")
99
+ if not help:
100
+ self.remove_class("-show-help")
101
+ try:
102
+ self.query_one(Markdown).update(dedent(help))
103
+ except NoMatches:
104
+ pass
105
+
106
+ def compose(self) -> ComposeResult:
107
+ """Compose the help panel widget structure.
108
+
109
+ Creates and returns the widget hierarchy for the help panel,
110
+ including a VerticalScroll container with a Markdown display area.
111
+
112
+ Yields:
113
+ VerticalScroll: The main container with Markdown widget for help text.
114
+ """
115
+ yield VerticalScroll(Markdown(id="widget-help"))