diff options
author | Guido van Rossum <guido@python.org> | 1994-07-13 12:54:42 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1994-07-13 12:54:42 (GMT) |
commit | 3284abe75469b00ab83f1899b4b825f211320859 (patch) | |
tree | 2e8c266cf4c8e0ca0eb9b9ca37bf9d09224e13c8 /Demo | |
parent | 50f437c9682e4f6a3d33f6189250ff0f3a65b5ea (diff) | |
download | cpython-3284abe75469b00ab83f1899b4b825f211320859.zip cpython-3284abe75469b00ab83f1899b4b825f211320859.tar.gz cpython-3284abe75469b00ab83f1899b4b825f211320859.tar.bz2 |
Initial revision
Diffstat (limited to 'Demo')
-rwxr-xr-x | Demo/tkinter/guido/listtree.py | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/Demo/tkinter/guido/listtree.py b/Demo/tkinter/guido/listtree.py new file mode 100755 index 0000000..5b5984c --- /dev/null +++ b/Demo/tkinter/guido/listtree.py @@ -0,0 +1,36 @@ +# Print a remote app's widget tree (names and classes only) + +import sys +import string + +from Tkinter import * + +def listtree(master, app): + list = Listbox(master, {'name': 'list', + Pack: {'expand': 1, 'fill': 'both'}}) + listnodes(list, app, '.', 0) + return list + +def listnodes(list, app, widget, level): + klass = list.send(app, 'winfo', 'class', widget) +## i = string.rindex(widget, '.') +## list.insert('end', '%s%s (%s)' % ((level-1)*'. ', widget[i:], klass)) + list.insert('end', '%s (%s)' % (widget, klass)) + children = list.tk.splitlist( + list.send(app, 'winfo', 'children', widget)) + for c in children: + listnodes(list, app, c, level+1) + +def main(): + if not sys.argv[1:]: + sys.stderr.write('Usage: listtree appname\n') + sys.exit(2) + app = sys.argv[1] + tk = Tk() + tk.minsize(1, 1) + f = Frame(tk, {'name': 'f', Pack: {'expand': 1, 'fill': 'both'}}) + list = listtree(f, app) + tk.mainloop() + +if __name__ == '__main__': + main() |