Changeset 4498


Ignore:
Timestamp:
Jun 18, 2020 9:32:02 PM (3 years ago)
Author:
toby
Message:

cleanup errors and cruft noted in spyder

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIIO.py

    r4492 r4498  
    4646import sys
    4747import re
    48 import glob
    4948import random as ran
    5049import GSASIIpath
     
    6160except ImportError:
    6261    pass
    63 import GSASIIimage as G2img
    6462import GSASIIElem as G2el
    6563import GSASIIstrIO as G2stIO
     
    10081006        wx.EndBusyCursor()
    10091007    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               
    10751009def ExtractFileFromZip(filename, selection=None, confirmread=True,
    10761010                       confirmoverwrite=True, parent=None,
     
    16901624
    16911625        '''
    1692         pth = G2G.GetExportPath(self.G2frame)
     1626        #pth = G2G.GetExportPath(self.G2frame)
    16931627        if self.G2frame.GSASprojectfile:
    16941628            defnam = os.path.splitext(
  • trunk/GSASIIctrlGUI.py

    r4496 r4498  
    170170import GSASIIfiles as G2fil
    171171import GSASIIscriptable as G2sc
    172 
     172import GSASIIpwd as G2pwd
     173import GSASIIlattice as G2lat
     174if sys.version_info[0] >= 3:
     175    unicode = str
     176    basestring = str
    173177
    174178# Define a short names for convenience
     
    28772881        self.ChoiceList = ChoiceList
    28782882        self.ColumnData = ColumnData
    2879         nCol = len(ColumnData)
    28802883        if options['style'] & wx.OK:
    28812884            useOK = True
     
    46394642    def OnHelpAbout(self, event):
    46404643        "Display an 'About GSAS-II' box"
    4641         import GSASII
    46424644        try:
    46434645            import wx.adv as wxadv  # AboutBox moved here in Phoenix
     
    50435045    return selected
    50445046
     5047class MultipleChoicesDialog(wx.Dialog):
     5048    '''A dialog that offers a series of choices, each with a
     5049    title and a wx.Choice widget. Intended to be used Modally.
     5050    typical input:
     5051
     5052        *  choicelist=[ ('a','b','c'), ('test1','test2'),('no choice',)]
     5053        *  headinglist = [ 'select a, b or c', 'select 1 of 2', 'No option here']
     5054       
     5055    selections are placed in self.chosen when OK is pressed
     5056
     5057    Also see GSASIIctrlGUI
     5058    '''
     5059    def __init__(self,choicelist,headinglist,
     5060                 head='Select options',
     5061                 title='Please select from options below',
     5062                 parent=None):
     5063        self.chosen = []
     5064        wx.Dialog.__init__(
     5065            self,parent,wx.ID_ANY,head,
     5066            pos=wx.DefaultPosition,style=wx.DEFAULT_DIALOG_STYLE)
     5067        panel = wx.Panel(self)
     5068        mainSizer = wx.BoxSizer(wx.VERTICAL)
     5069        mainSizer.Add((10,10),1)
     5070        topLabl = wx.StaticText(panel,wx.ID_ANY,title)
     5071        mainSizer.Add(topLabl,0,wx.ALIGN_CENTER_VERTICAL|wx.CENTER,10)
     5072        self.ChItems = []
     5073        for choice,lbl in zip(choicelist,headinglist):
     5074            mainSizer.Add((10,10),1)
     5075            self.chosen.append(0)
     5076            topLabl = wx.StaticText(panel,wx.ID_ANY,' '+lbl)
     5077            mainSizer.Add(topLabl,0,wx.ALIGN_LEFT,10)
     5078            self.ChItems.append(wx.Choice(self, wx.ID_ANY, (100, 50), choices = choice))
     5079            mainSizer.Add(self.ChItems[-1],0,wx.ALIGN_CENTER,10)
     5080
     5081        OkBtn = wx.Button(panel,-1,"Ok")
     5082        OkBtn.Bind(wx.EVT_BUTTON, self.OnOk)
     5083        cancelBtn = wx.Button(panel,-1,"Cancel")
     5084        cancelBtn.Bind(wx.EVT_BUTTON, self.OnCancel)
     5085        btnSizer = wx.BoxSizer(wx.HORIZONTAL)
     5086        btnSizer.Add((20,20),1)
     5087        btnSizer.Add(OkBtn)
     5088        btnSizer.Add((20,20),1)
     5089        btnSizer.Add(cancelBtn)
     5090        btnSizer.Add((20,20),1)
     5091        mainSizer.Add(btnSizer,0,wx.EXPAND|wx.BOTTOM|wx.TOP, 10)
     5092        panel.SetSizer(mainSizer)
     5093        panel.Fit()
     5094        self.Fit()
     5095       
     5096    def OnOk(self,event):
     5097        parent = self.GetParent()
     5098        if parent is not None: parent.Raise()
     5099        # save the results from the choice widgets
     5100        self.chosen = []
     5101        for w in self.ChItems:
     5102            self.chosen.append(w.GetSelection())
     5103        self.EndModal(wx.ID_OK)             
     5104           
     5105    def OnCancel(self,event):
     5106        parent = self.GetParent()
     5107        if parent is not None: parent.Raise()
     5108        self.chosen = []
     5109        self.EndModal(wx.ID_CANCEL)             
     5110
    50455111def MultipleChoicesSelector(choicelist, headinglist, ParentFrame=None, **kwargs):
    50465112    '''A modal dialog that offers a series of choices, each with a title and a wx.Choice
     
    51575223    except ImportError: # no config.py file yet
    51585224        savefile = os.path.join(GSASIIpath.path2GSAS2,'config.py')
    5159     except Exception as err: # import failed
     5225    except Exception: # import failed
    51605226        # find the bad file, save it in a new name and prepare to overwrite it
    51615227        for p in sys.path:
     
    62766342                else:
    62776343                    G2fil.G2Print("Warning: {} Reader failed to read {}"
    6278                                       .format(rd.formatName,filename))
     6344                                      .format(rd.formatName,f))
    62796345                Iparm1, Iparm2 = G2sc.load_iprms(Settings['instfile'],rd)   
    62806346                if 'phoenix' in wx.version():
     
    64356501                else:
    64366502                    G2fil.G2Print("Warning: {} Reader failed to read {}"
    6437                                       .format(rd.formatName,filename))
     6503                                      .format(rd.formatName,f))
    64386504                if 'phoenix' in wx.version():
    64396505                    HistName = 'PDF  '+rd.idstring
     
    67286794    # app.MainLoop()
    67296795    # print(td)
    6730        
     6796    choicelist=[ ('a','b','c'), ('test1','test2'),('no choice',)]
     6797    headinglist = [ 'select a, b or c', 'select 1 of 2', 'No option here']
     6798    dlg = MultipleChoicesDialog(choicelist,headinglist,parent=frm)
     6799    if dlg.ShowModal() == wx.ID_OK:
     6800        print(dlg.chosen)
     6801    print(MultipleChoicesSelector(choicelist,headinglist,frm))
    67316802    pnl = wx.Panel(frm)
    67326803    valArr = {'k':1.0}
Note: See TracChangeset for help on using the changeset viewer.