7
7
import textual .app
8
8
import textual .reactive
9
9
import textual .widget
10
+ import textual .widgets
10
11
11
12
if typing .TYPE_CHECKING :
12
13
from .browser import Browser
13
14
14
15
15
- class HeaderCloseIcon (textual .widget .Widget ):
16
- DEFAULT_CSS = """
17
- HeaderCloseIcon {
18
- dock: left;
19
- padding: 0 1;
20
- width: 4;
21
- content-align: left middle;
22
- }
23
- HeaderCloseIcon:hover {
24
- background: $panel-lighten-2;
25
- }
26
- """
27
-
28
- def render (self ) -> textual .app .RenderResult :
29
- return "❌"
30
-
16
+ class HeaderCloseIcon (textual .widgets .Button ):
31
17
def on_click (self ) -> None :
32
18
self .app .exit ()
33
19
34
20
35
- class HeaderHelpIcon (textual .widget .Widget ):
36
- DEFAULT_CSS = """
37
- HeaderHelpIcon {
38
- dock: right;
39
- padding: 0 1;
40
- width: 4;
41
- content-align: right middle;
42
- }
43
- HeaderHelpIcon:hover {
44
- background: $panel-lighten-2;
45
- }
46
- """
47
-
21
+ class HeaderHelpIcon (textual .widgets .Button ):
48
22
app : Browser
49
23
50
- def render (self ) -> textual .app .RenderResult :
51
- return "❓"
52
-
53
24
def on_click (self ) -> None :
54
25
self .app .action_help ()
55
26
56
27
57
28
class HeaderTitle (textual .widget .Widget ):
58
- DEFAULT_CSS = """
59
- HeaderTitle {
60
- content-align: center middle;
61
- width: 100%;
62
- }
63
- """
64
-
65
29
text = textual .reactive .Reactive ("" )
66
30
sub_text = textual .reactive .Reactive ("" )
67
31
@@ -74,26 +38,16 @@ def render(self) -> textual.app.RenderResult:
74
38
75
39
76
40
class Header (textual .widget .Widget ):
77
- DEFAULT_CSS = """
78
- Header {
79
- dock: top;
80
- width: 100%;
81
- background: $foreground 5%;
82
- color: $text;
83
- height: 1;
84
- }
85
- """
86
-
87
41
DEFAULT_CLASSES = ""
88
42
89
43
def __init__ (self , title : str , ** kwargs : Any ):
90
44
super ().__init__ (** kwargs )
91
45
self .title = title
92
46
93
47
def compose (self ) -> textual .app .ComposeResult :
94
- yield HeaderCloseIcon ()
48
+ yield HeaderCloseIcon ("❌" , tooltip = "Close" )
95
49
yield HeaderTitle ()
96
- yield HeaderHelpIcon ()
50
+ yield HeaderHelpIcon ("❓" , tooltip = "Help" )
97
51
98
52
def on_mount (self ) -> None :
99
53
self .query_one (HeaderTitle ).text = self .title
0 commit comments