annotate CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/lib/python3.8/idlelib/tree.py @ 68:5028fdace37b

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