[Idle-dev] help on Idle extension

Hernan Martinez Foffani hernan@orgmf.com.ar
Thu, 16 Aug 2001 01:11:49 +0200


Hi,
Before I give up, can anybody help me with this extension,
please? I'm a bit embarrased to ask because this is so
simple that it has to work.

With the following class a new menu option "Python Shelf"
does show up, but when I click it nothing happens.

Apparently, the method documents_event is not being dispatch
by Idle. Don't know why. Running the test standalone does
what I want, ie: a notepad window is opened.

FYI, there is an empty section [ContextHelp] at config.txt

I bet I'm missing something very obvious here.

Thanks in advance,
-Hernan

Win2000, Python 2.2a1, idle 0.8 and idlefork 0.8.x

---8<---8<--- ContextHelp.py ---8<---8<---

import webbrowser

class ContextHelp:
   
    menudefs = [ ('help', [
            None, # Separator
           ('Python _Shelf', '<<documents-event>>'),
         ]) ]

    windows_keydefs = { '<<documents-event>>': ['<Alt-F9>'], }
    unix_keydefs = { '<<documents-event>>': ['<Alt-F9>'], }

    def __init__(self, editwin):
        self.editwin = editwin

    def documents_event(self, event):
        webbrowser.open( "c:/pepe.txt") # whatever 

def test():
    a = ContextHelp(None)
    a.documents_event(None)

if __name__ == '__main__':
    test()