def __init__(self, states): """ Create a list of state items and a plus button to add new states. Parameter ========= states: list The list of default states defined by the test case. """ self.states = states self.default_state = self.states[0] super().__init__(self.default_state) self.eval_stab = v.Btn(children=['Check stability'], color='primary') for s in states: self.item_list.children.append(self.create_item(s)) self.item_list.notify_change({'name': 'children', 'type': 'change'}) self.widget = v.Card(children=[ v.CardTitle(children=['List of linear states', v.Spacer(), self.add_button]), v.CardText(children=[self.item_list]), v.CardActions(children=[v.Spacer(), self.eval_stab]) ])
def __init__(self): with out: yes = v.Btn(children=['yes'], class_='ma-2', style_='width: 100px', color='success') no = v.Btn(children=['no'], class_='ma-2', style_='width: 100px', color='error') self.width = '500' self.v_model = False self.text = v.CardTitle(children=[]) self.children = [ v.Card(children=[ self.text, v.CardActions(children=[v.Spacer(), yes, no]) ]), ] self.path = None self.replace = True yes.on_event('click', self.yes_click) no.on_event('click', self.no_click) super().__init__()
def __init__(self, table, **kwargs): self.table = table update = v.Btn(children=['update'], color='success') close = v.Btn(children=['close'], color='error') self.form_1d = FormProperties_1D() self.form_2d = FormProperties_2D() self.form = v.CardText(children=self.form_1d.widget) self.dialog = v.Dialog( width='500', v_model=False, children=[ v.Card(children=[ v.CardTitle(class_='headline gray lighten-2', primary_title=True, children=['Plot properties']), self.form, v.CardActions(children=[v.Spacer(), update, close]) ]), ]) def close_btn(widget, event, data): self.dialog.v_model = False update.on_event('click', self.update_btn) close.on_event('click', close_btn) super().__init__(**kwargs)
def __init__(self): title = v.CardTitle(children=[cm.quintile.clip.title]) self.link = v.TextField( class_="ma-5", v_model=None, outlined=True, label=cm.quintile.clip.lbl, hint=cm.quintile.clip.hint, persistent_hint=True, readonly=True, append_icon="mdi-clipboard-outline", ) self.done = v.Btn(color="primary", outlined=True, children=[cm.quintile.clip.done]) self.card = v.Card( children=[title, self.link, v.CardActions(children=[self.done])]) super().__init__(value=False, persistent=True, max_width="600px", children=[self.card]) # js links self.done.on_event("click", self._done_click)
def __init__(self, aoi_vew, model): # save the model self.model = model # listen to the aoi_vew to update the map self.view = aoi_vew self.init_layer = "" self.id = "" self.index = None # add all the standard placeholder, they will be replaced when a layer will be selected self.title = v.CardTitle(children=["Layer name"]) self.text = v.CardText(children=[""]) self.layer = v.TextField(class_="ma-5", v_model=None, color="warning", outlined=True, label="Layer") self.unit = v.TextField(class_="ma-5", v_model=None, color="warning", outlined=True, label="Unit") # add a map to display the layers self.m = sm.SepalMap() self.m.layout.height = "40vh" self.m.layout.margin = "2em" # two button will be placed at the bottom of the panel self.cancel = sw.Btn(cm.dial.cancel, color="primary", outlined=True) self.save = sw.Btn(cm.dial.save, color="primary") # create the init card self.card = v.Card(children=[ self.title, self.text, self.layer, self.unit, self.m, v.CardActions(class_="ma-5", children=[self.cancel, self.save]), ]) # init the dialog super().__init__(persistent=True, value=False, max_width="50vw", children=[self.card]) # js behaviours self.layer.on_event("blur", self._on_layer_change) self.cancel.on_event("click", self._cancel_click) self.save.on_event("click", self._save_click) self.view.observe(self._update_aoi, "updated")
def __init__(self, table, schema, *args, default=None, **kwargs): """ Dialog to modify/create new elements from the ClassTable data table Args: table (ClassTable, v.DataTable): Table linked with dialog schema (dict {'title':'type'}): Schema for table showing headers and type of data default (dict): Dictionary with default valules """ self.table = table self.default = default self.title = "New element" if not self.default else "Modify element" self.schema = schema self.v_model = True self.max_width = 500 self.overlay_opcity = 0.7 # Action buttons self.save = v.Btn(children=['Save']) save_tool = sw.Tooltip(self.save, 'Create new element') self.cancel = v.Btn(children=['Cancel']) cancel_tool = sw.Tooltip(self.cancel, 'Ignore changes') self.modify = v.Btn(children=['Modify']) modify_tool = sw.Tooltip(self.modify, 'Update row') save = [save_tool, cancel_tool] modify = [modify_tool, cancel_tool] actions = v.CardActions(children=save if not default else modify) super().__init__(*args, **kwargs) self.children=[ v.Card( class_='pa-4', children=[ v.CardTitle(children=[self.title])] + \ self._get_widgets() + \ [actions] ) ] # Create events self.save.on_event('click', self._save) self.modify.on_event('click', self._modify) self.cancel.on_event('click', self._cancel)
def __init__(self): with cp.eula_md.open() as f: licence = f.read() mkd = sw.Markdown(licence) text = v.CardText(children=[mkd]) btn = v.CardActions(children=[sw.Btn(cm.app.licence.btn)]) self.card = v.Card(children=[btn, v.Divider(), text, v.Divider(), btn]) super().__init__(value=not self._is_gwb(), max_width='1000px', children=[self.card], persistent=True) # link the btn behaviour btn.on_event('click', self._set_gwb)
def __init__(self, *args, **kwargs): self.form = self.form_class(*args, **kwargs) update_btn = v.Btn(children=['update'], color='success') close_btn = v.Btn(children=['close'], color='error') self.update_dialog = v.Dialog( width='500', v_model=False, children=[ v.Card(children=[ v.CardTitle(class_='headline gray lighten-2', primary_title=True, children=[self.update_text]), v.CardText(children=[self.form]), v.CardActions(children=[v.Spacer(), update_btn, close_btn]) ]), ]) update_btn.on_event('click', self.update_click) close_btn.on_event('click', self.close_click) self.content = v.CardText(children=[f'{self}']) self.btn = v.Btn( children=[v.Icon(children=['mdi-close'])], fab=True, color='error', dark=True, x_small=True, ) super().__init__(children=[ v.ListItemAction(children=[self.btn]), v.ListItemContent(children=[ v.Card( children=[self.content], flat=True, color='transparent', light=True, ), self.update_dialog ]), ], **kwargs)
def __init__(self, table, **kwargs): self.table = table update = v.Btn(children=['update']) close = v.Btn(children=['close']) self.form = [ IntField(label='linewidth', v_model=plot_config['linewidth']), v.Select(label='Line style', items=[{ 'text': v, 'value': k } for k, v in Line2D.lineStyles.items()], v_model=plot_config['linestyle']), v.Select(label='Marker', items=[{ 'text': v, 'value': k } for k, v in Line2D.markers.items()], v_model=plot_config['marker']), IntField(label='Marker size', v_model=plot_config['markersize']), FloatField(label='alpha', v_model=plot_config['alpha']), v.ColorPicker(v_model=plot_config['colors'][0]), ] self.dialog = v.Dialog( width='500', v_model=False, children=[ v.Card(children=[ v.CardTitle(class_='headline gray lighten-2', primary_title=True, children=['Plot properties']), v.CardText(children=self.form), v.CardActions(children=[v.Spacer(), update, close]) ]), ]) def close_btn(widget, event, data): self.dialog.v_model = False update.on_event('click', self.update_btn) close.on_event('click', close_btn) super().__init__(**kwargs)
def __init__(self): self.feature = None self.w_name = v.TextField(label=cm.map.dialog.label, v_model=None) self.btn = sw.Btn(cm.map.dialog.btn, "mdi-check") card = v.Card( class_="ma-5", children=[ v.CardTitle(children=[cm.map.dialog.title]), v.CardText(children=[self.w_name]), v.CardActions(children=[self.btn]), ], ) # init the dialog super().__init__( persistent=True, value=False, max_width="700px", children=[card] ) # add js behavior self.btn.on_event("click", self._on_click)
def __init__(self): # init the downloadable informations self.geometry = None self.dataset = None self.name = None self.aoi_name = None # create the useful widgets self.w_scale = v.Slider( v_model=30, # align on the landsat images min=10, max=300, thumb_label=True, step=10, ) self.w_method = v.RadioGroup( v_model="gee", row=True, children=[ v.Radio(label=cm.export.radio.sepal, value="sepal"), v.Radio(label=cm.export.radio.gee, value="gee"), ], ) self.alert = sw.Alert() self.btn = sw.Btn(cm.export.apply, small=True) export_data = v.Card(children=[ v.CardTitle( children=[v.Html(tag="h4", children=[cm.export.title])]), v.CardText(children=[ v.Html(tag="h4", children=[cm.export.scale]), self.w_scale, v.Html(tag="h4", children=[cm.export.radio.label]), self.w_method, self.alert, ]), v.CardActions(children=[self.btn]), ]) # the clickable icon self.download_btn = v.Btn( v_on="menu.on", color="primary", icon=True, children=[v.Icon(children=["mdi-cloud-download"])], ) super().__init__( value=False, close_on_content_click=False, nudge_width=200, offset_x=True, children=[export_data], v_slots=[{ "name": "activator", "variable": "menu", "children": self.download_btn }], ) # add js behaviour self.btn.on_event("click", self._apply)
def __init__(self): # init the downloadable informations self.geometry = None self.names = [] self.datasets = {} # create the useful widgets self.w_scale = v.Slider( class_="mt-5", v_model=30, # align on the landsat images, ticks="always", tick_labels=[ str(i) if i in self.TICKS_TO_SHOW else "" for i in range(10, 301, 10) ], min=10, max=300, thumb_label=True, step=10, ) self.w_prefix = v.TextField( label=cm.export.name, small=True, dense=True, v_model=None, ) self.w_datasets = v.Select( dense=True, small=True, label=cm.export.datasets, v_model=None, items=[*self.datasets], multiple=True, chips=True, ) self.w_method = v.RadioGroup( v_model="gee", row=True, children=[ v.Radio(label=cm.export.radio.sepal, value="sepal"), v.Radio(label=cm.export.radio.gee, value="gee"), ], ) self.alert = sw.Alert() self.btn = sw.Btn(cm.export.apply, small=True) export_data = v.Card(children=[ v.CardTitle( children=[v.Html(tag="h4", children=[cm.export.title])]), v.CardText(children=[ self.w_prefix, self.w_datasets, v.Html(tag="h4", children=[cm.export.scale]), self.w_scale, v.Html(tag="h4", children=[cm.export.radio.label]), self.w_method, self.alert, ]), v.CardActions(children=[self.btn]), ]) # the clickable icon self.w_down = v.Btn( v_on="menu.on", color="primary", icon=True, children=[v.Icon(children=["mdi-cloud-download"])], ) super().__init__( value=False, close_on_content_click=False, nudge_width=200, offset_x=True, children=[export_data], v_slots=[{ "name": "activator", "variable": "menu", "children": self.w_down }], ) # add js behaviour self.btn.on_event("click", self._apply)
def __init__(self, *args, **kwargs): with out: self.form = self.item_class.form_class(*args, **kwargs) create_add = v.Btn(children=['add'], color='success') create_close = v.Btn(children=['close'], color='error') create_dialog = v.Dialog( width='500', v_model=False, children=[ v.Card(children=[ v.CardTitle(class_='headline gray lighten-2', primary_title=True, children=[self.new_text]), v.CardText(children=[self.form]), v.CardActions( children=[v.Spacer(), create_add, create_close]) ]), ]) self.item_list = v.List(children=[]) add_button = v.Btn( children=[v.Icon(children=['mdi-plus']), create_dialog], fab=True, color='primary', small=True, dark=True, ) def close_click(widget, event, data): create_dialog.v_model = False def on_change(change): self.item_list.notify_change({ 'name': 'children', 'type': 'change' }) def add_click(widget, event, data): self.form.check_rules() if self.form.v_model: new_item = self.create_item() self.item_list.children.append(new_item) create_dialog.v_model = False def remove_item(widget, event, data): self.item_list.children.remove(new_item) self.item_list.notify_change({ 'name': 'children', 'type': 'change' }) new_item.btn.on_event('click', remove_item) new_item.on_event('click', new_item.update_item) new_item.observe(on_change, 'children') self.item_list.notify_change({ 'name': 'children', 'type': 'change' }) create_close.on_event('click', close_click) create_add.on_event('click', add_click) def on_add_click(widget, event, data): with out: self.form.reset_form() create_dialog.v_model = True add_button.on_event('click', on_add_click) self.add_button = add_button self.widget = v.Card(children=[ v.CardText(children=[self.item_list]), v.CardActions(children=[v.Spacer(), add_button]) ])