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

Class DestructiveButton

fletmint/button.py:135–183  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

133
134
135class DestructiveButton(Button):
136 def __init__(
137 self,
138 width=200,
139 height=50,
140 on_click=None,
141 disabled=False,
142 label="Delete",
143 icon=None,
144 ):
145 # Override the background color for a destructive button (red)
146 destructive_style = ButtonStyle(
147 color={
148 "": ButtonColors.button_disabled_content_color
149 if disabled
150 else ButtonColors.button_content_color, # MaterialState.DEFAULT
151 },
152 bgcolor={
153 "": "#FF0000" # Red background for the destructive action
154 if not disabled
155 else ButtonColors.button_disabled_background_color,
156 "disabled": ButtonColors.button_disabled_background_color,
157 },
158 padding=18,
159 shape=ContinuousRectangleBorder(radius=20),
160 )
161
162 # Pass the customized style to the base `Button` class
163 super().__init__(
164 width=width,
165 height=height,
166 on_click=on_click,
167 disabled=disabled,
168 label=label,
169 icon=icon,
170 )
171 # Override the style attribute directly to apply the destructive color
172 self.style = destructive_style
173
174 def did_mount(self):
175 self.update()
176
177 def set_disabled(self, disabled: bool):
178 super().set_disabled(disabled)
179 # Override the background color for the destructive state when enabled
180 self.bgcolor = (
181 "#FF0000" if not disabled else ButtonColors.button_disabled_background_color
182 )
183 self.update()

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected