Changeset 4410 for trunk/GSASIIctrlGUI.py
- Timestamp:
- Apr 24, 2020 11:06:35 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIctrlGUI.py
r4388 r4410 88 88 :func:`askSaveFile` Get a file name from user 89 89 :func:`askSaveDirectory` Get a directory name from user 90 :func:`BlockSelector` Select a single block for instrument parameters 91 :func:`MultipleBlockSelector` Select one or more blocks of data, used for 92 CIF powder histogram imports only 93 :func:`MultipleChoicesSelector` Dialog for displaying fairly complex choices, used for 94 CIF powder histogram imports only 95 :func:`PhaseSelector` Select a phase from a list (used for phase importers) 96 90 97 ================================ ================================================================= 91 98 … … 1905 1912 dlg.Destroy() 1906 1913 1907 ################################################################ Single choice Dialog with filter options 1914 ############################################################### 1915 # Single choice Dialog with filter options 1908 1916 class G2SingleChoiceDialog(wx.Dialog): 1909 1917 '''A dialog similar to wx.SingleChoiceDialog except that a filter can be … … 2090 2098 self.EndModal(wx.ID_CANCEL) 2091 2099 2092 ################################################################### ,#############2100 ################################################################################ 2093 2101 def G2MessageBox(parent,msg,title='Error'): 2094 2102 '''Simple code to display a error or warning message … … 2831 2839 dlg.Destroy() 2832 2840 2833 ######################################################### Column-order selection dialog 2841 ######################################################## 2842 # Column-order selection dialog 2834 2843 def GetItemOrder(parent,keylist,vallookup,posdict): 2835 2844 '''Creates a dialog where items can be ordered into columns … … 4693 4702 return s.encode('ascii','replace') 4694 4703 4704 ###################################################################### 4705 # wx classes for reading various types of data files 4706 ###################################################################### 4707 def BlockSelector(ChoiceList, ParentFrame=None,title='Select a block', 4708 size=None, header='Block Selector',useCancel=True): 4709 ''' Provide a wx dialog to select a single block where one must 4710 be selected. Used for selecting for banks for instrument 4711 parameters if the file contains more than one set. 4712 ''' 4713 if useCancel: 4714 dlg = wx.SingleChoiceDialog( 4715 ParentFrame,title, header,ChoiceList) 4716 else: 4717 dlg = wx.SingleChoiceDialog( 4718 ParentFrame,title, header,ChoiceList, 4719 style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER|wx.OK|wx.CENTRE) 4720 if size: dlg.SetMinSize(size) 4721 dlg.CenterOnParent() 4722 dlg.SendSizeEvent() 4723 if dlg.ShowModal() == wx.ID_OK: 4724 sel = dlg.GetSelection() 4725 return sel 4726 else: 4727 return None 4728 dlg.Destroy() 4729 4730 def MultipleBlockSelector(ChoiceList, ParentFrame=None, 4731 title='Select a block',size=None, header='Block Selector'): 4732 '''Provide a wx dialog to select a block of data if the 4733 file contains more than one set of data and one must be 4734 selected. Used in :mod:`G2pwd_CIF` only. 4735 4736 :returns: a list of the selected blocks 4737 ''' 4738 dlg = wx.MultiChoiceDialog(ParentFrame,title, header,ChoiceList+['Select all'], 4739 wx.CHOICEDLG_STYLE) 4740 if size: dlg.SetMinSize(size) 4741 dlg.CenterOnScreen() 4742 dlg.SendSizeEvent() 4743 if dlg.ShowModal() == wx.ID_OK: 4744 sel = dlg.GetSelections() 4745 else: 4746 return [] 4747 dlg.Destroy() 4748 selected = [] 4749 if len(ChoiceList) in sel: 4750 return range(len(ChoiceList)) 4751 else: 4752 return sel 4753 return selected 4754 4755 def MultipleChoicesSelector(choicelist, headinglist, ParentFrame=None, **kwargs): 4756 '''A modal dialog that offers a series of choices, each with a title and a wx.Choice 4757 widget. Used in :mod:`G2pwd_CIF` only. 4758 4759 Typical input: 4760 4761 * choicelist=[ ('a','b','c'), ('test1','test2'),('no choice',)] 4762 4763 * headinglist = [ 'select a, b or c', 'select 1 of 2', 'No option here'] 4764 4765 optional keyword parameters are: head (window title) and title 4766 returns a list of selected indicies for each choice (or None) 4767 ''' 4768 result = None 4769 dlg = MultipleChoicesDialog(choicelist,headinglist, 4770 parent=ParentFrame, **kwargs) 4771 dlg.CenterOnParent() 4772 if dlg.ShowModal() == wx.ID_OK: 4773 result = dlg.chosen 4774 dlg.Destroy() 4775 return result 4776 4777 def PhaseSelector(ChoiceList, ParentFrame=None, 4778 title='Select a phase', size=None,header='Phase Selector'): 4779 ''' Provide a wx dialog to select a phase, used in importers if a file 4780 contains more than one phase 4781 ''' 4782 return BlockSelector(ChoiceList,ParentFrame,title, 4783 size,header) 4784 4695 4785 ################################################################################ 4696 4786 # configuration routines (for editing config.py)
Note: See TracChangeset
for help on using the changeset viewer.