Sets a right click menu for an element. If a menu is already set for the element, it will call the tkinter destroy method to remove it :param menu: A list of lists of Menu items to show when this element is right clicked. See user docs for exact format.
(self, menu=None)
| 1797 | |
| 1798 | |
| 1799 | def set_right_click_menu(self, menu=None): |
| 1800 | """ |
| 1801 | Sets a right click menu for an element. |
| 1802 | If a menu is already set for the element, it will call the tkinter destroy method to remove it |
| 1803 | :param menu: A list of lists of Menu items to show when this element is right clicked. See user docs for exact format. |
| 1804 | :type menu: List[List[ List[str] | str ]] |
| 1805 | """ |
| 1806 | if menu == MENU_RIGHT_CLICK_DISABLED: |
| 1807 | return |
| 1808 | if menu is None: |
| 1809 | menu = self.ParentForm.RightClickMenu |
| 1810 | if menu is None: |
| 1811 | return |
| 1812 | if menu: |
| 1813 | # If previously had a menu destroy it |
| 1814 | if self.TKRightClickMenu: |
| 1815 | try: |
| 1816 | self.TKRightClickMenu.destroy() # just in case there's a problem let's not crash |
| 1817 | except: |
| 1818 | pass |
| 1819 | top_menu = tk.Menu(self.ParentForm.TKroot, tearoff=self.ParentForm.right_click_menu_tearoff, tearoffcommand=self._tearoff_menu_callback) |
| 1820 | |
| 1821 | if self.ParentForm.right_click_menu_background_color not in (COLOR_SYSTEM_DEFAULT, None): |
| 1822 | top_menu.config(bg=self.ParentForm.right_click_menu_background_color) |
| 1823 | if self.ParentForm.right_click_menu_text_color not in (COLOR_SYSTEM_DEFAULT, None): |
| 1824 | top_menu.config(fg=self.ParentForm.right_click_menu_text_color) |
| 1825 | if self.ParentForm.right_click_menu_disabled_text_color not in (COLOR_SYSTEM_DEFAULT, None): |
| 1826 | top_menu.config(disabledforeground=self.ParentForm.right_click_menu_disabled_text_color) |
| 1827 | if self.ParentForm.right_click_menu_font is not None: |
| 1828 | top_menu.config(font=self.ParentForm.right_click_menu_font) |
| 1829 | |
| 1830 | if self.ParentForm.right_click_menu_selected_colors[0] not in (COLOR_SYSTEM_DEFAULT, None): |
| 1831 | top_menu.config(activeforeground=self.ParentForm.right_click_menu_selected_colors[0]) |
| 1832 | if self.ParentForm.right_click_menu_selected_colors[1] not in (COLOR_SYSTEM_DEFAULT, None): |
| 1833 | top_menu.config(activebackground=self.ParentForm.right_click_menu_selected_colors[1]) |
| 1834 | AddMenuItem(top_menu, menu[1], self, right_click_menu=True) |
| 1835 | self.TKRightClickMenu = top_menu |
| 1836 | if self.ParentForm.RightClickMenu: # if the top level has a right click menu, then setup a callback for the Window itself |
| 1837 | if self.ParentForm.TKRightClickMenu is None: |
| 1838 | self.ParentForm.TKRightClickMenu = top_menu |
| 1839 | if (running_mac()): |
| 1840 | self.ParentForm.TKroot.bind('<ButtonRelease-2>', self.ParentForm._RightClickMenuCallback) |
| 1841 | else: |
| 1842 | self.ParentForm.TKroot.bind('<ButtonRelease-3>', self.ParentForm._RightClickMenuCallback) |
| 1843 | if (running_mac()): |
| 1844 | self.Widget.bind('<ButtonRelease-2>', self._RightClickMenuCallback) |
| 1845 | else: |
| 1846 | self.Widget.bind('<ButtonRelease-3>', self._RightClickMenuCallback) |
| 1847 | |
| 1848 | |
| 1849 | def save_element_screenshot_to_disk(self, filename=None): |
no test coverage detected