5
5
from dataclasses import dataclass
6
6
from typing import Self
7
7
8
+ from matplotlib .font_manager import FontProperties
8
9
from nicegui import ui
9
10
10
11
from pretty_gpx .common .utils .utils import safe
11
- from matplotlib . font_manager import FontProperties
12
+
12
13
13
14
@dataclass
14
15
class UiInput :
@@ -75,10 +76,11 @@ def create(cls,
75
76
fonts_l : tuple [FontProperties , ...],
76
77
tooltip : str ,
77
78
on_change : Callable [[], Awaitable [None ]]) -> Self :
78
-
79
- button = ui .button (fonts_l [0 ].get_name ()).props ('outline flat' ) \
80
- .classes ('bg-white text-black w-48 justify-start' ) \
81
- .style ('border: 1px solid #ddd; border-radius: 4px; position: relative;' )
79
+ """Create the UiFontsMenu."""
80
+ default_font = fonts_l [0 ].get_name ()
81
+ button = ui .button (default_font ).props ('outline flat' ) \
82
+ .classes ('bg-white text-black w-48 justify-start' ) \
83
+ .style ('border: 1px solid #ddd; border-radius: 4px; position: relative;' )
82
84
83
85
with button :
84
86
ui .icon ('arrow_drop_down' ).classes ('ml-auto' )
@@ -89,8 +91,8 @@ def create(cls,
89
91
for font in fonts_l :
90
92
font_name = font .get_name ()
91
93
92
- def create_click_handler (selected_font ) :
93
- async def handler ():
94
+ def create_click_handler (selected_font : str ) -> Callable [[], Awaitable [ None ]] :
95
+ async def handler () -> None :
94
96
button .text = selected_font
95
97
menu .close ()
96
98
await on_change ()
@@ -102,7 +104,8 @@ async def handler():
102
104
.style (f'font-family: { font_name } ; padding: 8px 16px;' ) \
103
105
.on ('click' , create_click_handler (font_name ))
104
106
105
- def toggle_menu ():
107
+ def toggle_menu () -> None :
108
+ """Toggle menu visibility."""
106
109
if menu .visible :
107
110
menu .close ()
108
111
else :
0 commit comments