Changeset 1138 for trunk/GSASIIgrid.py
- Timestamp:
- Nov 7, 2013 12:12:55 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIgrid.py
r1128 r1138 118 118 119 119 [ wxID_CONSTRAINTADD,wxID_EQUIVADD,wxID_HOLDADD,wxID_FUNCTADD, 120 ] = [wx.NewId() for item in range(4)] 120 wxID_CONSPHASE, wxID_CONSHIST, wxID_CONSHAP, wxID_CONSGLOBAL, 121 ] = [wx.NewId() for item in range(8)] 121 122 122 123 [ wxID_RESTRAINTADD, wxID_RESTSELPHASE,wxID_RESTDELETE, wxID_RESRCHANGEVAL, … … 279 280 else: 280 281 self.invalid = False 282 self.Bind(wx.EVT_CHAR,self._GetStringValue) 281 283 elif val is None: 282 284 raise Exception,("ValidatedTxtCtrl error: value of "+str(key)+ … … 360 362 elif self.OKcontrol and previousInvalid: 361 363 self.OKcontrol(True) 364 # always store the result 365 if self.CIFinput: # for CIF make results ASCII 366 self.result[self.key] = val.encode('ascii','replace') 367 else: 368 self.result[self.key] = val 369 370 def _GetStringValue(self,event): 371 '''Get string input and store. 372 ''' 373 event.Skip() # process keystroke 374 wx.CallAfter(self._SaveStringValue) 375 376 def _SaveStringValue(self): 377 val = self.GetValue().strip() 362 378 # always store the result 363 379 if self.CIFinput: # for CIF make results ASCII … … 1321 1337 :param str header: Title to place on window frame 1322 1338 :param list ChoiceList: a list of choices where one will be selected 1339 :param bool toggle: If True (default) the toggle and select all buttons 1340 are displayed 1323 1341 1324 1342 :param kw: optional keyword parameters for the wx.Dialog may 1325 be included such as Size [which defaults to `(320,310)`] and1326 Style (which defaults to `wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER|wx.CENTRE| wx.OK | wx.CANCEL`);1343 be included such as size [which defaults to `(320,310)`] and 1344 style (which defaults to `wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER|wx.CENTRE| wx.OK | wx.CANCEL`); 1327 1345 note that `wx.OK` and `wx.CANCEL` controls 1328 1346 the presence of the eponymous buttons in the dialog. 1329 1347 :returns: the name of the created dialog 1330 1348 ''' 1331 def __init__(self,parent, title, header, ChoiceList, **kw):1349 def __init__(self,parent, title, header, ChoiceList, toggle=True, **kw): 1332 1350 # process keyword parameters, notably Style 1333 1351 options = {'size':(320,310), # default Frame keywords … … 1355 1373 Sizer.Add((-1,10)) 1356 1374 # set/toggle buttons 1357 bSizer = wx.BoxSizer(wx.VERTICAL) 1358 setBut = wx.Button(self,wx.ID_ANY,'Set All') 1359 setBut.Bind(wx.EVT_BUTTON,self._SetAll) 1360 bSizer.Add(setBut,0,wx.ALIGN_CENTER) 1361 bSizer.Add((-1,5)) 1362 togBut = wx.Button(self,wx.ID_ANY,'Toggle All') 1363 togBut.Bind(wx.EVT_BUTTON,self._ToggleAll) 1364 bSizer.Add(togBut,0,wx.ALIGN_CENTER) 1365 Sizer.Add(bSizer,0,wx.LEFT,12) 1375 if toggle: 1376 bSizer = wx.BoxSizer(wx.VERTICAL) 1377 setBut = wx.Button(self,wx.ID_ANY,'Set All') 1378 setBut.Bind(wx.EVT_BUTTON,self._SetAll) 1379 bSizer.Add(setBut,0,wx.ALIGN_CENTER) 1380 bSizer.Add((-1,5)) 1381 togBut = wx.Button(self,wx.ID_ANY,'Toggle All') 1382 togBut.Bind(wx.EVT_BUTTON,self._ToggleAll) 1383 bSizer.Add(togBut,0,wx.ALIGN_CENTER) 1384 Sizer.Add(bSizer,0,wx.LEFT,12) 1366 1385 # OK/Cancel buttons 1367 1386 btnsizer = wx.StdDialogButtonSizer() … … 1852 1871 1853 1872 ################################################################################ 1873 class HelpButton(wx.Button): 1874 '''Create a help button that displays help information. 1875 The text is displayed in a modal message window. 1876 1877 TODO: it might be nice if it were non-modal: e.g. it stays around until 1878 the parent is deleted or the user closes it, but this did not work for 1879 me. 1880 1881 :param parent: the panel which will be the parent of the button 1882 :param str msg: the help text to be displayed 1883 ''' 1884 def __init__(self,parent,msg): 1885 if sys.platform == "darwin": 1886 wx.Button.__init__(self,parent,wx.ID_HELP) 1887 else: 1888 wx.Button.__init__(self,parent,wx.ID_ANY,'?',style=wx.BU_EXACTFIT) 1889 self.Bind(wx.EVT_BUTTON,self._onPress) 1890 self.msg=msg 1891 self.parent = parent 1892 def _onPress(self,event): 1893 'Respond to a button press by displaying the requested text' 1894 dlg = wx.MessageDialog(self.parent,self.msg,'Help info',wx.OK) 1895 dlg.ShowModal() 1896 dlg.Destroy() 1897 ################################################################################ 1854 1898 class MyHtmlPanel(wx.Panel): 1855 1899 '''Defines a panel to display HTML help information, as an alternative to … … 1988 2032 self.ConstraintMenu = wx.MenuBar() 1989 2033 self.PrefillDataMenu(self.ConstraintMenu,helpType='Constraints') 2034 self.ConstraintTab = wx.Menu(title='') 2035 self.ConstraintMenu.Append(menu=self.ConstraintTab, title='Select tab') 2036 for id,txt in ( 2037 (wxID_CONSPHASE,'Phase'), 2038 (wxID_CONSHAP,'Histogram/Phase'), 2039 (wxID_CONSHIST,'Histogram'), 2040 (wxID_CONSGLOBAL,'Global')): 2041 self.ConstraintTab.Append( 2042 id=id, kind=wx.ITEM_NORMAL,text=txt, 2043 help='Select '+txt+' constraint editing tab') 1990 2044 self.ConstraintEdit = wx.Menu(title='') 1991 2045 self.ConstraintMenu.Append(menu=self.ConstraintEdit, title='Edit') … … 1998 2052 self.ConstraintEdit.Append(id=wxID_FUNCTADD, kind=wx.ITEM_NORMAL,text='Add New Var', 1999 2053 help='Add variable composed of existing parameter') 2054 2055 # item = self.ConstraintEdit.Append(id=wx.ID_ANY,kind=wx.ITEM_NORMAL,text='Update GUI') 2056 # def UpdateGSASIIconstrGUI(event): 2057 # import GSASIIconstrGUI 2058 # reload(GSASIIconstrGUI) 2059 # import GSASIIobj 2060 # reload(GSASIIobj) 2061 # self.Bind(wx.EVT_MENU,UpdateGSASIIconstrGUI,id=item.GetId()) 2062 2000 2063 self.PostfillDataMenu() 2001 2064
Note: See TracChangeset
for help on using the changeset viewer.