
"""Definitions for OptionLists.

Most parts of the game shouldn't need to worry about creating and managing
tkinter.Button instances for options; as such, this module defines an API for
creating an 'OptionList' which does not require an active instance of tkinter
and can create a new tkinter.Frame with the appropriate buttons when needed.
"""

import inspect
import tkinter
from rpg import event
from rpg.ui import widgets

import typing
if typing.TYPE_CHECKING:
    from rpg import app
    from typing import List, Optional, Tuple

OptionWidget = typing.Union[tkinter.Label, widgets.Button]
OptionDefinition = typing.Tuple[str, event.GameEvent]


class Option(object):
    """The definition of an option on the GameView.

    An option encodes a name, an event, and if it is enabled.
    """

    def __init__(self, name, event_instance: 'event.GameEvent',
                 visible: bool = True) -> None:
        """Initialize the option.

        :param name: The name of the option, used for the text on the button
        :param event_instance: A GameEvent instance which can be applied on the
                               button press event
        :param visible: If the option is visible
        """
        self.name = name
        self.event = event_instance