MCPcopy Create free account
hub / github.com/Bbalduzz/fletmint / TextInput

Class TextInput

fletmint/text_input.py:46–171  ·  view source on GitHub ↗

may be rewritten as a sublclass of TextField

Source from the content-addressed store, hash-verified

44
45
46class TextInput(ft.Container):
47 """may be rewritten as a sublclass of TextField"""
48
49 def __init__(
50 self,
51 on_focus_additional=None,
52 on_blur_additional=None,
53 prefix=None,
54 suffix=None,
55 theme=ft.ThemeMode.DARK,
56 **kwargs
57 ):
58 self.on_focus_additional = on_focus_additional
59 self.on_blur_additional = on_blur_additional
60 self.colors = (
61 TextInputColors.dark()
62 if theme == ft.ThemeMode.DARK
63 else TextInputColors.light()
64 )
65 self.prefix = prefix
66 self.suffix = suffix
67 self.kwargs = kwargs
68
69 if self.prefix and not self.suffix:
70 content_padding = ft.padding.only(left=45, right=15)
71 elif self.suffix and not self.prefix:
72 content_padding = ft.padding.only(right=45, left=15)
73 elif self.prefix and self.suffix:
74 content_padding = ft.padding.symmetric(horizontal=45)
75 else:
76 content_padding = ft.padding.all(15)
77
78 # Initialize the inner text field using ft.TextField
79 self.text_field = ft.TextField(
80 focused_border_width=ft.border.all(0),
81 focused_border_color=ft.InputBorder.NONE,
82 focused_bgcolor=self.colors.text_field_focused_background_color,
83 border_radius=ft.border_radius.all(7),
84 border_color=self.colors.text_field_border_color,
85 filled=True,
86 color=self.colors.text_color,
87 cursor_color=self.colors.cursor_color,
88 cursor_width=1,
89 on_focus=self.set_hover_state,
90 on_blur=self.remove_hover_state,
91 bgcolor=self.colors.text_field_background_color,
92 content_padding=content_padding,
93 **self.kwargs,
94 )
95
96 self.field = ft.Stack(
97 [
98 self.text_field,
99 ft.Container(
100 self.prefix,
101 ink=True,
102 width=20,
103 height=20,

Callers 4

mainFunction · 0.85
__init__Method · 0.85
buildMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected