summaryrefslogtreecommitdiffstats
path: root/Lib/stdwin/DirList.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1991-04-07 13:41:50 (GMT)
committerGuido van Rossum <guido@python.org>1991-04-07 13:41:50 (GMT)
commit2d844d1ddc581c80116c88be5854720bcf84f3e0 (patch)
tree7aaca4e789dd1394d8eff7484dfced08a635983f /Lib/stdwin/DirList.py
parentfa5406496750f9f0717457341041297b4173430f (diff)
downloadcpython-2d844d1ddc581c80116c88be5854720bcf84f3e0.zip
cpython-2d844d1ddc581c80116c88be5854720bcf84f3e0.tar.gz
cpython-2d844d1ddc581c80116c88be5854720bcf84f3e0.tar.bz2
Initial revision
Diffstat (limited to 'Lib/stdwin/DirList.py')
-rwxr-xr-xLib/stdwin/DirList.py63
1 files changed, 63 insertions, 0 deletions
diff --git a/Lib/stdwin/DirList.py b/Lib/stdwin/DirList.py
new file mode 100755
index 0000000..fb0ae99
--- /dev/null
+++ b/Lib/stdwin/DirList.py
@@ -0,0 +1,63 @@
+# DirList -- Directory Listing widget
+
+try:
+ import posix, path
+ os = posix
+except NameError:
+ import mac, macpath
+ os = mac
+ path = macpath
+
+import stdwin, rect
+from stdwinevents import *
+from Buttons import PushButton
+from WindowParent import WindowParent
+from HVSplit import HSplit, VSplit
+
+class DirList() = VSplit():
+ #
+ def create(self, (parent, dirname)):
+ self = VSplit.create(self, parent)
+ names = os.listdir(dirname)
+ for name in names:
+ if path.isdir(path.cat(dirname, name)):
+ fullname = path.cat(dirname, name)
+ btn = SubdirButton().definetext(self, fullname)
+ elif name[-3:] = '.py':
+ btn = ModuleButton().definetext(self, name)
+ else:
+ btn = FileButton().definetext(self, name)
+ return self
+ #
+
+class DirListWindow() = WindowParent():
+ #
+ def create(self, dirname):
+ self = WindowParent.create(self, (dirname, (0, 0)))
+ child = DirList().create(self, dirname)
+ self.realize()
+ return self
+ #
+
+class SubdirButton() = PushButton():
+ #
+ def drawpict(self, d):
+ PushButton.drawpict(self, d)
+ d.box(rect.inset(self.bounds, (3, 1)))
+ #
+ def up_trigger(self):
+ window = DirListWindow().create(self.text)
+ #
+
+class FileButton() = PushButton():
+ #
+ def up_trigger(self):
+ stdwin.fleep()
+ #
+
+class ModuleButton() = FileButton():
+ #
+ def drawpict(self, d):
+ PushButton.drawpict(self, d)
+ d.box(rect.inset(self.bounds, (1, 3)))
+ #