1 # Create hierarchical menus for some volumes.
12 fss
, ok
= macfs
.GetDirectory()
15 my_volumes
.append(fss
.as_pathname())
20 makevolmenus(my_volumes
)
34 def makevolmenus(volumes
):
39 menu
= NewMenu(nextid(), vol
)
40 adddirectory(menu
, vol
)
43 def adddirectory(menu
, dir, maxdepth
= 1):
44 print "adddirectory:", `
dir`
, maxdepth
45 files
= os
.listdir(dir)
49 menu
.AppendMenu('x') # add a dummy string
50 menu
.SetMenuItemText(item
, file) # set the actual text
51 fullname
= os
.path
.join(dir, file)
52 if os
.path
.isdir(fullname
):
53 menu
.SetMenuItemText(item
, ':' + file + ':') # append colons
56 submenu
= NewMenu(id, fullname
)
57 adddirectory(submenu
, fullname
, maxdepth
-1)
58 submenu
.InsertMenu(-1)
59 # If the 'Cmd' is 0x1B, then the 'Mark' is the submenu id
60 menu
.SetItemMark(item
, id)
61 menu
.SetItemCmd(item
, 0x1B)
63 menu
.AppendMenu(':') # dummy item to make it selectable
66 if __name__
== '__main__':
68 sys
.exit(1) # To allow the user to interact...