#-----------------------------------------------------------------------------# Copyright (c) Anaconda, Inc., and Bokeh Contributors.# All rights reserved.## The full license is in the file LICENSE.txt, distributed with this software.#-----------------------------------------------------------------------------''''''#-----------------------------------------------------------------------------# Boilerplate#-----------------------------------------------------------------------------from__future__importannotationsimportlogging# isort:skiplog=logging.getLogger(__name__)#-----------------------------------------------------------------------------# Imports#-----------------------------------------------------------------------------# Bokeh importsfrom...core.has_propsimportabstractfrom...core.propertiesimport(Bool,Enum,Int,List,Nullable,String,)from.buttonsimportButtonLikefrom.widgetimportWidget#-----------------------------------------------------------------------------# Globals and constants#-----------------------------------------------------------------------------__all__=('AbstractGroup','CheckboxButtonGroup','CheckboxGroup','RadioButtonGroup','RadioGroup','ToggleButtonGroup','ToggleInputGroup',)#-----------------------------------------------------------------------------# Dev API#-----------------------------------------------------------------------------
[docs]@abstractclassAbstractGroup(Widget):''' Abstract base class for all kinds of groups. '''# explicit __init__ to support Init signaturesdef__init__(self,*args,**kwargs)->None:super().__init__(*args,**kwargs)labels=List(String,help=""" List of text labels contained in this group. """)
[docs]@abstractclassToggleButtonGroup(AbstractGroup,ButtonLike):''' Abstract base class for groups with items rendered as buttons. '''# explicit __init__ to support Init signaturesdef__init__(self,*args,**kwargs)->None:super().__init__(*args,**kwargs)orientation=Enum("horizontal","vertical",help=""" Orient the button group either horizontally (default) or vertically. """)
[docs]@abstractclassToggleInputGroup(AbstractGroup):''' Abstract base class for groups with items rendered as check/radio boxes. '''# explicit __init__ to support Init signaturesdef__init__(self,*args,**kwargs)->None:super().__init__(*args,**kwargs)inline=Bool(False,help=""" Should items be arrange vertically (``False``) or horizontally in-line (``True``). """)
#-----------------------------------------------------------------------------# General API#-----------------------------------------------------------------------------
[docs]classCheckboxGroup(ToggleInputGroup):''' A group of check boxes. '''# explicit __init__ to support Init signaturesdef__init__(self,*args,**kwargs)->None:super().__init__(*args,**kwargs)active=List(Int,help=""" The list of indices of selected check boxes. """)
[docs]classRadioGroup(ToggleInputGroup):''' A group of radio boxes. '''# explicit __init__ to support Init signaturesdef__init__(self,*args,**kwargs)->None:super().__init__(*args,**kwargs)active=Nullable(Int,help=""" The index of the selected radio box, or ``None`` if nothing is selected. """)
[docs]classCheckboxButtonGroup(ToggleButtonGroup):''' A group of check boxes rendered as toggle buttons. '''# explicit __init__ to support Init signaturesdef__init__(self,*args,**kwargs)->None:super().__init__(*args,**kwargs)active=List(Int,help=""" The list of indices of selected check boxes. """)
[docs]classRadioButtonGroup(ToggleButtonGroup):''' A group of radio boxes rendered as toggle buttons. '''# explicit __init__ to support Init signaturesdef__init__(self,*args,**kwargs)->None:super().__init__(*args,**kwargs)active=Nullable(Int,help=""" The index of the selected radio box, or ``None`` if nothing is selected. """)