#!/usr/bin/env python3 # -*- coding:utf-8 -*- from flexx import flx from ipfsdocs.common import ( BootstrapInput, set_to_localstorage, get_from_localstorage, ) class Events(BootstrapInput): event_id = flx.IntProp(settable=True) def init(self): self.set_icon_text("\uf1ea") self.events = flx.ComboBox(flex=1) @flx.reaction("root.state.events") def update_events(self): self.events.set_options( ["\uf05e"] + [ f"""{event["description"]} ({event["date"]})""" for event in self.root.state.events ] ) @flx.reaction("events.selected_index") def update_iddb(self): if self.events.selected_index in (-1, 0): event_id = -1 else: event_id = self.root.state.events[self.events.selected_index - 1]["id"] self.set_event_id(event_id)