-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Description
Type of Issues (Enhancement, Error, Bug, Question)
Operating System
Windows 10
Python version
3.7.2
PySimpleGUI Port and Version
tkinter '4.4.1 Released'
Your Experience Levels In Months or Years
9 years Python programming experience
12 years Programming experience overall
Yes, I Have used another Python GUI Framework (tkiner, Qt, etc) previously (yes/no is fine)?
You have completed these steps:
- [Yes] Read instructions on how to file an Issue
- [Yes] Searched through main docs http://www.PySimpleGUI.org for your problem
- [Yes] Searched through the readme for your specific port if not PySimpleGUI (Qt, WX, Remi)
- [Yes] Looked for Demo Programs that are similar to your goal http://www.PySimpleGUI.com
- [Yes] Note that there are also Demo Programs under each port on GitHub
- [Yes] Run your program outside of your debugger (from a command line)
- [Yes] Searched through Issues (open and closed) to see if already reported
Code or partial code causing the problem
Is there any way to enable/disable Right Menu Definitions on elements? I tried mutating menu definition to not have the ! character (Did not work), and trying to use Update(right_click_menu=new_layout) complains about a unexpected value.
import PySimpleGUI as sg
right = ["that",["this"]]
layout = [[sg.Text("SAMPLETEXT", key="text", right_click_menu = right)]]
window = sg.Window('Right Click Menu Mutator Debunker :c', layout, grab_anywhere=False).Finalize()
while True:
event, values = window.Read()
if event == "this":
right[1][0] = "mutated" # doesnt mutate
window.Element("text").Update(right_click_menu=right) #crashes
This doesn't work.
Update: After messing with the source code of the project and trying to comprehend most of everything that was happening with it, I was able to manually enable/disable elements within a single nested RightClickMenu (Which is what I need, but this could be extended to nested menus). This is extremely hackish tho
import PySimpleGUI as sg
import tkinter as tk
#MENU_DISABLED_CHARACTER = '!'
right = ["that",["this","there","those"]]
layout = [[sg.Text("SAMPLETEXT", key="text", right_click_menu = right)]]
window = sg.Window('Right Click Menu Mutator Debunker :c', layout, grab_anywhere=False).Finalize()
while True:
event, values = window.Read()
if event == "this":
element = window.Element("text")
tkright = element.TKRightClickMenu
for menu_element in right[1]:
if menu_element[0] == "!":
tkright.entryconfig(menu_element[1:], state='disabled')
else:
tkright.entryconfig(menu_element, state='disabled')
print(event,values)