1 | n/a | # XXX TO DO: |
---|
2 | n/a | # - popup menu |
---|
3 | n/a | # - support partial or total redisplay |
---|
4 | n/a | # - key bindings (instead of quick-n-dirty bindings on Canvas): |
---|
5 | n/a | # - up/down arrow keys to move focus around |
---|
6 | n/a | # - ditto for page up/down, home/end |
---|
7 | n/a | # - left/right arrows to expand/collapse & move out/in |
---|
8 | n/a | # - more doc strings |
---|
9 | n/a | # - add icons for "file", "module", "class", "method"; better "python" icon |
---|
10 | n/a | # - callback for selection??? |
---|
11 | n/a | # - multiple-item selection |
---|
12 | n/a | # - tooltips |
---|
13 | n/a | # - redo geometry without magic numbers |
---|
14 | n/a | # - keep track of object ids to allow more careful cleaning |
---|
15 | n/a | # - optimize tree redraw after expand of subnode |
---|
16 | n/a | |
---|
17 | n/a | import os |
---|
18 | n/a | |
---|
19 | n/a | from tkinter import * |
---|
20 | n/a | from tkinter.ttk import Scrollbar |
---|
21 | n/a | |
---|
22 | n/a | from idlelib.config import idleConf |
---|
23 | n/a | from idlelib import zoomheight |
---|
24 | n/a | |
---|
25 | n/a | ICONDIR = "Icons" |
---|
26 | n/a | |
---|
27 | n/a | # Look for Icons subdirectory in the same directory as this module |
---|
28 | n/a | try: |
---|
29 | n/a | _icondir = os.path.join(os.path.dirname(__file__), ICONDIR) |
---|
30 | n/a | except NameError: |
---|
31 | n/a | _icondir = ICONDIR |
---|
32 | n/a | if os.path.isdir(_icondir): |
---|
33 | n/a | ICONDIR = _icondir |
---|
34 | n/a | elif not os.path.isdir(ICONDIR): |
---|
35 | n/a | raise RuntimeError("can't find icon directory (%r)" % (ICONDIR,)) |
---|
36 | n/a | |
---|
37 | n/a | def listicons(icondir=ICONDIR): |
---|
38 | n/a | """Utility to display the available icons.""" |
---|
39 | n/a | root = Tk() |
---|
40 | n/a | import glob |
---|
41 | n/a | list = glob.glob(os.path.join(icondir, "*.gif")) |
---|
42 | n/a | list.sort() |
---|
43 | n/a | images = [] |
---|
44 | n/a | row = column = 0 |
---|
45 | n/a | for file in list: |
---|
46 | n/a | name = os.path.splitext(os.path.basename(file))[0] |
---|
47 | n/a | image = PhotoImage(file=file, master=root) |
---|
48 | n/a | images.append(image) |
---|
49 | n/a | label = Label(root, image=image, bd=1, relief="raised") |
---|
50 | n/a | label.grid(row=row, column=column) |
---|
51 | n/a | label = Label(root, text=name) |
---|
52 | n/a | label.grid(row=row+1, column=column) |
---|
53 | n/a | column = column + 1 |
---|
54 | n/a | if column >= 10: |
---|
55 | n/a | row = row+2 |
---|
56 | n/a | column = 0 |
---|
57 | n/a | root.images = images |
---|
58 | n/a | |
---|
59 | n/a | |
---|
60 | n/a | class TreeNode: |
---|
61 | n/a | |
---|
62 | n/a | def __init__(self, canvas, parent, item): |
---|
63 | n/a | self.canvas = canvas |
---|
64 | n/a | self.parent = parent |
---|
65 | n/a | self.item = item |
---|
66 | n/a | self.state = 'collapsed' |
---|
67 | n/a | self.selected = False |
---|
68 | n/a | self.children = [] |
---|
69 | n/a | self.x = self.y = None |
---|
70 | n/a | self.iconimages = {} # cache of PhotoImage instances for icons |
---|
71 | n/a | |
---|
72 | n/a | def destroy(self): |
---|
73 | n/a | for c in self.children[:]: |
---|
74 | n/a | self.children.remove(c) |
---|
75 | n/a | c.destroy() |
---|
76 | n/a | self.parent = None |
---|
77 | n/a | |
---|
78 | n/a | def geticonimage(self, name): |
---|
79 | n/a | try: |
---|
80 | n/a | return self.iconimages[name] |
---|
81 | n/a | except KeyError: |
---|
82 | n/a | pass |
---|
83 | n/a | file, ext = os.path.splitext(name) |
---|
84 | n/a | ext = ext or ".gif" |
---|
85 | n/a | fullname = os.path.join(ICONDIR, file + ext) |
---|
86 | n/a | image = PhotoImage(master=self.canvas, file=fullname) |
---|
87 | n/a | self.iconimages[name] = image |
---|
88 | n/a | return image |
---|
89 | n/a | |
---|
90 | n/a | def select(self, event=None): |
---|
91 | n/a | if self.selected: |
---|
92 | n/a | return |
---|
93 | n/a | self.deselectall() |
---|
94 | n/a | self.selected = True |
---|
95 | n/a | self.canvas.delete(self.image_id) |
---|
96 | n/a | self.drawicon() |
---|
97 | n/a | self.drawtext() |
---|
98 | n/a | |
---|
99 | n/a | def deselect(self, event=None): |
---|
100 | n/a | if not self.selected: |
---|
101 | n/a | return |
---|
102 | n/a | self.selected = False |
---|
103 | n/a | self.canvas.delete(self.image_id) |
---|
104 | n/a | self.drawicon() |
---|
105 | n/a | self.drawtext() |
---|
106 | n/a | |
---|
107 | n/a | def deselectall(self): |
---|
108 | n/a | if self.parent: |
---|
109 | n/a | self.parent.deselectall() |
---|
110 | n/a | else: |
---|
111 | n/a | self.deselecttree() |
---|
112 | n/a | |
---|
113 | n/a | def deselecttree(self): |
---|
114 | n/a | if self.selected: |
---|
115 | n/a | self.deselect() |
---|
116 | n/a | for child in self.children: |
---|
117 | n/a | child.deselecttree() |
---|
118 | n/a | |
---|
119 | n/a | def flip(self, event=None): |
---|
120 | n/a | if self.state == 'expanded': |
---|
121 | n/a | self.collapse() |
---|
122 | n/a | else: |
---|
123 | n/a | self.expand() |
---|
124 | n/a | self.item.OnDoubleClick() |
---|
125 | n/a | return "break" |
---|
126 | n/a | |
---|
127 | n/a | def expand(self, event=None): |
---|
128 | n/a | if not self.item._IsExpandable(): |
---|
129 | n/a | return |
---|
130 | n/a | if self.state != 'expanded': |
---|
131 | n/a | self.state = 'expanded' |
---|
132 | n/a | self.update() |
---|
133 | n/a | self.view() |
---|
134 | n/a | |
---|
135 | n/a | def collapse(self, event=None): |
---|
136 | n/a | if self.state != 'collapsed': |
---|
137 | n/a | self.state = 'collapsed' |
---|
138 | n/a | self.update() |
---|
139 | n/a | |
---|
140 | n/a | def view(self): |
---|
141 | n/a | top = self.y - 2 |
---|
142 | n/a | bottom = self.lastvisiblechild().y + 17 |
---|
143 | n/a | height = bottom - top |
---|
144 | n/a | visible_top = self.canvas.canvasy(0) |
---|
145 | n/a | visible_height = self.canvas.winfo_height() |
---|
146 | n/a | visible_bottom = self.canvas.canvasy(visible_height) |
---|
147 | n/a | if visible_top <= top and bottom <= visible_bottom: |
---|
148 | n/a | return |
---|
149 | n/a | x0, y0, x1, y1 = self.canvas._getints(self.canvas['scrollregion']) |
---|
150 | n/a | if top >= visible_top and height <= visible_height: |
---|
151 | n/a | fraction = top + height - visible_height |
---|
152 | n/a | else: |
---|
153 | n/a | fraction = top |
---|
154 | n/a | fraction = float(fraction) / y1 |
---|
155 | n/a | self.canvas.yview_moveto(fraction) |
---|
156 | n/a | |
---|
157 | n/a | def lastvisiblechild(self): |
---|
158 | n/a | if self.children and self.state == 'expanded': |
---|
159 | n/a | return self.children[-1].lastvisiblechild() |
---|
160 | n/a | else: |
---|
161 | n/a | return self |
---|
162 | n/a | |
---|
163 | n/a | def update(self): |
---|
164 | n/a | if self.parent: |
---|
165 | n/a | self.parent.update() |
---|
166 | n/a | else: |
---|
167 | n/a | oldcursor = self.canvas['cursor'] |
---|
168 | n/a | self.canvas['cursor'] = "watch" |
---|
169 | n/a | self.canvas.update() |
---|
170 | n/a | self.canvas.delete(ALL) # XXX could be more subtle |
---|
171 | n/a | self.draw(7, 2) |
---|
172 | n/a | x0, y0, x1, y1 = self.canvas.bbox(ALL) |
---|
173 | n/a | self.canvas.configure(scrollregion=(0, 0, x1, y1)) |
---|
174 | n/a | self.canvas['cursor'] = oldcursor |
---|
175 | n/a | |
---|
176 | n/a | def draw(self, x, y): |
---|
177 | n/a | # XXX This hard-codes too many geometry constants! |
---|
178 | n/a | dy = 20 |
---|
179 | n/a | self.x, self.y = x, y |
---|
180 | n/a | self.drawicon() |
---|
181 | n/a | self.drawtext() |
---|
182 | n/a | if self.state != 'expanded': |
---|
183 | n/a | return y + dy |
---|
184 | n/a | # draw children |
---|
185 | n/a | if not self.children: |
---|
186 | n/a | sublist = self.item._GetSubList() |
---|
187 | n/a | if not sublist: |
---|
188 | n/a | # _IsExpandable() was mistaken; that's allowed |
---|
189 | n/a | return y+17 |
---|
190 | n/a | for item in sublist: |
---|
191 | n/a | child = self.__class__(self.canvas, self, item) |
---|
192 | n/a | self.children.append(child) |
---|
193 | n/a | cx = x+20 |
---|
194 | n/a | cy = y + dy |
---|
195 | n/a | cylast = 0 |
---|
196 | n/a | for child in self.children: |
---|
197 | n/a | cylast = cy |
---|
198 | n/a | self.canvas.create_line(x+9, cy+7, cx, cy+7, fill="gray50") |
---|
199 | n/a | cy = child.draw(cx, cy) |
---|
200 | n/a | if child.item._IsExpandable(): |
---|
201 | n/a | if child.state == 'expanded': |
---|
202 | n/a | iconname = "minusnode" |
---|
203 | n/a | callback = child.collapse |
---|
204 | n/a | else: |
---|
205 | n/a | iconname = "plusnode" |
---|
206 | n/a | callback = child.expand |
---|
207 | n/a | image = self.geticonimage(iconname) |
---|
208 | n/a | id = self.canvas.create_image(x+9, cylast+7, image=image) |
---|
209 | n/a | # XXX This leaks bindings until canvas is deleted: |
---|
210 | n/a | self.canvas.tag_bind(id, "<1>", callback) |
---|
211 | n/a | self.canvas.tag_bind(id, "<Double-1>", lambda x: None) |
---|
212 | n/a | id = self.canvas.create_line(x+9, y+10, x+9, cylast+7, |
---|
213 | n/a | ##stipple="gray50", # XXX Seems broken in Tk 8.0.x |
---|
214 | n/a | fill="gray50") |
---|
215 | n/a | self.canvas.tag_lower(id) # XXX .lower(id) before Python 1.5.2 |
---|
216 | n/a | return cy |
---|
217 | n/a | |
---|
218 | n/a | def drawicon(self): |
---|
219 | n/a | if self.selected: |
---|
220 | n/a | imagename = (self.item.GetSelectedIconName() or |
---|
221 | n/a | self.item.GetIconName() or |
---|
222 | n/a | "openfolder") |
---|
223 | n/a | else: |
---|
224 | n/a | imagename = self.item.GetIconName() or "folder" |
---|
225 | n/a | image = self.geticonimage(imagename) |
---|
226 | n/a | id = self.canvas.create_image(self.x, self.y, anchor="nw", image=image) |
---|
227 | n/a | self.image_id = id |
---|
228 | n/a | self.canvas.tag_bind(id, "<1>", self.select) |
---|
229 | n/a | self.canvas.tag_bind(id, "<Double-1>", self.flip) |
---|
230 | n/a | |
---|
231 | n/a | def drawtext(self): |
---|
232 | n/a | textx = self.x+20-1 |
---|
233 | n/a | texty = self.y-4 |
---|
234 | n/a | labeltext = self.item.GetLabelText() |
---|
235 | n/a | if labeltext: |
---|
236 | n/a | id = self.canvas.create_text(textx, texty, anchor="nw", |
---|
237 | n/a | text=labeltext) |
---|
238 | n/a | self.canvas.tag_bind(id, "<1>", self.select) |
---|
239 | n/a | self.canvas.tag_bind(id, "<Double-1>", self.flip) |
---|
240 | n/a | x0, y0, x1, y1 = self.canvas.bbox(id) |
---|
241 | n/a | textx = max(x1, 200) + 10 |
---|
242 | n/a | text = self.item.GetText() or "<no text>" |
---|
243 | n/a | try: |
---|
244 | n/a | self.entry |
---|
245 | n/a | except AttributeError: |
---|
246 | n/a | pass |
---|
247 | n/a | else: |
---|
248 | n/a | self.edit_finish() |
---|
249 | n/a | try: |
---|
250 | n/a | self.label |
---|
251 | n/a | except AttributeError: |
---|
252 | n/a | # padding carefully selected (on Windows) to match Entry widget: |
---|
253 | n/a | self.label = Label(self.canvas, text=text, bd=0, padx=2, pady=2) |
---|
254 | n/a | theme = idleConf.CurrentTheme() |
---|
255 | n/a | if self.selected: |
---|
256 | n/a | self.label.configure(idleConf.GetHighlight(theme, 'hilite')) |
---|
257 | n/a | else: |
---|
258 | n/a | self.label.configure(idleConf.GetHighlight(theme, 'normal')) |
---|
259 | n/a | id = self.canvas.create_window(textx, texty, |
---|
260 | n/a | anchor="nw", window=self.label) |
---|
261 | n/a | self.label.bind("<1>", self.select_or_edit) |
---|
262 | n/a | self.label.bind("<Double-1>", self.flip) |
---|
263 | n/a | self.text_id = id |
---|
264 | n/a | |
---|
265 | n/a | def select_or_edit(self, event=None): |
---|
266 | n/a | if self.selected and self.item.IsEditable(): |
---|
267 | n/a | self.edit(event) |
---|
268 | n/a | else: |
---|
269 | n/a | self.select(event) |
---|
270 | n/a | |
---|
271 | n/a | def edit(self, event=None): |
---|
272 | n/a | self.entry = Entry(self.label, bd=0, highlightthickness=1, width=0) |
---|
273 | n/a | self.entry.insert(0, self.label['text']) |
---|
274 | n/a | self.entry.selection_range(0, END) |
---|
275 | n/a | self.entry.pack(ipadx=5) |
---|
276 | n/a | self.entry.focus_set() |
---|
277 | n/a | self.entry.bind("<Return>", self.edit_finish) |
---|
278 | n/a | self.entry.bind("<Escape>", self.edit_cancel) |
---|
279 | n/a | |
---|
280 | n/a | def edit_finish(self, event=None): |
---|
281 | n/a | try: |
---|
282 | n/a | entry = self.entry |
---|
283 | n/a | del self.entry |
---|
284 | n/a | except AttributeError: |
---|
285 | n/a | return |
---|
286 | n/a | text = entry.get() |
---|
287 | n/a | entry.destroy() |
---|
288 | n/a | if text and text != self.item.GetText(): |
---|
289 | n/a | self.item.SetText(text) |
---|
290 | n/a | text = self.item.GetText() |
---|
291 | n/a | self.label['text'] = text |
---|
292 | n/a | self.drawtext() |
---|
293 | n/a | self.canvas.focus_set() |
---|
294 | n/a | |
---|
295 | n/a | def edit_cancel(self, event=None): |
---|
296 | n/a | try: |
---|
297 | n/a | entry = self.entry |
---|
298 | n/a | del self.entry |
---|
299 | n/a | except AttributeError: |
---|
300 | n/a | return |
---|
301 | n/a | entry.destroy() |
---|
302 | n/a | self.drawtext() |
---|
303 | n/a | self.canvas.focus_set() |
---|
304 | n/a | |
---|
305 | n/a | |
---|
306 | n/a | class TreeItem: |
---|
307 | n/a | |
---|
308 | n/a | """Abstract class representing tree items. |
---|
309 | n/a | |
---|
310 | n/a | Methods should typically be overridden, otherwise a default action |
---|
311 | n/a | is used. |
---|
312 | n/a | |
---|
313 | n/a | """ |
---|
314 | n/a | |
---|
315 | n/a | def __init__(self): |
---|
316 | n/a | """Constructor. Do whatever you need to do.""" |
---|
317 | n/a | |
---|
318 | n/a | def GetText(self): |
---|
319 | n/a | """Return text string to display.""" |
---|
320 | n/a | |
---|
321 | n/a | def GetLabelText(self): |
---|
322 | n/a | """Return label text string to display in front of text (if any).""" |
---|
323 | n/a | |
---|
324 | n/a | expandable = None |
---|
325 | n/a | |
---|
326 | n/a | def _IsExpandable(self): |
---|
327 | n/a | """Do not override! Called by TreeNode.""" |
---|
328 | n/a | if self.expandable is None: |
---|
329 | n/a | self.expandable = self.IsExpandable() |
---|
330 | n/a | return self.expandable |
---|
331 | n/a | |
---|
332 | n/a | def IsExpandable(self): |
---|
333 | n/a | """Return whether there are subitems.""" |
---|
334 | n/a | return 1 |
---|
335 | n/a | |
---|
336 | n/a | def _GetSubList(self): |
---|
337 | n/a | """Do not override! Called by TreeNode.""" |
---|
338 | n/a | if not self.IsExpandable(): |
---|
339 | n/a | return [] |
---|
340 | n/a | sublist = self.GetSubList() |
---|
341 | n/a | if not sublist: |
---|
342 | n/a | self.expandable = 0 |
---|
343 | n/a | return sublist |
---|
344 | n/a | |
---|
345 | n/a | def IsEditable(self): |
---|
346 | n/a | """Return whether the item's text may be edited.""" |
---|
347 | n/a | |
---|
348 | n/a | def SetText(self, text): |
---|
349 | n/a | """Change the item's text (if it is editable).""" |
---|
350 | n/a | |
---|
351 | n/a | def GetIconName(self): |
---|
352 | n/a | """Return name of icon to be displayed normally.""" |
---|
353 | n/a | |
---|
354 | n/a | def GetSelectedIconName(self): |
---|
355 | n/a | """Return name of icon to be displayed when selected.""" |
---|
356 | n/a | |
---|
357 | n/a | def GetSubList(self): |
---|
358 | n/a | """Return list of items forming sublist.""" |
---|
359 | n/a | |
---|
360 | n/a | def OnDoubleClick(self): |
---|
361 | n/a | """Called on a double-click on the item.""" |
---|
362 | n/a | |
---|
363 | n/a | |
---|
364 | n/a | # Example application |
---|
365 | n/a | |
---|
366 | n/a | class FileTreeItem(TreeItem): |
---|
367 | n/a | |
---|
368 | n/a | """Example TreeItem subclass -- browse the file system.""" |
---|
369 | n/a | |
---|
370 | n/a | def __init__(self, path): |
---|
371 | n/a | self.path = path |
---|
372 | n/a | |
---|
373 | n/a | def GetText(self): |
---|
374 | n/a | return os.path.basename(self.path) or self.path |
---|
375 | n/a | |
---|
376 | n/a | def IsEditable(self): |
---|
377 | n/a | return os.path.basename(self.path) != "" |
---|
378 | n/a | |
---|
379 | n/a | def SetText(self, text): |
---|
380 | n/a | newpath = os.path.dirname(self.path) |
---|
381 | n/a | newpath = os.path.join(newpath, text) |
---|
382 | n/a | if os.path.dirname(newpath) != os.path.dirname(self.path): |
---|
383 | n/a | return |
---|
384 | n/a | try: |
---|
385 | n/a | os.rename(self.path, newpath) |
---|
386 | n/a | self.path = newpath |
---|
387 | n/a | except OSError: |
---|
388 | n/a | pass |
---|
389 | n/a | |
---|
390 | n/a | def GetIconName(self): |
---|
391 | n/a | if not self.IsExpandable(): |
---|
392 | n/a | return "python" # XXX wish there was a "file" icon |
---|
393 | n/a | |
---|
394 | n/a | def IsExpandable(self): |
---|
395 | n/a | return os.path.isdir(self.path) |
---|
396 | n/a | |
---|
397 | n/a | def GetSubList(self): |
---|
398 | n/a | try: |
---|
399 | n/a | names = os.listdir(self.path) |
---|
400 | n/a | except OSError: |
---|
401 | n/a | return [] |
---|
402 | n/a | names.sort(key = os.path.normcase) |
---|
403 | n/a | sublist = [] |
---|
404 | n/a | for name in names: |
---|
405 | n/a | item = FileTreeItem(os.path.join(self.path, name)) |
---|
406 | n/a | sublist.append(item) |
---|
407 | n/a | return sublist |
---|
408 | n/a | |
---|
409 | n/a | |
---|
410 | n/a | # A canvas widget with scroll bars and some useful bindings |
---|
411 | n/a | |
---|
412 | n/a | class ScrolledCanvas: |
---|
413 | n/a | def __init__(self, master, **opts): |
---|
414 | n/a | if 'yscrollincrement' not in opts: |
---|
415 | n/a | opts['yscrollincrement'] = 17 |
---|
416 | n/a | self.master = master |
---|
417 | n/a | self.frame = Frame(master) |
---|
418 | n/a | self.frame.rowconfigure(0, weight=1) |
---|
419 | n/a | self.frame.columnconfigure(0, weight=1) |
---|
420 | n/a | self.canvas = Canvas(self.frame, **opts) |
---|
421 | n/a | self.canvas.grid(row=0, column=0, sticky="nsew") |
---|
422 | n/a | self.vbar = Scrollbar(self.frame, name="vbar") |
---|
423 | n/a | self.vbar.grid(row=0, column=1, sticky="nse") |
---|
424 | n/a | self.hbar = Scrollbar(self.frame, name="hbar", orient="horizontal") |
---|
425 | n/a | self.hbar.grid(row=1, column=0, sticky="ews") |
---|
426 | n/a | self.canvas['yscrollcommand'] = self.vbar.set |
---|
427 | n/a | self.vbar['command'] = self.canvas.yview |
---|
428 | n/a | self.canvas['xscrollcommand'] = self.hbar.set |
---|
429 | n/a | self.hbar['command'] = self.canvas.xview |
---|
430 | n/a | self.canvas.bind("<Key-Prior>", self.page_up) |
---|
431 | n/a | self.canvas.bind("<Key-Next>", self.page_down) |
---|
432 | n/a | self.canvas.bind("<Key-Up>", self.unit_up) |
---|
433 | n/a | self.canvas.bind("<Key-Down>", self.unit_down) |
---|
434 | n/a | #if isinstance(master, Toplevel) or isinstance(master, Tk): |
---|
435 | n/a | self.canvas.bind("<Alt-Key-2>", self.zoom_height) |
---|
436 | n/a | self.canvas.focus_set() |
---|
437 | n/a | def page_up(self, event): |
---|
438 | n/a | self.canvas.yview_scroll(-1, "page") |
---|
439 | n/a | return "break" |
---|
440 | n/a | def page_down(self, event): |
---|
441 | n/a | self.canvas.yview_scroll(1, "page") |
---|
442 | n/a | return "break" |
---|
443 | n/a | def unit_up(self, event): |
---|
444 | n/a | self.canvas.yview_scroll(-1, "unit") |
---|
445 | n/a | return "break" |
---|
446 | n/a | def unit_down(self, event): |
---|
447 | n/a | self.canvas.yview_scroll(1, "unit") |
---|
448 | n/a | return "break" |
---|
449 | n/a | def zoom_height(self, event): |
---|
450 | n/a | zoomheight.zoom_height(self.master) |
---|
451 | n/a | return "break" |
---|
452 | n/a | |
---|
453 | n/a | |
---|
454 | n/a | def _tree_widget(parent): # htest # |
---|
455 | n/a | top = Toplevel(parent) |
---|
456 | n/a | x, y = map(int, parent.geometry().split('+')[1:]) |
---|
457 | n/a | top.geometry("+%d+%d" % (x+50, y+175)) |
---|
458 | n/a | sc = ScrolledCanvas(top, bg="white", highlightthickness=0, takefocus=1) |
---|
459 | n/a | sc.frame.pack(expand=1, fill="both", side=LEFT) |
---|
460 | n/a | item = FileTreeItem(ICONDIR) |
---|
461 | n/a | node = TreeNode(sc.canvas, None, item) |
---|
462 | n/a | node.expand() |
---|
463 | n/a | |
---|
464 | n/a | if __name__ == '__main__': |
---|
465 | n/a | # test_tree is currently a copy of this |
---|
466 | n/a | from idlelib.idle_test.htest import run |
---|
467 | n/a | run(_tree_widget) |
---|