Mercurial > cpython-lru_cache-weakref
annotate Lib/stdwin/DirList.py @ 5817:48b94de85bf3 legacy-trunk
Extensive changes by AMK.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Thu, 17 Jul 1997 16:29:42 +0000 |
| parents | f9bbb01388d5 |
| children |
| rev | line source |
|---|---|
| 195 | 1 # DirList -- Directory Listing widget |
| 2 | |
|
347
daabe232062e
Renamed path.cat to path.join
Guido van Rossum <guido@python.org>
parents:
195
diff
changeset
|
3 # XXX Displays messy paths when following '..' |
|
daabe232062e
Renamed path.cat to path.join
Guido van Rossum <guido@python.org>
parents:
195
diff
changeset
|
4 |
| 780 | 5 import os |
| 195 | 6 import stdwin, rect |
| 7 from stdwinevents import * | |
| 8 from Buttons import PushButton | |
| 9 from WindowParent import WindowParent | |
| 10 from HVSplit import HSplit, VSplit | |
| 11 | |
|
519
048e1371c450
Use ImportError; New class syntax.
Guido van Rossum <guido@python.org>
parents:
347
diff
changeset
|
12 class DirList(VSplit): |
| 195 | 13 # |
|
1110
1d06b1499eb9
* Got entirely rid of path.py.
Guido van Rossum <guido@python.org>
parents:
780
diff
changeset
|
14 def create(self, parent, dirname): |
| 195 | 15 self = VSplit.create(self, parent) |
| 16 names = os.listdir(dirname) | |
| 17 for name in names: | |
| 780 | 18 if os.path.isdir(os.path.join(dirname, name)): |
| 19 fullname = os.path.join(dirname, name) | |
| 195 | 20 btn = SubdirButton().definetext(self, fullname) |
| 559 | 21 elif name[-3:] == '.py': |
| 195 | 22 btn = ModuleButton().definetext(self, name) |
| 23 else: | |
| 24 btn = FileButton().definetext(self, name) | |
| 25 return self | |
| 26 # | |
| 27 | |
|
519
048e1371c450
Use ImportError; New class syntax.
Guido van Rossum <guido@python.org>
parents:
347
diff
changeset
|
28 class DirListWindow(WindowParent): |
| 195 | 29 # |
| 30 def create(self, dirname): | |
|
1178
f9bbb01388d5
* More changes due to stricter argument passing rules
Guido van Rossum <guido@python.org>
parents:
1110
diff
changeset
|
31 self = WindowParent.create(self, dirname, (0, 0)) |
| 195 | 32 child = DirList().create(self, dirname) |
| 33 self.realize() | |
| 34 return self | |
| 35 # | |
| 36 | |
|
519
048e1371c450
Use ImportError; New class syntax.
Guido van Rossum <guido@python.org>
parents:
347
diff
changeset
|
37 class SubdirButton(PushButton): |
| 195 | 38 # |
| 39 def drawpict(self, d): | |
| 40 PushButton.drawpict(self, d) | |
| 41 d.box(rect.inset(self.bounds, (3, 1))) | |
| 42 # | |
| 43 def up_trigger(self): | |
| 44 window = DirListWindow().create(self.text) | |
| 45 # | |
| 46 | |
|
519
048e1371c450
Use ImportError; New class syntax.
Guido van Rossum <guido@python.org>
parents:
347
diff
changeset
|
47 class FileButton(PushButton): |
| 195 | 48 # |
| 49 def up_trigger(self): | |
| 50 stdwin.fleep() | |
| 51 # | |
| 52 | |
|
519
048e1371c450
Use ImportError; New class syntax.
Guido van Rossum <guido@python.org>
parents:
347
diff
changeset
|
53 class ModuleButton(FileButton): |
| 195 | 54 # |
| 55 def drawpict(self, d): | |
| 56 PushButton.drawpict(self, d) | |
| 57 d.box(rect.inset(self.bounds, (1, 3))) | |
| 58 # |
