Skip to content

Instantly share code, notes, and snippets.

@abhijangda
Last active December 17, 2015 20:39
Show Gist options
  • Select an option

  • Save abhijangda/5669133 to your computer and use it in GitHub Desktop.

Select an option

Save abhijangda/5669133 to your computer and use it in GitHub Desktop.
There will be following classes with their parent classes and
the methods they will support
class MenuBar (BoxLayout):
# This is a BoxLayout with horizontal orientation
def add_widget (self, menu_item, index=0):
"""To add a MenuItem to MenuBar. This function will first check
whether menu_item is a MenuItem or any other Widget"""
class Menu (Bubble):
def add_widget (self, menu_item, index=0):
"""To add a MenuItem to MenuBar. This function will first check
whether menu_item is a MenuItem or any other Widget"""
def attach_to_menu_item (self, menu_item):
"""This will attach self to menu_item. So, clicking on menu_item will
display the Menu. One Menu could be attached with only one
menu_item"""
def detach_from_menu_item (self):
"""This will detach menu from the menu_item"""
Events:
on_activate: will be called when Menu is shown to the user.
on_select: when any MenuItem from Menu is selected.
This is available in DropDown already.
on_attach: when Menu is attached to the menu_item.
on_detach: when Menu is detached from the menu_item.
class MenuItem (object):
"""This is an abstract class for MenuItem"""
class MenuItemButton (MenuItem, Button):
class MenuItemButton (MenuItem, ToggleButton):
class MenuItemButton (MenuItem, CheckBox):
These classes already contains, their own required events
Normal procedure to create a Menu.
Create a MenuBar
Create a MenuItem and then add to MenuBar
Create a Menu and attach it to MenuItem
Create new MenuItems and add them to Menu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment