Changeset 7c8d3093 in sasview for calculatorview/src/sans/perspectives/calculator/pyconsole.py
- Timestamp:
- Dec 20, 2011 3:25:39 PM (13 years ago)
- 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
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
calculatorview/src/sans/perspectives/calculator/pyconsole.py
r4c5448c r7c8d3093 12 12 if sys.platform.count("win32")>0: 13 13 PANEL_WIDTH = 800 14 PANEL_HEIGHT = 60014 PANEL_HEIGHT = 700 15 15 FONT_VARIANT = 0 16 16 else: 17 17 PANEL_WIDTH = 830 18 PANEL_HEIGHT = 62018 PANEL_HEIGHT = 730 19 19 FONT_VARIANT = 1 20 20 ID_COMPILE = wx.NewId() … … 59 59 self.dataDir = dataDir 60 60 self.Centre() 61 self.fileMenu.FindItemById(wx.ID_NEW).Enable(False) 61 62 self.Bind(wx.EVT_MENU, self.OnNewFile, id=wx.ID_NEW) 62 63 self.Bind(wx.EVT_MENU, self.OnOpenFile, id=wx.ID_OPEN) 63 64 self.Bind(wx.EVT_MENU, self.OnSaveFile, id=wx.ID_SAVE) … … 67 68 self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateCompileMenu, id=ID_COMPILE) 68 69 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 70 76 def _add_menu(self): 71 77 """ … … 76 82 'Compile the file') 77 83 self.compileMenu.AppendSeparator() 78 self.compileMenu.Append(ID_RUN, 'Run ',84 self.compileMenu.Append(ID_RUN, 'Run in Shell', 79 85 'Run the file in the Python Shell') 80 self.MenuBar.Insert(3, self.compileMenu, '& Compile')86 self.MenuBar.Insert(3, self.compileMenu, '&Run') 81 87 82 88 def OnHelp(self, event): … … 109 115 wx.OK|wx.ICON_INFORMATION) 110 116 dial.ShowModal() 117 118 def OnNewFile(self, event): 119 """ 120 OnFileOpen 121 """ 122 self.OnFileNew(event) 111 123 112 124 def OnOpenFile(self, event): … … 134 146 self.Show(True) 135 147 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 140 156 filedir = '' 141 157 if self.buffer and self.buffer.doc.filedir: 142 158 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') 144 176 if result.path: 145 177 self.buffer.saveAs(result.path) … … 148 180 cancel = True 149 181 return cancel 182 150 183 151 184 def update_custom_combo(self): … … 176 209 # Why we have to do this (Otherwise problems on Windows)? 177 210 forward_path = self.buffer.doc.filepath.replace('\\', '/') 178 self.shell.Execute("execfile('%s')"% forward_path) 211 self.shell.Execute("execfile('%s')"% forward_path) 179 212 self.shell.Hide() 180 213 self.shell.Show(True) 181 self.shell.SetFocus()214 return self.shell.GetText().split(">>>")[-2] 182 215 else: 183 216 mssg = "\n This is not a python file." … … 185 218 icon = wx.ICON_ERROR 186 219 wx.MessageBox(str(mssg), title, style=icon) 220 return 0 187 221 188 222 def OnCompile(self, event): … … 192 226 if self._check_changed(): 193 227 return True 194 if self._get_err_msg(): 228 run_out = self.OnRun(None) 229 if self._get_err_msg(run_out): 195 230 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) 197 232 wx.CallAfter(self.update_custom_combo) 198 233 … … 206 241 return cancel 207 242 208 def _get_err_msg(self ):243 def _get_err_msg(self, text=''): 209 244 """ 210 245 Get err_msg … … 229 264 if msg != None: 230 265 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 234 272 else: 235 mssg += "Successful." 273 mssg += "Successful.\n\n" 274 if text: 275 mssg += "Run-Test results:\n" 276 mssg += str(text) 236 277 title = 'Info' 237 278 icon = wx.ICON_INFORMATION
Note: See TracChangeset
for help on using the changeset viewer.