##// END OF EJS Templates
merge
Ville M. Vainio -
r1132:999d4d56 merge
parent child Browse files
Show More
@@ -461,8 +461,7 b' class IPShellWidget(wx.Panel):'
461 because it seems to be more useful
461 because it seems to be more useful
462 Any idea to make it more 'generic' welcomed.
462 Any idea to make it more 'generic' welcomed.
463 '''
463 '''
464
464 def __init__(self, parent, intro=None,
465 def __init__(self, parent, ask_exit_handler=None, intro=None,
466 background_color="BLACK", add_button_handler=None,
465 background_color="BLACK", add_button_handler=None,
467 wx_ip_shell=None,
466 wx_ip_shell=None,
468 ):
467 ):
@@ -478,24 +477,25 b' class IPShellWidget(wx.Panel):'
478 self.cout = StringIO()
477 self.cout = StringIO()
479
478
480 self.add_button_handler = add_button_handler
479 self.add_button_handler = add_button_handler
481 self.ask_exit_handler = ask_exit_handler
482
480
483 if wx_ip_shell is not None:
481 if wx_ip_shell is not None:
484 self.IP = wx_ip_shell
482 self.IP = wx_ip_shell
485 else:
483 else:
486 self.IP = WxNonBlockingIPShell(self,
484 self.IP = WxNonBlockingIPShell(self,
487 cout=self.cout,cerr=self.cout,
485 cout = self.cout,cerr = self.cout,
488 ask_exit_handler = ask_exit_handler)
486 ask_exit_handler = self.askExitCallback)
489
487
490 ### IPython wx console view instanciation ###
488 ### IPython wx console view instanciation ###
491 #If user didn't defined an intro text, we create one for him
489 #If user didn't defined an intro text, we create one for him
492 #If you really wnat an empty intrp just call wxIPythonViewPanel
490 #If you really wnat an empty intrp just call wxIPythonViewPanel
493 #with intro=''
491 #with intro=''
494 if intro == None:
492 if intro is None:
495 welcome_text = "Welcome to WxIPython Shell.\n\n"
493 welcome_text = "Welcome to WxIPython Shell.\n\n"
496 welcome_text+= self.IP.getBanner()
494 welcome_text+= self.IP.getBanner()
497 welcome_text+= "!command -> Execute command in shell\n"
495 welcome_text+= "!command -> Execute command in shell\n"
498 welcome_text+= "TAB -> Autocompletion\n"
496 welcome_text+= "TAB -> Autocompletion\n"
497 else:
498 welcome_text = intro
499
499
500 self.text_ctrl = WxConsoleView(self,
500 self.text_ctrl = WxConsoleView(self,
501 self.IP.getPrompt(),
501 self.IP.getPrompt(),
@@ -518,6 +518,9 b' class IPShellWidget(wx.Panel):'
518 self.setCurrentState('IDLE')
518 self.setCurrentState('IDLE')
519 self.pager_state = 'DONE'
519 self.pager_state = 'DONE'
520
520
521 def askExitCallback(self, event):
522 self.askExitHandler(event)
523
521 #---------------------- IPython Thread Management ------------------------
524 #---------------------- IPython Thread Management ------------------------
522 def stateDoExecuteLine(self):
525 def stateDoExecuteLine(self):
523 #print >>sys.__stdout__,"command:",self.getCurrentLine()
526 #print >>sys.__stdout__,"command:",self.getCurrentLine()
@@ -692,6 +695,17 b' class IPShellWidget(wx.Panel):'
692 '''
695 '''
693 self.updateStatusTracker = func
696 self.updateStatusTracker = func
694
697
698 def askExitHandler(self, event):
699 '''
700 Default exit handler
701 '''
702 self.text_ctrl.write('\nExit callback has not been set.')
703
704 def setAskExitHandler(self, func):
705 '''
706 Define an exit handler
707 '''
708 self.askExitHandler = func
695
709
696 if __name__ == '__main__':
710 if __name__ == '__main__':
697 # Some simple code to test the shell widget.
711 # Some simple code to test the shell widget.
@@ -34,14 +34,14 b' class MyFrame(wx.Frame):'
34 #create differents panels and make them persistant
34 #create differents panels and make them persistant
35 self.history_panel = IPythonHistoryPanel(self)
35 self.history_panel = IPythonHistoryPanel(self)
36
36
37 self.ipython_panel = IPShellWidget(self,self.OnExitDlg,
37 self.ipython_panel = IPShellWidget(self,background_color = "BLACK")
38 background_color = "BLACK")
39
38
40 #self.ipython_panel = WxIPythonViewPanel(self,self.OnExitDlg,
39 #self.ipython_panel = WxIPythonViewPanel(self,
41 # background_color = "WHITE")
40 # background_color = "WHITE")
42
41
43 self.ipython_panel.setHistoryTrackerHook(self.history_panel.write)
42 self.ipython_panel.setHistoryTrackerHook(self.history_panel.write)
44 self.ipython_panel.setStatusTrackerHook(self.updateStatus)
43 self.ipython_panel.setStatusTrackerHook(self.updateStatus)
44 self.ipython_panel.setAskExitHandler(self.OnExitDlg)
45
45
46 self.statusbar = self.createStatus()
46 self.statusbar = self.createStatus()
47 self.createMenu()
47 self.createMenu()
General Comments 0
You need to be logged in to leave comments. Login now