Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

#$Id: shellCtrl.py 91 2011-02-07 23:01:27Z sarkiss $ 

import wx 

from wx import py 

class ShellController: 

    def __init__(self, frame): 

        #self.shellMenu = viewMenu.AppendCheckItem(ID_SHELL, "Python Shell")    

        #self.shellMenu.Check() 

        #viewMenu.AppendSeparator() 

 

        #crust = py.crust.Crust(parent=self) 

#        self.navigator = wx.aui.AuiNotebook(self,size=wx.Size(200,400)) 

# 

#        self.filling = wx.py.crust.Filling(self.navigator,rootObject=self.myGLCanvas, 

#                                           rootLabel="GL Canvas")    

#        self.navigator.AddPage(self.filling, 'Namespace') 

#        self.display = wx.py.crust.Display(parent=self.navigator) 

#        self.navigator.AddPage(self.display, 'Display') 

#        # Add 'pp' (pretty print) to the interpreter's locals. 

#         

#        self.calltip = wx.py.crust.Calltip(parent=self.navigator) 

#        self.navigator.AddPage(self.calltip, 'Calltip') 

#         

#        self.sessionlisting = wx.py.crust.SessionListing(parent=self.navigator) 

#        self.navigator.AddPage(self.sessionlisting, 'History') 

#         

#        self.dispatcherlisting = wx.py.crust.DispatcherListing(parent=self.navigator) 

#        self.navigator.AddPage(self.dispatcherlisting, 'Dispatcher') 

#        # add the panes to the manager 

        #self._mgr.AddPane(self.navigator, wx.LEFT, 'Control') 

        frame.shell = py.shell.Shell(frame.controls) 

        frame.shell.redirectStdin(True) 

        frame.shell.redirectStdout(True) 

        from icons import pythonPNG 

 

        frame.controls.AddPage(frame.shell, "Python Shell", bitmap=pythonPNG) 

        #uncomment the lines below to print stack each time a text is added in the shell 

        #this is useful for debugging and removing print statement left by other users  

#        self.fun = frame.shell.EnsureCaretVisible 

#        frame.shell.EnsureCaretVisible = self.printStack 

 

        #self.ModifiyTraceback() 

 

 

    def printStack(self): 

        import traceback 

        traceback.print_stack() 

        self.fun() 

 

    def ModifiyTraceback(self): 

        from traceback import print_exception 

        def print_exception_modified(etype, value, tb, limit=None, file=None): 

            sys.last_type, sys.last_value, sys.last_traceback = sys.exc_info() 

            #self.shell.redirectStderr(True) 

            print_exception(etype, value, tb, limit, file) 

            #self.shell.redirectStderr(False) 

            self.shell.prompt() 

        import traceback 

        traceback.print_exception = print_exception_modified 

#        import sys 

#        sys.modules['traceback'].print_exception = print_exception_modified