Guido van Rossum | c636014 | 1990-10-13 19:23:40 +0000 | [diff] [blame] | 1 | # Module 'dirwin' |
| 2 | |
| 3 | # Directory windows, a subclass of listwin |
| 4 | |
| 5 | import gwin |
| 6 | import listwin |
| 7 | import anywin |
| 8 | import path |
| 9 | import dircache |
| 10 | |
| 11 | def action(w, string, i, detail): |
| 12 | (h, v), clicks, button, mask = detail |
| 13 | if clicks = 2: |
| 14 | name = path.cat(w.name, string) |
| 15 | try: |
Guido van Rossum | 2dbf39c | 1990-10-21 16:15:58 +0000 | [diff] [blame] | 16 | w2 = anywin.open(name) |
| 17 | w2.parent = w |
Guido van Rossum | c636014 | 1990-10-13 19:23:40 +0000 | [diff] [blame] | 18 | except posix.error, why: |
| 19 | stdwin.message('Can\'t open ' + name + ': ' + why[1]) |
| 20 | |
| 21 | def open(name): |
| 22 | name = path.cat(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 |