mirror of
https://github.com/flobz/psa_car_controller.git
synced 2026-08-26 10:17:18 +00:00
fix button
This commit is contained in:
+16
-9
@@ -1,22 +1,29 @@
|
||||
import dash_bootstrap_components as dbc
|
||||
import dash_daq as daq
|
||||
import dash_html_components as html
|
||||
from dash.dependencies import Input
|
||||
|
||||
from web.tools.Button import Button, RESPONSE
|
||||
from web.app import dash_app
|
||||
from web.tools.Button import Button
|
||||
|
||||
|
||||
class Switch(Button):
|
||||
def __init__(self, role, button_id, label, fct, value): # pylint: disable=too-many-arguments
|
||||
def __init__(self, role, element_id, label, fct, value, prevent_initial_call=True):
|
||||
# pylint: disable=too-many-arguments
|
||||
self.value = value
|
||||
super().__init__(role, button_id, label, fct)
|
||||
super().__init__(role, element_id, label, fct, prevent_initial_call)
|
||||
|
||||
def _set_callback(self, prevent_initial_call):
|
||||
dash_app.callback(self._output, Input(self.get_button_id(), 'value'),
|
||||
prevent_initial_call=prevent_initial_call)(self.call)
|
||||
|
||||
def get_html(self):
|
||||
return dbc.Col([daq.ToggleSwitch( # pylint: disable=not-callable
|
||||
id={'role': self.role, 'id': self.button_id},
|
||||
return dbc.Col([daq.ToggleSwitch( # pylint: disable=not-callable
|
||||
id=self.get_button_id(),
|
||||
value=self.value,
|
||||
label=self.label
|
||||
), html.Div(id={'role': self.role + RESPONSE, 'id': self.button_id})])
|
||||
), html.Div(id=self.get_response_id())])
|
||||
|
||||
def call(self, div_id, value):
|
||||
self._fct(div_id["id"], value)
|
||||
return " "
|
||||
def call(self, value):
|
||||
self._fct(self._element_id, value)
|
||||
return " "
|
||||
|
||||
Reference in New Issue
Block a user