Changeset 4819 for trunk/GSASIIctrlGUI.py
- Timestamp:
- Feb 17, 2021 12:52:34 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIctrlGUI.py
r4811 r4819 183 183 pass 184 184 185 ################################################################################ 186 #### Fixed definitions for wx Ids 187 ################################################################################ 185 #### Fixed definitions for wx Ids ################################################################################ 188 186 def Define_wxId(*args): 189 187 '''routine to create unique global wx Id symbols in this module. … … 197 195 exec('global '+arg+';'+arg+' = wx.NewId()') 198 196 199 ################################################################################ 200 #### Tree Control 201 ################################################################################ 197 #### Tree Control ################################################################################ 202 198 class G2TreeCtrl(wx.TreeCtrl): 203 199 '''Create a wrapper around the standard TreeCtrl so we can "wrap" … … 415 411 item, cookie = self.GetNextChild(self.root, cookie) 416 412 417 ################################################################################ 418 #### TextCtrl that stores input as entered with optional validation 419 ################################################################################ 413 #### TextCtrl that stores input as entered with optional validation ################################################################################ 420 414 class ValidatedTxtCtrl(wx.TextCtrl): 421 415 '''Create a TextCtrl widget that uses a validator to prevent the … … 1275 1269 if num >= 0: self.SetSelection(num) 1276 1270 1277 ############################################################## 1278 # Custom checkbox that saves values into dict/list as used 1271 #### Custom checkbox that saves values into dict/list as used ############################################################## 1279 1272 class G2CheckBox(wx.CheckBox): 1280 1273 '''A customized version of a CheckBox that automatically initializes … … 1308 1301 if self.OnChange: self.OnChange(event) 1309 1302 1310 ################################################################################ 1311 #### Commonly used dialogs 1312 ################################################################################ 1303 #### Commonly used dialogs ################################################################################ 1313 1304 def CallScrolledMultiEditor(parent,dictlst,elemlst,prelbl=[],postlbl=[], 1314 1305 title='Edit items',header='',size=(300,250), … … 1324 1315 title,header,size, 1325 1316 CopyButton, ASCIIonly, **kw) 1317 dlg.CenterOnParent() 1326 1318 if dlg.ShowModal() == wx.ID_OK: 1327 1319 dlg.Destroy() … … 1349 1341 :param tuple dictlst: a list of dicts or lists containing values to edit 1350 1342 1351 :param tuple elemlst: a list of keys for each item in a dictlst. Must have the1352 same length as dictlst.1353 1354 :param wx.Frame parent: name of parent window, or may be None1355 1343 :param tuple elemlst: a list of keys/indices for items in dictlst. 1344 Note that elemlst must have the same length as dictlst, where each 1345 item in elemlst will will match an entry for an entry for successive 1346 dicts/lists in dictlst. 1347 1356 1348 :param tuple prelbl: a list of labels placed before the TextCtrl for each 1357 1349 item (optional) … … 1561 1553 ############################################### Multichoice Dialog with set all, toggle & filter options 1562 1554 class G2MultiChoiceDialog(wx.Dialog): 1563 '''A dialog similar to MultiChoiceDialog except that buttons are 1564 added to set all choices and to toggle all choices. 1555 '''A dialog similar to wx.MultiChoiceDialog except that buttons are 1556 added to set all choices and to toggle all choices and a filter is 1557 available to select from available entries. Note that if multiple 1558 entries are placed in the filter box separated by spaces, all 1559 of the strings must be present for an item to be shown. 1565 1560 1566 1561 :param wx.Frame ParentFrame: reference to parent frame … … 1577 1572 options to present to the user, where value_i is the default value. 1578 1573 Options are listed ordered by the value_i values. 1574 :param list selected: list of indicies for items that should be 1579 1575 :param kw: optional keyword parameters for the wx.Dialog may 1580 1576 be included such as size [which defaults to `(320,310)`] and … … 1585 1581 ''' 1586 1582 def __init__(self,parent, title, header, ChoiceList, toggle=True, 1587 monoFont=False, filterBox=True, extraOpts={}, **kw): 1583 monoFont=False, filterBox=True, extraOpts={}, selected=[], 1584 **kw): 1588 1585 # process keyword parameters, notably style 1589 1586 options = {'size':(320,310), # default Frame keywords … … 1593 1590 self.ChoiceList = ['%4d) %s'%(i,item) for i,item in enumerate(ChoiceList)] # numbered list of choices (list of str values) 1594 1591 self.Selections = len(self.ChoiceList) * [False,] # selection status for each choice (list of bools) 1592 for i in selected: 1593 self.Selections[i] = True 1595 1594 self.filterlist = range(len(self.ChoiceList)) # list of the choice numbers that have been filtered (list of int indices) 1596 1595 self.Stride = 1 … … 1624 1623 self.rangeFirst = None 1625 1624 self.clb = wx.CheckListBox(self, wx.ID_ANY, (30,30), wx.DefaultSize, self.ChoiceList) 1625 self._ShowSelections() 1626 1626 self.clb.Bind(wx.EVT_CHECKLISTBOX,self.OnCheck) 1627 1627 if monoFont: … … 1795 1795 self.GetSelections() # record current selections 1796 1796 txt = self.filterBox.GetValue() 1797 txt = txt.lower() 1797 1798 self.clb.Clear() 1798 1799 … … 1800 1801 self.filterlist = [] 1801 1802 if txt: 1802 txt = txt.lower()1803 1803 ChoiceList = [] 1804 1804 for i,item in enumerate(self.ChoiceList): 1805 if item.lower().find(txt) != -1: 1805 for t in txt.split(): 1806 if item.lower().find(t) == -1: 1807 break 1808 else: 1806 1809 ChoiceList.append(item) 1807 1810 self.filterlist.append(i) … … 2205 2208 dlg.Destroy() 2206 2209 2207 ############################################################### 2208 # Single choice Dialog with filter options 2210 ##### Single choice Dialog with filter options ############################################################### 2209 2211 class G2SingleChoiceDialog(wx.Dialog): 2210 2212 '''A dialog similar to wx.SingleChoiceDialog except that a filter can be … … 4448 4450 return None 4449 4451 4450 ################################################################################ 4451 ##### Customized Grid Support 4452 ################################################################################ 4452 ##### Customized Grid Support ################################################################################ 4453 4453 class GSGrid(wg.Grid): 4454 4454 '''Basic wx.Grid implementation … … 4773 4773 evt.StopPropagation() 4774 4774 4775 ################################################################################ 4776 ##### Get an output file or directory 4777 ################################################################################ 4775 ##### Get an output file or directory ################################################################################ 4778 4776 def askSaveFile(G2frame,defnam,extension,longFormatName,parent=None): 4779 4777 '''Ask the user to supply a file name … … 4829 4827 return filename 4830 4828 4831 ################################################################################ 4832 ##### Customized Notebook 4833 ################################################################################ 4829 ##### Customized Notebook ################################################################################ 4834 4830 class GSNoteBook(wx.aui.AuiNotebook): 4835 4831 '''Notebook used in various locations; implemented with wx.aui extension … … 4896 4892 # return attr 4897 4893 4898 ################################################################################ 4899 #### Help support routines 4900 ################################################################################ 4894 #### Help support routines ################################################################################ 4901 4895 class MyHelp(wx.Menu): 4902 4896 ''' … … 5387 5381 return s.encode('ascii','replace') 5388 5382 5389 ###################################################################### 5390 # wx classes for reading various types of data files 5391 ###################################################################### 5383 # wx classes for reading various types of data files ###################################################################### 5392 5384 def BlockSelector(ChoiceList, ParentFrame=None,title='Select a block', 5393 5385 size=None, header='Block Selector',useCancel=True): … … 6001 5993 6002 5994 ################################################################################ 6003 ################################################################################6004 5995 class SortableLstCtrl(wx.Panel): 6005 5996 '''Creates a read-only table with sortable columns. Sorting is done by … … 6119 6110 print('docs build kludge for G2LstCtrl') 6120 6111 6121 ################################################################################ 6122 #### Display Help information 6123 ################################################################################ 6112 #### Display Help information ################################################################################ 6124 6113 # define some globals 6125 6114 htmlPanel = None … … 6221 6210 webbrowser.open(pfx+URL, new=0, autoraise=True) 6222 6211 6223 ################################################################################ 6224 #### Tutorials support 6225 ################################################################################ 6212 #### Tutorials support ################################################################################ 6226 6213 G2BaseURL = "https://subversion.xray.aps.anl.gov/pyGSAS" 6227 6214 tutorialIndex = ( … … 6761 6748 except KeyError: 6762 6749 pass 6763 ################################################################################ 6764 # Autoload PWDR files 6765 ################################################################################ 6750 6751 ### Autoload PWDR files ################################################################################ 6766 6752 AutoLoadWindow = None 6767 6753 … … 7169 7155 AutoLoadWindow = dlg # save window reference 7170 7156 7171 ################################################################################ 7172 # Deal with Origin 1/2 ambiguities 7173 ################################################################################ 7157 # Deal with Origin 1/2 ambiguities ################################################################################ 7174 7158 def ChooseOrigin(G2frame,rd): 7175 7159 # make copy of Phase but shift atoms Origin 1->2
Note: See TracChangeset
for help on using the changeset viewer.