8 class ChooserGui(object):
9 def __init__(self, screen):
10 #self.m_screen = screen
11 helptext = """This dialog shows all installed plugins for the grml-terminalserver.
12 Just activate them as needed and proceed with <Run>!"""
13 self.m_grid = snack.GridForm(screen, 'Grmlterminalserver Config', 1, 8)
15 self.m_text = snack.TextboxReflowed(40, helptext)
16 self.m_grid.add(self.m_text, 0, 0, (0, 0, 0, 1))
18 self.m_plugins = snack.CheckboxTree(15)
19 self.m_grid.add(self.m_plugins, 0, 2, (0, 0, 0, 1), growx=1)
21 self.m_bb = snack.ButtonBar(screen, ((' Run ', 'run'), ('Quit', 'quit')))
22 self.m_grid.add(self.m_bb, 0, 4)
25 result = self.m_grid.runOnce()
26 if(type(result) == types.StringType and result == 'F12'):
29 return self.m_bb.buttonPressed(result)
32 return self.m_plugins.getSelection()
34 def addPlugin(self, name, pluginid):
35 self.m_plugins.append(name, pluginid)
38 dir = os.path.expanduser(dir.rstrip('\n'))
40 files = os.listdir(dir)
42 print 'Error: no such file or directory, using current directory'
43 files = os.listdir('.')
44 dir = os.path.abspath(dir)
45 files = ( f for f in files if os.path.isfile(os.path.join(dir, f)) )
47 screen = snack.SnackScreen()
48 gui = ChooserGui(screen)
53 print 'ret =', result, 'selections =', gui.getPlugins()
56 if __name__ == '__main__':
58 while result != 'quit':
59 print 'please input a directory: '
60 dir = sys.stdin.readline()