# Path: mGui/gui.py
# def _collect_mappings():
# def wrap(control, replace_events=False):
# def derive(control):


from mGui import gui
__author__ = 'bobwhite'

"""
This example shows how to create a mGui window with menus and submenus using the new mGui 2.1 submenu syntax
"""



def food_selected(*_, **kwargs):
    print "order " + kwargs['sender'].label


def pizza_selected(*_, **kwargs):
    pizza = kwargs['sender'].parent

    toppings = [i.label for i in pizza.controls if isinstance(i, gui.CheckBoxMenuItem) and  i.checkBox]
    print "order pizza " + (" and ".join(toppings))


def radio_selected(*_, **kwargs):
    print 'delivery:', kwargs['sender'].label
    kwargs['sender'].parent.label = "Delivery: " + kwargs['sender'].label


# the use of tag here acts as a keepalive, so the functions don't get garbage collected
# this is a useful alternative to classes  for simple cases

# Path: mGui/gui.py
# def _collect_mappings():
# def wrap(control, replace_events=False):
# def derive(control):


# Path: mGui/examples/menus.py
from mGui import gui

__author__ = 'bobwhite'

"""
This example shows how to create a mGui window with menus and submenus using the new mGui 2.1 submenu syntax
"""



def food_selected(*_, **kwargs):
    print "order " + kwargs['sender'].label


def pizza_selected(*_, **kwargs):
    pizza = kwargs['sender'].parent

    toppings = [i.label for i in pizza.controls if isinstance(i, gui.CheckBoxMenuItem) and  i.checkBox]
    print "order pizza " + (" and ".join(toppings))


def radio_selected(*_, **kwargs):
    print 'delivery:', kwargs['sender'].label
    kwargs['sender'].parent.label = "Delivery: " + kwargs['sender'].label


# the use of tag here acts as a keepalive, so the functions don't get garbage collected
# this is a useful alternative to classes  for simple cases

with gui.Window(menuBar=True, tag=(food_selected, pizza_selected, radio_selected)) as test_window: