Package chianti :: Package Gui :: Package gui_cl :: Module gui
[hide private]
[frames] | no frames]

Source Code for Module chianti.Gui.gui_cl.gui

 1  ''' 
 2  Command line selection dialogs. 
 3  ''' 
 4  import os 
 5  import fnmatch 
 6   
 7  'command-line selection dialogs' 
 8   
 9   
10 -def chpicker(path, filter='*.*', label=None):
11 '''Select a filename from using a command line dialog. 12 13 the label keyword is included for consistency but does nothing''' 14 if not os.path.isdir(path): 15 path=os.curdir 16 # if type(pattern) == NoneType: 17 # pattern="All files (*.*)" 18 allNames=os.listdir(path) 19 names = fnmatch.filter(allNames, filter) 20 print(' - make a selection from one of these - ') 21 for i, one in enumerate(names): 22 print('%6i %s '%(i, one)) 23 raw = input(' type the index of your selection >>. ') 24 fileName = os.path.join(path, names[int(raw)]) 25 return fileName
26 27 28 # 29 #
30 -class selectorDialog:
31 '''Make a single or multiple selection from a list of items. 32 33 expects the input of an array of items, will select one or more 34 the label and parent keywords are for consistency with other modules but do nothing'''
35 - def __init__(self, items, label=None , parent=None):
36 # 37 print(' - make a selection from these - ') 38 for i, one in enumerate(items): 39 print('%6i %s '%( i, one)) 40 print(' type the comma-separated index/indices of your selection') 41 raw = input('>>> ') 42 # 43 sraw = list(raw.split(',')) 44 self.selectedIndex = [] 45 self.selectedText = [] 46 for one in sraw: 47 self.selectedIndex.append(int(one)) 48 self.selectedText.append(items[int(one)])
49 #
50 -class choice2Dialog:
51 '''Make a single or multiplee selection from a list of items and another 52 single or multiple selection from the same list. 53 54 Useful for picking numerators and denominators. 55 56 expects the input of an array of items, will select one or more from both widgets 57 the keywords label and parent are there for consistency with real gui dialogs'''
58 - def __init__(self, items, label=None , parent=None):
59 # 60 print(' - select the numerator line(s) from these - ') 61 for i, one in enumerate(items): 62 print('%6i %s ' %( i, one)) 63 print(' type the comma-separated index/indices of your selection') 64 raw = input('>>> ') 65 # 66 sraw = list(raw.split(',')) 67 self.numIndex = [] 68 self.numText = [] 69 for one in sraw: 70 self.numIndex.append(int(one)) 71 self.numText.append(items[int(one)]) 72 # 73 print(' - select the denominator line(s) from these - ') 74 for i, one in enumerate(items): 75 print('%6i %s ' %( i, one)) 76 print(' type the comma-separated index/indices of your selection') 77 raw = input('>>> ') 78 # 79 sraw = list(raw.split(',')) 80 self.denIndex = [] 81 self.denText = [] 82 for one in sraw: 83 self.denIndex.append(int(one)) 84 self.denText.append(items[int(one)])
85