0
0
mirror of https://github.com/python/cpython.git synced 2024-11-25 01:20:47 +01:00
cpython/Lib/lib-stdwin/DirList.py
Guido van Rossum 89a78697b8 * Got entirely rid of path.py.
* Many modules: fixes for new, stricter, argument passing rules
  (most changes were automatic ones -- not all of this is tested!).
* gwin.py: now uses mainloop.py for its main loop and window admin.
* mainloop.py: always call dispatch() with event as a tuple!
* Fix bug in pdb's 'clear' command -- don't set the bpt but clear it!
1992-12-14 12:57:56 +00:00

59 lines
1.3 KiB
Python

# DirList -- Directory Listing widget
# XXX Displays messy paths when following '..'
import os
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 os.path.isdir(os.path.join(dirname, name)):
fullname = os.path.join(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)))
#