A custom Menubar that replaces the OS provided Menubar Why? Two reasons - 1. they look great (see custom titlebar) 2. if you have a custom titlebar, then you have to use a custom menubar if you want a menubar :param menu_definition: The Menu definition specified using lists (
(menu_definition, disabled_text_color=None, bar_font=None, font=None, tearoff=False, pad=0, p=None, background_color=None, text_color=None,
bar_background_color=None, bar_text_color=None, key=None, k=None)
| 13322 | |
| 13323 | |
| 13324 | def MenubarCustom(menu_definition, disabled_text_color=None, bar_font=None, font=None, tearoff=False, pad=0, p=None, background_color=None, text_color=None, |
| 13325 | bar_background_color=None, bar_text_color=None, key=None, k=None): |
| 13326 | """ |
| 13327 | A custom Menubar that replaces the OS provided Menubar |
| 13328 | |
| 13329 | Why? |
| 13330 | Two reasons - 1. they look great (see custom titlebar) 2. if you have a custom titlebar, then you have to use a custom menubar if you want a menubar |
| 13331 | |
| 13332 | :param menu_definition: The Menu definition specified using lists (docs explain the format) |
| 13333 | :type menu_definition: List[List[Tuple[str, List[str]]] |
| 13334 | :param disabled_text_color: color to use for text when item is disabled. Can be in #RRGGBB format or a color name "black" |
| 13335 | :type disabled_text_color: (str) |
| 13336 | :param bar_font: specifies the font family, size to be used for the chars in the bar itself |
| 13337 | :type bar_font: (str or (str, int[, str]) or None) |
| 13338 | :param font: specifies the font family, size to be used for the menu items |
| 13339 | :type font: (str or (str, int[, str]) or None) |
| 13340 | :param tearoff: if True, then can tear the menu off from the window ans use as a floating window. Very cool effect |
| 13341 | :type tearoff: (bool) |
| 13342 | :param pad: Amount of padding to put around element in pixels (left/right, top/bottom) or ((left, right), (top, bottom)) or an int. If an int, then it's converted into a tuple (int, int). TIP - 0 will make flush with titlebar |
| 13343 | :type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) | int |
| 13344 | :param p: Same as pad parameter. It's an alias. If EITHER of them are set, then the one that's set will be used. If BOTH are set, pad will be used |
| 13345 | :type p: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) | int |
| 13346 | :param background_color: color to use for background of the menus that are displayed after making a section. Can be in #RRGGBB format or a color name "black". Defaults to the color of the bar text |
| 13347 | :type background_color: (str) |
| 13348 | :param text_color: color to use for the text of the many items in the displayed menus. Can be in #RRGGBB format or a color name "black". Defaults to the bar background |
| 13349 | :type text_color: (str) |
| 13350 | :param bar_background_color: color to use for the menubar. Can be in #RRGGBB format or a color name "black". Defaults to theme's button text color |
| 13351 | :type bar_background_color: (str) |
| 13352 | :param bar_text_color: color to use for the menu items text. Can be in #RRGGBB format or a color name "black". Defaults to theme's button background color |
| 13353 | :type bar_text_color: (str) |
| 13354 | :param key: Value that uniquely identifies this element from all other elements. Used when Finding an element or in return values. Must be unique to the window |
| 13355 | :type key: str | int | tuple | object |
| 13356 | :param k: Same as the Key. You can use either k or key. Which ever is set will be used. |
| 13357 | :type k: str | int | tuple | object |
| 13358 | :returns: A Column element that has a series of ButtonMenu elements |
| 13359 | :rtype: Column |
| 13360 | """ |
| 13361 | |
| 13362 | bar_bg = bar_background_color if bar_background_color is not None else theme_button_color()[0] |
| 13363 | bar_text = bar_text_color if bar_text_color is not None else theme_button_color()[1] |
| 13364 | menu_bg = background_color if background_color is not None else bar_text |
| 13365 | menu_text = text_color if text_color is not None else bar_bg |
| 13366 | pad = pad if pad is not None else p |
| 13367 | |
| 13368 | row = [] |
| 13369 | for menu in menu_definition: |
| 13370 | text = menu[0] |
| 13371 | if MENU_SHORTCUT_CHARACTER in text: |
| 13372 | text = text.replace(MENU_SHORTCUT_CHARACTER, '') |
| 13373 | if text.startswith(MENU_DISABLED_CHARACTER): |
| 13374 | disabled = True |
| 13375 | text = text[len(MENU_DISABLED_CHARACTER):] |
| 13376 | else: |
| 13377 | disabled = False |
| 13378 | |
| 13379 | button_menu = ButtonMenu(text, menu, border_width=0, button_color=(bar_text, bar_bg), key=text, pad=(0, 0), disabled=disabled, font=bar_font, |
| 13380 | item_font=font, disabled_text_color=disabled_text_color, text_color=menu_text, background_color=menu_bg, tearoff=tearoff) |
| 13381 | button_menu.part_of_custom_menubar = True |
no test coverage detected