This will be something for the startup *dev* tips.  Yes, I think we need 
various categories of tips...

Recent revs add the "verbose" keyword arg to g.callers(), and retires the 
"files" keyword arg. g.callers(verbose=True) returns the callers on 
separate lines.  This is especially useful for gui programming, where there 
may be many 'display, 'edit', 'redraw' and 'update' methods.  It's also 
useful where you just don't have any idea where a function or method 
resides.

For example, these traces, in BoxTitle.edit:

g.trace('===== (BoxTitle:%s) entry_widget: %s' % (
    self.__class__.__name__,
    self.entry_widget.__class__.__name__))
g.trace('CALLERS', g.callers(verbose=True))

Produce:

trace: edit ===== (BoxTitle:BoxTitleLog) entry_widget: LeoLog
trace: edit CALLERS
  line   32 apNPSApplication.py            LeoApp.
__remove_argument_call_main
  line 2711 cursesGui2.py                  LeoApp.main
  line 1632 cursesGui2.py                  LeoCursesGui.run
  line   66 fm_form_edit_loop.py           LeoForm.edit

Each line shows the line number and file containing the function or 
method.  All the above lines show methods.

Edward

P. S. Today's great innovation, in g._callerName, is to get the class name 
using code equivalent to:

sys._getframe(n).f_code.locals_.get('self').__class__.__name__

EKR

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.

Reply via email to