Hello,
im currently trying out things with param.Selector an experiencing some unexpected behaviour.
With this code
import attr
import param
class B(param.Parameterized):
ticketview = param.Selector(default=None, allow_None=True, check_on_set=True, objects={"": None, "A": 1, "B": 2})
b = B()
b.ticketview = "B"
print(b.ticketview)
the selector correctly throws an error
ValueError: B not in parameter ticketview's list of possible objects, valid options include [None, 1, 2]
but if i want to change the objects dynamically, the behaviour changes too
import attr
import param
class B(param.Parameterized):
ticketview = param.Selector(default=None, allow_None=True, check_on_set=True, objects={"": None})
b = B()
b.param.ticketview.objects = {"": None, "A": 1, "B": 2}
b.ticketview = "B"
print(b.ticketview)
This code does not throw any error.
Is there something im not seeing here?
I thought the keys of the dictionary are only for displaying?
EDIT:
Well looking into the init of param.Selector reveals that here
if isinstance(objects, collections_abc.Mapping):
self.names = objects
self.objects = list(objects.values())
the objects are rewritten and the names attirbute is used.
Am i expected to mimic this if i want to update the objects of the selector aka
b.param.ticketview.objects = list(new_objects.values())
b.param.ticketview.names = new_objects
or is there a better way?