Thank you both again. Here is the code I ended up using, for future 
reference. I went for Terry's solution because its very clean, and I need 
to create nothing else but a @script node in each outline I want this 
working like that:

'''
How to replace a method in Leo (Make Leo behave differently without 
modifying leopyref.leo):

- Find the method. In my case, it was:
c.frame.tree.treeWidget.urlDrop
- Define your new function (urlDrop in the example code)
-  Run the example script whenever you want Leo to behave differently.
- [EXTRA] If you want this to happen everytime you run a Leo file, place 
the script under a node with a header "@script", and enable auto-running 
@script nodes in Leo config file.
'''

#Example script:

def urlDrop():
    #Things you want Leo to do instead of what it does now
    pass

#You need to import types, and also any modules your function needs. In my 
case, I had to import also QtCore:
import types
from PyQt4 import QtCore

#Replacement of your method:
c.frame.tree.treeWidget.urlDrop = urlDrop
c.frame.tree.treeWidget.urlDrop = types.MethodType(urlDrop, c.frame.tree.
treeWidget.urlDrop)


-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at http://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.

Reply via email to