Skip to content

Commit

Permalink
use liststore
Browse files Browse the repository at this point in the history
  • Loading branch information
Jhsmit committed Oct 30, 2024
1 parent 8a88ee4 commit 6abd60f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
7 changes: 2 additions & 5 deletions dont_fret/web/bursts/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from dont_fret.web.components import FigureFromTask, RangeInputField, RegexSelectDialog
from dont_fret.web.methods import chain_filters
from dont_fret.web.models import BinnedImage, BurstFilterItem, BurstNode, BurstPlotSettings
from dont_fret.web.new_models import FRETNode, FRETStore, ListStore
from dont_fret.web.new_models import FRETNode, FRETStore, ListStore, use_liststore
from dont_fret.web.utils import (
NestedSelectors,
find_index,
Expand Down Expand Up @@ -190,10 +190,7 @@ def FilterEditDialog():
existing_filter_fields = [f.name for f in state.filters]
selector_nodes = make_selector_nodes(state.fret_nodes.items, attr="bursts")

def make_store():
return ListStore[str]([selector_nodes[0].value, selector_nodes[0].children[0].value])

burst_node_choice = solara.use_memo(make_store, [])
burst_node_choice = use_liststore([])

def make_chart():
burst_node = get_bursts(state.fret_nodes.items, burst_node_choice.items)
Expand Down
8 changes: 8 additions & 0 deletions dont_fret/web/new_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,14 @@ def index(self, item: T) -> int:
return self.items.index(item)


def use_liststore(initial_value: list[T]) -> ListStore[T]:
def make_liststore():
return ListStore(initial_value)

store = solara.use_memo(make_liststore, [])
return store


@dataclasses.dataclass
class FRETNode:
name: solara.Reactive[str] # displayed name
Expand Down

0 comments on commit 6abd60f

Please sign in to comment.