Changeset 2566


Ignore:
Timestamp:
Dec 8, 2016 7:51:19 AM (5 years ago)
Author:
toby
Message:

AutoInt? win-only problem; update for IPython 5 debug

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIimgGUI.py

    r2563 r2566  
    22522252            '''
    22532253            self.Evaluator = None
    2254             if r2.GetValue():
     2254            if self.useTable.GetValue():
     2255                dlg = None
    22552256                try:
    2256                     dlg = IntegParmTable(self.G2frame) # create the dialog
     2257                    dlg = IntegParmTable(self) # create the dialog
    22572258                    dlg.CenterOnParent()
    22582259                    if dlg.ShowModal() == wx.ID_OK:
     
    22612262                        self.Evaluator = DefineEvaluator(dlg)
    22622263                        self.params['Mode'] = 'table'
    2263                         r2E.Enable(True)
     2264                        self.editTable.Enable(True)
    22642265                    else:
    22652266                        self.useActive.SetValue(True)
    22662267                finally:
    2267                     dlg.Destroy()
    2268             if self.useActive.GetValue():
     2268                    if dlg: dlg.Destroy()
     2269            elif self.useActive.GetValue():
    22692270                self.params['Mode'] = 'active'
    22702271                self.imageBase = G2frame.Image
    22712272                self.useActive.SetLabel("Active Image: "+
    22722273                        G2frame.PatternTree.GetItemText(self.imageBase))
    2273                 r2E.Enable(False)
     2274                self.editTable.Enable(False)
     2275            else:
     2276                print('unexpected mode in OnRadioSelect')
    22742277
    22752278        def OnEditTable(event):
     
    22852288                    self.Evaluator = DefineEvaluator(dlg)
    22862289                    self.params['Mode'] = 'table'
    2287                     r2E.Enable(True)
     2290                    self.editTable.Enable(True)
    22882291                else:
    22892292                    self.useActive.SetValue(True)
     
    22922295                    self.useActive.SetLabel("Active Image: "+
    22932296                            G2frame.PatternTree.GetItemText(self.imageBase))
    2294                     r2E.Enable(False)
     2297                    self.editTable.Enable(False)
    22952298            finally:
    22962299                dlg.Destroy()
     
    23392342        self.useActive.SetValue(True)
    23402343        minisizer = wx.BoxSizer(wx.HORIZONTAL)
    2341         r2 = wx.RadioButton(mnpnl, wx.ID_ANY, "From distance look-up table")
    2342         minisizer.Add(r2,0,wx.ALIGN_LEFT|wx.ALL,1)
    2343         r2.Bind(wx.EVT_RADIOBUTTON, OnRadioSelect)
    2344         r2E = wx.Button(mnpnl,  wx.ID_ANY, "Edit table")
    2345         minisizer.Add(r2E,0,wx.ALIGN_LEFT,10)
    2346         r2E.Enable(False)
    2347         r2E.Bind(wx.EVT_BUTTON, OnEditTable)
     2344        self.useTable = wx.RadioButton(mnpnl, wx.ID_ANY, "From distance look-up table")
     2345        minisizer.Add(self.useTable,0,wx.ALIGN_LEFT|wx.ALL,1)
     2346        self.useTable.Bind(wx.EVT_RADIOBUTTON, OnRadioSelect)
     2347        self.editTable = wx.Button(mnpnl,  wx.ID_ANY, "Edit table")
     2348        minisizer.Add(self.editTable,0,wx.ALIGN_LEFT,10)
     2349        self.editTable.Enable(False)
     2350        self.editTable.Bind(wx.EVT_BUTTON, OnEditTable)
    23482351        # bind button and deactivate be default
    23492352        lblsizr.Add(minisizer)
     
    25112514               
    25122515    def EnableButtons(self,flag):
    2513         '''Turns the buttons at window bottom "off" when integration is running
     2516        '''Relabels and enable/disables the buttons at window bottom when auto-integration is running
    25142517        '''
    2515         for item in (self.btnstart,self.btnreset,self.btnclose):
    2516             item.Enable(flag)
     2518        # for unclear reasons disabling these buttons causes OnRadioSelect to be invoked
     2519        # on windows
     2520        if sys.platform != "win32":
     2521            for item in (self.btnstart,self.btnreset,self.btnclose): item.Enable(flag)
    25172522        if flag:
    25182523            self.btnstart.SetLabel('Pause')
     
    27672772            'Mask File',
    27682773            )
    2769     def __init__(self,G2frame,parms=None,IMfileList=None):
    2770         self.G2frame = G2frame
    2771         wx.Dialog.__init__(self,G2frame,style=wx.RESIZE_BORDER|wx.DEFAULT_DIALOG_STYLE)
     2774    def __init__(self,parent,parms=None,IMfileList=None):
     2775        self.G2frame = parent.G2frame
     2776        wx.Dialog.__init__(self,parent,style=wx.RESIZE_BORDER|wx.DEFAULT_DIALOG_STYLE)
    27722777        if parms:
    27732778            self.parms = parms # list of values by column
     
    27782783            files = []
    27792784            try:
    2780                 pth = G2G.GetImportPath(G2frame)
     2785                pth = G2G.GetImportPath(self.G2frame)
    27812786                if not pth: pth = '.'
    2782                 dlg = wx.FileDialog(self, 'Read previous table or build new table by selecting image control files', pth,
     2787                dlg = wx.FileDialog(parent, 'Read previous table or build new table by selecting image control files', pth,
    27832788                    style=wx.OPEN| wx.MULTIPLE,
    27842789                    wildcard='Integration table (*.imtbl)|*.imtbl|image control files (.imctrl)|*.imctrl')
     
    28292834                S = fp.readline()
    28302835            fp.close()
    2831             # delete entries
     2836            # delete entries where files do not exist
    28322837            m1 = [i for i,f in enumerate(tmpDict['filenames']) if not os.path.exists(f)]
    28332838            if m1:
     
    28542859                except ValueError:
    28552860                    parms.append(tmpDict[key])
     2861                except IndexError:
     2862                    print('No valid image control entries read')
     2863                    wx.CallAfter(self.EndModal,wx.ID_CANCEL)
     2864                    return [[]],[]
    28562865            return parms,fileList
    28572866        # option 2, read in a list of files
  • trunk/GSASIIpath.py

    r2455 r2566  
    504504    msg   = 'Entering IPython console at {0.f_code.co_filename} at line {0.f_lineno}'.format(frame)
    505505    savehook = sys.excepthook # save the exception hook
    506     InteractiveShellEmbed(banner1=msg)(local_ns=frame.f_locals,global_ns=frame.f_globals)
     506    try:
     507        InteractiveShellEmbed(banner1=msg)(local_ns=frame.f_locals,global_ns=frame.f_globals)
     508    except: # use a different call for IPython 5
     509        class c(object): pass
     510        pseudomod = c() # create something that acts like a module
     511        pseudomod.__dict__ = frame.f_locals
     512        InteractiveShellEmbed(banner1=msg)(module=pseudomod,global_ns=frame.f_globals)
    507513    sys.excepthook = savehook # reset IPython's change to the exception hook
    508514
Note: See TracChangeset for help on using the changeset viewer.