home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / pytho152.zip / emx / lib / python1.5 / lib-stdwin / dirwin.py < prev    next >
Text File  |  2000-08-10  |  590b  |  30 lines

  1. # Module 'dirwin'
  2.  
  3. # Directory windows, a subclass of listwin
  4.  
  5. import os
  6. import gwin
  7. import listwin
  8. import anywin
  9. import dircache
  10.  
  11. def action(w, string, i, detail):
  12.     (h, v), clicks, button, mask = detail
  13.     if clicks == 2:
  14.         name = os.path.join(w.name, string)
  15.         try:
  16.             w2 = anywin.open(name)
  17.             w2.parent = w
  18.         except os.error, why:
  19.             stdwin.message('Can\'t open ' + name + ': ' + why[1])
  20.  
  21. def open(name):
  22.     name = os.path.join(name, '')
  23.     list = dircache.opendir(name)[:]
  24.     list.sort()
  25.     dircache.annotate(name, list)
  26.     w = listwin.open(name, list)
  27.     w.name = name
  28.     w.action = action
  29.     return w
  30.