1 '''
2 wxWidget selection dialogs.
3 '''
4
5 ' wxWidget selection dialogs'
6
7 import wx
8 from chianti.Gui.gui_wx.ui import *
9
10 -def chpicker(dir,filter='All files (*.*)|*.*',label='ChiantiPy'):
11 '''Select a filename using a gui dialog.'''
12 app=wx.App()
13 a=wx.FileDialog(None)
14 a.SetMessage(label)
15 a.SetWildcard(filter)
16 a.SetDirectory(dir)
17 a.ShowModal()
18 a.name = a.GetFilename()
19 a.Destroy()
20 return a.name
21
23 '''Make a single or multiple selection from a list of items.
24
25 expects the input of an array of items, will select one or more
26 '''
27 - def __init__(self, items,label='Your list',title='Select One'):
28 a = wx.App()
29 a = wx.MultiChoiceDialog(None,label,title,items)
30 a.ShowModal()
31 self.selectedIndex = a.GetSelections()
32 selectedItems=[]
33 for one in self.selectedIndex:
34 selectedItems.append(items[one])
35 self.selectedItems = selectedItems
36 a.Destroy
37
39 '''Make a single or multiplee selection from a list of items and another
40 single or multiple selection from the same list.
41
42 Useful for picking numerators and denominators.
43
44 expects the input of an array of items, will select one or more from both widgets.'''
46
47 app = wx.App()
48 dlg = ui_choice2Dialog(None, -1, "")
49 nItems = len(items)
50 for i in range(nItems):
51 dlg.numListBox.Insert(str(items[i]),i)
52 dlg.denListBox.Insert(str(items[i]),i)
53
54 app.SetTopWindow(dlg)
55 if dlg.ShowModal() == wx.ID_OK:
56 self.numIndex = dlg.numListBox.GetSelections()
57
58 self.denIndex = dlg.denListBox.GetSelections()
59 self.numText = []
60 self.denText = []
61 for one in self.numIndex:
62
63
64 self.numText.append(items[one])
65 for one in self.denIndex:
66
67 self.denText.append(items[one])
68 dlg.Destroy()
69