Changeset 4498 for trunk/GSASIIIO.py
- Timestamp:
- Jun 18, 2020 9:32:02 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIIO.py
r4492 r4498 46 46 import sys 47 47 import re 48 import glob49 48 import random as ran 50 49 import GSASIIpath … … 61 60 except ImportError: 62 61 pass 63 import GSASIIimage as G2img64 62 import GSASIIElem as G2el 65 63 import GSASIIstrIO as G2stIO … … 1008 1006 wx.EndBusyCursor() 1009 1007 print ('index peak list saved') 1010 1011 class MultipleChoicesDialog(wx.Dialog): 1012 '''A dialog that offers a series of choices, each with a 1013 title and a wx.Choice widget. Intended to be used Modally. 1014 typical input: 1015 1016 * choicelist=[ ('a','b','c'), ('test1','test2'),('no choice',)] 1017 * headinglist = [ 'select a, b or c', 'select 1 of 2', 'No option here'] 1018 1019 selections are placed in self.chosen when OK is pressed 1020 1021 Also see GSASIIctrlGUI 1022 ''' 1023 def __init__(self,choicelist,headinglist, 1024 head='Select options', 1025 title='Please select from options below', 1026 parent=None): 1027 self.chosen = [] 1028 wx.Dialog.__init__( 1029 self,parent,wx.ID_ANY,head, 1030 pos=wx.DefaultPosition,style=wx.DEFAULT_DIALOG_STYLE) 1031 panel = wx.Panel(self) 1032 mainSizer = wx.BoxSizer(wx.VERTICAL) 1033 mainSizer.Add((10,10),1) 1034 topLabl = wx.StaticText(panel,wx.ID_ANY,title) 1035 mainSizer.Add(topLabl,0,wx.ALIGN_CENTER_VERTICAL|wx.CENTER,10) 1036 self.ChItems = [] 1037 for choice,lbl in zip(choicelist,headinglist): 1038 mainSizer.Add((10,10),1) 1039 self.chosen.append(0) 1040 topLabl = wx.StaticText(panel,wx.ID_ANY,' '+lbl) 1041 mainSizer.Add(topLabl,0,wx.ALIGN_LEFT,10) 1042 self.ChItems.append(wx.Choice(self, wx.ID_ANY, (100, 50), choices = choice)) 1043 mainSizer.Add(self.ChItems[-1],0,wx.ALIGN_CENTER,10) 1044 1045 OkBtn = wx.Button(panel,-1,"Ok") 1046 OkBtn.Bind(wx.EVT_BUTTON, self.OnOk) 1047 cancelBtn = wx.Button(panel,-1,"Cancel") 1048 cancelBtn.Bind(wx.EVT_BUTTON, self.OnCancel) 1049 btnSizer = wx.BoxSizer(wx.HORIZONTAL) 1050 btnSizer.Add((20,20),1) 1051 btnSizer.Add(OkBtn) 1052 btnSizer.Add((20,20),1) 1053 btnSizer.Add(cancelBtn) 1054 btnSizer.Add((20,20),1) 1055 mainSizer.Add(btnSizer,0,wx.EXPAND|wx.BOTTOM|wx.TOP, 10) 1056 panel.SetSizer(mainSizer) 1057 panel.Fit() 1058 self.Fit() 1059 1060 def OnOk(self,event): 1061 parent = self.GetParent() 1062 if parent is not None: parent.Raise() 1063 # save the results from the choice widgets 1064 self.chosen = [] 1065 for w in self.ChItems: 1066 self.chosen.append(w.GetSelection()) 1067 self.EndModal(wx.ID_OK) 1068 1069 def OnCancel(self,event): 1070 parent = self.GetParent() 1071 if parent is not None: parent.Raise() 1072 self.chosen = [] 1073 self.EndModal(wx.ID_CANCEL) 1074 1008 1075 1009 def ExtractFileFromZip(filename, selection=None, confirmread=True, 1076 1010 confirmoverwrite=True, parent=None, … … 1690 1624 1691 1625 ''' 1692 pth = G2G.GetExportPath(self.G2frame)1626 #pth = G2G.GetExportPath(self.G2frame) 1693 1627 if self.G2frame.GSASprojectfile: 1694 1628 defnam = os.path.splitext(
Note: See TracChangeset
for help on using the changeset viewer.