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