Source code for bokeh.models.ui.menus

#-----------------------------------------------------------------------------
# Copyright (c) 2012 - 2024, Anaconda, Inc., and Bokeh Contributors.
# All rights reserved.
#
# The full license is in the file LICENSE.txt, distributed with this software.
#-----------------------------------------------------------------------------
"""

"""

#-----------------------------------------------------------------------------
# Boilerplate
#-----------------------------------------------------------------------------
from __future__ import annotations

import logging # isort:skip
log = logging.getLogger(__name__)

#-----------------------------------------------------------------------------
# Imports
#-----------------------------------------------------------------------------

# Bokeh imports
from ...core.enums import Orientation
from ...core.has_props import abstract
from ...core.properties import (
    Bool,
    Enum,
    Instance,
    List,
    Nullable,
    Required,
    String,
)
from .icons import Icon
from .ui_element import UIElement

#-----------------------------------------------------------------------------
# Globals and constants
#-----------------------------------------------------------------------------

__all__ = (
    "Action",
    "Menu",
    "Section",
    "Divider",
)

#-----------------------------------------------------------------------------
# General API
#-----------------------------------------------------------------------------

#-----------------------------------------------------------------------------
# Dev API
#-----------------------------------------------------------------------------

@abstract
class MenuItem(UIElement):
    """ """

    # explicit __init__ to support Init signatures
    def __init__(self, *args, **kwargs) -> None:
        super().__init__(*args, **kwargs)

[docs] class Action(MenuItem): """ """ # explicit __init__ to support Init signatures def __init__(self, *args, **kwargs) -> None: super().__init__(*args, **kwargs) icon = Nullable(Instance(Icon), default=None, help=""" """) label = Required(String, help=""" """) description = Nullable(String, default=None, help=""" """) menu = Nullable(Instance(lambda: Menu), default=None, help=""" """)
class CheckAction(Action): """ """ # explicit __init__ to support Init signatures def __init__(self, *args, **kwargs) -> None: super().__init__(*args, **kwargs) checked = Bool(default=False, help=""" """) # group = Either(Instance(Group), Auto)
[docs] class Section(MenuItem): """ """ # explicit __init__ to support Init signatures def __init__(self, *args, **kwargs) -> None: super().__init__(*args, **kwargs) items = List(Instance(Action), default=[], help=""" """)
[docs] class Divider(MenuItem): """ """ # explicit __init__ to support Init signatures def __init__(self, *args, **kwargs) -> None: super().__init__(*args, **kwargs)
#----------------------------------------------------------------------------- # Private API #----------------------------------------------------------------------------- #----------------------------------------------------------------------------- # Code #-----------------------------------------------------------------------------