I need to make an extension for Idle, that lets me change its right click menu (context menu?) to add events/options that i want to be there. Mainly for Idle Editor. I only found documentation on how to change the classic top menu, but havent seen anything about changing the right click menu.
I have a standalone program that lets me make new rmenu in Tkinter and need to implement it into Idle. I found editor.py, where is the rmenu configured, but havent made much out of it.
As discovered, IDLE provides a mechanism for user extensions to declare new main menu entries that IDLE will insert into the main menu. It does not currently provide a similar mechanism for inserting into the right-click context menu. This seems like a sensible idea so I added draft issue "IDLE config extension: allow addition to context menu" to the IDLE project page with a reference to this question. I will consider this should I focus on extensions some time in the future.
In the meanwhile, look at the sample extension idlelib/zzdummy.py. Instead of the menudefs declaration, you would have to add code in
YourExtClass.__init__to do 1 of 2 things:Add (append) a tuple to
text.rmenu_defs(a list). The example ineditor.EditorWindow.rmenu_specs(currently line 589) is("Close", "<<close-window>>", None). The actual editorrmenu_specsis inpyshellline 153. UseNonefor the 3rd member.add a command to
text.rmenuusing code like that ineditor.EditorWindow.make_rmenu.The choice depends on whether IDLE installs extensions before or after making rmenu.