File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2323 ComboBox (
2424 label = "Your favorite car makers" ,
2525 multi_select = True ,
26- value = "BMW, Volkswagen" ,
26+ value = [ "BMW, Volkswagen" ] ,
2727 width = "50%" ,
28+ on_change = lambda e : print ("selected cars:" , e .control .value ),
2829 options = [
2930 combobox .Option ("Select all" , item_type = "select_all" ),
3031 combobox .Option ("div1" , item_type = "divider" ),
3435 combobox .Option ("Mercedes-Benz" ),
3536 ],
3637 ),
38+ ComboBox (
39+ label = "Allows free form" ,
40+ multi_select = False ,
41+ width = "50%" ,
42+ allow_free_form = True ,
43+ options = [
44+ combobox .Option ("One" ),
45+ combobox .Option ("Two" ),
46+ combobox .Option ("Five" ),
47+ ],
48+ ),
49+ ComboBox (
50+ label = "Allows free form with multi-select" ,
51+ multi_select = True ,
52+ width = "50%" ,
53+ allow_free_form = True ,
54+ options = [
55+ combobox .Option ("Red" ),
56+ combobox .Option ("Green" ),
57+ combobox .Option ("Blue" ),
58+ ],
59+ ),
3760)
61+
62+ input ()
Original file line number Diff line number Diff line change 1- from typing import Literal , Optional
1+ from typing import List , Literal , Optional
22
33from beartype import beartype
44
@@ -87,10 +87,15 @@ def label(self, value):
8787 # value
8888 @property
8989 def value (self ):
90- return self ._get_attr ("value" )
90+ v = self ._get_attr ("value" )
91+ if v and self .multi_select :
92+ return [x .strip () for x in v .split ("," )]
93+ return v
9194
9295 @value .setter
9396 def value (self , value ):
97+ if isinstance (value , List ):
98+ value = "," .join (value )
9499 self ._set_attr ("value" , value )
95100
96101 # placeholder
You can’t perform that action at this time.
0 commit comments