1994-08-03 05:10:35 -03:00
|
|
|
# List a remote app's widget tree (names and classes only)
|
1994-07-13 09:54:42 -03:00
|
|
|
|
|
|
|
import sys
|
|
|
|
|
2009-01-04 14:53:28 -04:00
|
|
|
from tkinter import *
|
1994-07-13 09:54:42 -03:00
|
|
|
|
|
|
|
def listtree(master, app):
|
2004-07-18 03:16:08 -03:00
|
|
|
list = Listbox(master, name='list')
|
|
|
|
list.pack(expand=1, fill=BOTH)
|
|
|
|
listnodes(list, app, '.', 0)
|
|
|
|
return list
|
1994-07-13 09:54:42 -03:00
|
|
|
|
|
|
|
def listnodes(list, app, widget, level):
|
2004-07-18 03:16:08 -03:00
|
|
|
klass = list.send(app, 'winfo', 'class', widget)
|
|
|
|
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)
|
1994-07-13 09:54:42 -03:00
|
|
|
|
|
|
|
def main():
|
2004-07-18 03:16:08 -03:00
|
|
|
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')
|
|
|
|
f.pack(expand=1, fill=BOTH)
|
|
|
|
list = listtree(f, app)
|
|
|
|
tk.mainloop()
|
1994-07-13 09:54:42 -03:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2004-07-18 03:16:08 -03:00
|
|
|
main()
|