MCPcopy Index your code
hub / github.com/PySimpleGUI/PySimpleGUI / _add_right_click_menu_and_grab

Function _add_right_click_menu_and_grab

PySimpleGUI/PySimpleGUI.py:15687–15731  ·  view source on GitHub ↗
(element)

Source from the content-addressed store, hash-verified

15685 # print(e)
15686
15687 def _add_right_click_menu_and_grab(element):
15688 if element.RightClickMenu == MENU_RIGHT_CLICK_DISABLED:
15689 return
15690 if element.Type == ELEM_TYPE_TAB_GROUP: # unless everything disabled, then need to always set a right click menu for tabgroups
15691 if toplevel_form.RightClickMenu == MENU_RIGHT_CLICK_DISABLED:
15692 return
15693 menu = _MENU_RIGHT_CLICK_TABGROUP_DEFAULT
15694 else:
15695 menu = element.RightClickMenu or form.RightClickMenu or toplevel_form.RightClickMenu
15696
15697 if menu:
15698 top_menu = tk.Menu(toplevel_form.TKroot, tearoff=toplevel_form.right_click_menu_tearoff, tearoffcommand=element._tearoff_menu_callback)
15699
15700 if toplevel_form.right_click_menu_background_color not in (COLOR_SYSTEM_DEFAULT, None):
15701 top_menu.config(bg=toplevel_form.right_click_menu_background_color)
15702 if toplevel_form.right_click_menu_text_color not in (COLOR_SYSTEM_DEFAULT, None):
15703 top_menu.config(fg=toplevel_form.right_click_menu_text_color)
15704 if toplevel_form.right_click_menu_disabled_text_color not in (COLOR_SYSTEM_DEFAULT, None):
15705 top_menu.config(disabledforeground=toplevel_form.right_click_menu_disabled_text_color)
15706 if toplevel_form.right_click_menu_font is not None:
15707 top_menu.config(font=toplevel_form.right_click_menu_font)
15708
15709 if toplevel_form.right_click_menu_selected_colors[0] not in (COLOR_SYSTEM_DEFAULT, None):
15710 top_menu.config(activeforeground=toplevel_form.right_click_menu_selected_colors[0])
15711 if toplevel_form.right_click_menu_selected_colors[1] not in (COLOR_SYSTEM_DEFAULT, None):
15712 top_menu.config(activebackground=toplevel_form.right_click_menu_selected_colors[1])
15713 AddMenuItem(top_menu, menu[1], element, right_click_menu=True)
15714 element.TKRightClickMenu = top_menu
15715 if toplevel_form.RightClickMenu: # if the top level has a right click menu, then setup a callback for the Window itself
15716 if toplevel_form.TKRightClickMenu is None:
15717 toplevel_form.TKRightClickMenu = top_menu
15718 if (running_mac()):
15719 toplevel_form.TKroot.bind('<ButtonRelease-2>', toplevel_form._RightClickMenuCallback)
15720 else:
15721 toplevel_form.TKroot.bind('<ButtonRelease-3>', toplevel_form._RightClickMenuCallback)
15722 if (running_mac()):
15723 element.Widget.bind('<ButtonRelease-2>', element._RightClickMenuCallback)
15724 else:
15725 element.Widget.bind('<ButtonRelease-3>', element._RightClickMenuCallback)
15726 try:
15727 if element.Type == ELEM_TYPE_COLUMN:
15728 element.TKColFrame.canvas.bind('<ButtonRelease-3>', element._RightClickMenuCallback)
15729 except:
15730 pass
15731 _add_grab(element)
15732
15733 def _add_expansion(element, row_should_expand, row_fill_direction):
15734 expand = True

Callers 1

PackFormIntoFrameFunction · 0.85

Calls 4

AddMenuItemFunction · 0.85
running_macFunction · 0.85
_add_grabFunction · 0.85
bindMethod · 0.45

Tested by

no test coverage detected