Ignore:
Timestamp:
Dec 20, 2011 5:25:39 PM (12 years ago)
Author:
Jae Cho <jhjcho@…>
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
b025572
Parents:
1352c78
Message:

more completion of custom model edit

File:
1 edited

Legend:

Unmodified
Added
Removed
  • calculatorview/src/sans/perspectives/calculator/pyconsole.py

    r4c5448c r7c8d3093  
    1212if sys.platform.count("win32")>0: 
    1313    PANEL_WIDTH = 800 
    14     PANEL_HEIGHT = 600 
     14    PANEL_HEIGHT = 700 
    1515    FONT_VARIANT = 0 
    1616else: 
    1717    PANEL_WIDTH = 830 
    18     PANEL_HEIGHT = 620 
     18    PANEL_HEIGHT = 730 
    1919    FONT_VARIANT = 1 
    2020ID_COMPILE = wx.NewId()  
     
    5959        self.dataDir = dataDir 
    6060        self.Centre() 
    61         self.fileMenu.FindItemById(wx.ID_NEW).Enable(False) 
     61         
     62        self.Bind(wx.EVT_MENU, self.OnNewFile, id=wx.ID_NEW) 
    6263        self.Bind(wx.EVT_MENU, self.OnOpenFile, id=wx.ID_OPEN) 
    6364        self.Bind(wx.EVT_MENU, self.OnSaveFile, id=wx.ID_SAVE) 
     
    6768        self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateCompileMenu, id=ID_COMPILE) 
    6869        self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateCompileMenu, id=ID_RUN) 
    69          
     70        if not title.count('Python Shell'): 
     71            # Delete menu item (open and new) if not python shell 
     72            self.fileMenu.Delete(wx.ID_NEW) 
     73            self.fileMenu.Delete(wx.ID_OPEN) 
     74         
     75    
    7076    def _add_menu(self): 
    7177        """ 
     
    7682                 'Compile the file') 
    7783        self.compileMenu.AppendSeparator() 
    78         self.compileMenu.Append(ID_RUN, 'Run', 
     84        self.compileMenu.Append(ID_RUN, 'Run in Shell', 
    7985                 'Run the file in the Python Shell') 
    80         self.MenuBar.Insert(3, self.compileMenu, '&Compile') 
     86        self.MenuBar.Insert(3, self.compileMenu, '&Run') 
    8187     
    8288    def OnHelp(self, event): 
     
    109115                           wx.OK|wx.ICON_INFORMATION)   
    110116        dial.ShowModal() 
     117         
     118    def OnNewFile(self, event): 
     119        """ 
     120        OnFileOpen   
     121        """ 
     122        self.OnFileNew(event) 
    111123 
    112124    def OnOpenFile(self, event): 
     
    134146        self.Show(True) 
    135147 
    136     def bufferSaveAs(self): 
    137         """ 
    138         Save buffer to a new filename: Bypass the annoying suggest save  
    139         """ 
     148    def bufferOpen(self): 
     149        """ 
     150        Open file in buffer, bypassing editor bufferOpen 
     151        """ 
     152        if self.bufferHasChanged(): 
     153            cancel = self.bufferSuggestSave() 
     154            if cancel: 
     155                return cancel 
    140156        filedir = '' 
    141157        if self.buffer and self.buffer.doc.filedir: 
    142158            filedir = self.buffer.doc.filedir 
    143         result = editor.saveSingle(directory=filedir) 
     159        result = editor.openSingle(directory=filedir,   
     160                            wildcard='Python Files (*.py)|*.py') 
     161        if result.path: 
     162            self.bufferCreate(result.path) 
     163        cancel = False 
     164        return cancel 
     165     
     166    def bufferSaveAs(self): 
     167        """ 
     168        Save buffer to a new filename: Bypassing editor bufferSaveAs 
     169        """ 
     170        filedir = '' 
     171        if self.buffer and self.buffer.doc.filedir: 
     172            filedir = self.buffer.doc.filedir 
     173        result = editor.saveSingle(directory=filedir,  
     174                                   filename='untitled.py', 
     175                                   wildcard='Python Files (*.py)|*.py') 
    144176        if result.path: 
    145177            self.buffer.saveAs(result.path) 
     
    148180            cancel = True 
    149181        return cancel 
     182     
    150183     
    151184    def update_custom_combo(self): 
     
    176209            # Why we have to do this (Otherwise problems on Windows)? 
    177210            forward_path = self.buffer.doc.filepath.replace('\\', '/') 
    178             self.shell.Execute("execfile('%s')"% forward_path) 
     211            self.shell.Execute("execfile('%s')"% forward_path)  
    179212            self.shell.Hide() 
    180213            self.shell.Show(True) 
    181             self.shell.SetFocus() 
     214            return self.shell.GetText().split(">>>")[-2] 
    182215        else: 
    183216            mssg = "\n This is not a python file." 
     
    185218            icon = wx.ICON_ERROR 
    186219            wx.MessageBox(str(mssg), title, style=icon) 
     220            return 0 
    187221         
    188222    def OnCompile(self, event): 
     
    192226        if self._check_changed(): 
    193227            return True 
    194         if self._get_err_msg(): 
     228        run_out = self.OnRun(None) 
     229        if self._get_err_msg(run_out): 
    195230            if self._manager != None and self.panel != None: 
    196                 self._manager.set_edit_menu(self.parent) 
     231                self._manager.set_edit_menu_helper(self.parent) 
    197232                wx.CallAfter(self.update_custom_combo) 
    198233     
     
    206241                return cancel 
    207242              
    208     def _get_err_msg(self): 
     243    def _get_err_msg(self, text=''): 
    209244        """ 
    210245        Get err_msg 
     
    229264        if msg != None: 
    230265            mssg += "Error occurred:\n" 
    231             mssg += str(msg) 
    232             title = 'Warning' 
    233             icon = wx.ICON_WARNING 
     266            mssg += str(msg) + "\n\n" 
     267            if text: 
     268                mssg += "Run-Test results:\n" 
     269                mssg += str(text) 
     270                title = 'Warning' 
     271                icon = wx.ICON_WARNING 
    234272        else: 
    235             mssg += "Successful." 
     273            mssg += "Successful.\n\n" 
     274            if text: 
     275                mssg += "Run-Test results:\n" 
     276                mssg += str(text) 
    236277            title = 'Info' 
    237278            icon = wx.ICON_INFORMATION 
Note: See TracChangeset for help on using the changeset viewer.