Makes a "popup menu" This type of menu is what you get when a normal menu or a right click menu is torn off The settings for the menu are obtained from the window parameter's Window :param window: The window associated with the popup menu. The theme and right click menu settings
(window, element, menu_def, title=None, location=(None, None))
| 22034 | |
| 22035 | |
| 22036 | def popup_menu(window, element, menu_def, title=None, location=(None, None)): |
| 22037 | """ |
| 22038 | Makes a "popup menu" |
| 22039 | This type of menu is what you get when a normal menu or a right click menu is torn off |
| 22040 | The settings for the menu are obtained from the window parameter's Window |
| 22041 | |
| 22042 | |
| 22043 | :param window: The window associated with the popup menu. The theme and right click menu settings for this window will be used |
| 22044 | :type window: Window |
| 22045 | :param element: An element in your window to associate the menu to. It can be any element |
| 22046 | :type element: Element |
| 22047 | :param menu_def: A menu definition. This will be the same format as used for Right Click Menus1 |
| 22048 | :type menu_def: List[List[ List[str] | str ]] |
| 22049 | :param title: The title that will be shown on the torn off menu window. Defaults to window titlr |
| 22050 | :type title: str |
| 22051 | :param location: The location on the screen to place the window |
| 22052 | :type location: (int, int) | (None, None) |
| 22053 | """ |
| 22054 | |
| 22055 | element._popup_menu_location = location |
| 22056 | top_menu = tk.Menu(window.TKroot, tearoff=True, tearoffcommand=element._tearoff_menu_callback) |
| 22057 | if window.right_click_menu_background_color not in (COLOR_SYSTEM_DEFAULT, None): |
| 22058 | top_menu.config(bg=window.right_click_menu_background_color) |
| 22059 | if window.right_click_menu_text_color not in (COLOR_SYSTEM_DEFAULT, None): |
| 22060 | top_menu.config(fg=window.right_click_menu_text_color) |
| 22061 | if window.right_click_menu_disabled_text_color not in (COLOR_SYSTEM_DEFAULT, None): |
| 22062 | top_menu.config(disabledforeground=window.right_click_menu_disabled_text_color) |
| 22063 | if window.right_click_menu_font is not None: |
| 22064 | top_menu.config(font=window.right_click_menu_font) |
| 22065 | if window.right_click_menu_selected_colors[0] != COLOR_SYSTEM_DEFAULT: |
| 22066 | top_menu.config(activeforeground=window.right_click_menu_selected_colors[0]) |
| 22067 | if window.right_click_menu_selected_colors[1] != COLOR_SYSTEM_DEFAULT: |
| 22068 | top_menu.config(activebackground=window.right_click_menu_selected_colors[1]) |
| 22069 | top_menu.config(title=window.Title if title is None else title) |
| 22070 | AddMenuItem(top_menu, menu_def[1], element, right_click_menu=True) |
| 22071 | # element.Widget.bind('<Button-3>', element._RightClickMenuCallback) |
| 22072 | top_menu.invoke(0) |
| 22073 | |
| 22074 | # Antipattern anyone? A global variable used by the error traceback window to stop recursive calls due to error while displaying error |
| 22075 | class _PopupErrorGlobals: |
nothing calls this directly
no test coverage detected