Show More
@@ -30,9 +30,7 b' import wx.lib.newevent' | |||||
30 |
|
30 | |||
31 | import re |
|
31 | import re | |
32 | import sys |
|
32 | import sys | |
33 | import os |
|
|||
34 | import locale |
|
33 | import locale | |
35 | import time |
|
|||
36 | from StringIO import StringIO |
|
34 | from StringIO import StringIO | |
37 | try: |
|
35 | try: | |
38 | import IPython |
|
36 | import IPython | |
@@ -76,35 +74,39 b' class WxNonBlockingIPShell(NonBlockingIPShell):' | |||||
76 | class WxConsoleView(stc.StyledTextCtrl): |
|
74 | class WxConsoleView(stc.StyledTextCtrl): | |
77 | ''' |
|
75 | ''' | |
78 | Specialized styled text control view for console-like workflow. |
|
76 | Specialized styled text control view for console-like workflow. | |
79 |
We use here a scintilla frontend thus it can be reused in any GUI t |
|
77 | We use here a scintilla frontend thus it can be reused in any GUI that | |
80 | scintilla with less work. |
|
78 | supports scintilla with less work. | |
81 |
|
79 | |||
82 |
@cvar ANSI_COLORS_BLACK: Mapping of terminal colors to X11 names. |
|
80 | @cvar ANSI_COLORS_BLACK: Mapping of terminal colors to X11 names. | |
|
81 | (with Black background) | |||
83 | @type ANSI_COLORS_BLACK: dictionary |
|
82 | @type ANSI_COLORS_BLACK: dictionary | |
84 |
|
83 | |||
85 |
@cvar ANSI_COLORS_WHITE: Mapping of terminal colors to X11 names. |
|
84 | @cvar ANSI_COLORS_WHITE: Mapping of terminal colors to X11 names. | |
|
85 | (with White background) | |||
86 | @type ANSI_COLORS_WHITE: dictionary |
|
86 | @type ANSI_COLORS_WHITE: dictionary | |
87 |
|
87 | |||
88 | @ivar color_pat: Regex of terminal color pattern |
|
88 | @ivar color_pat: Regex of terminal color pattern | |
89 | @type color_pat: _sre.SRE_Pattern |
|
89 | @type color_pat: _sre.SRE_Pattern | |
90 | ''' |
|
90 | ''' | |
91 |
ANSI_STYLES_BLACK |
|
91 | ANSI_STYLES_BLACK={'0;30': [0,'WHITE'], '0;31': [1,'RED'], | |
92 |
|
|
92 | '0;32': [2,'GREEN'], '0;33': [3,'BROWN'], | |
93 |
|
|
93 | '0;34': [4,'BLUE'], '0;35': [5,'PURPLE'], | |
94 |
|
|
94 | '0;36': [6,'CYAN'], '0;37': [7,'LIGHT GREY'], | |
95 |
|
|
95 | '1;30': [8,'DARK GREY'], '1;31': [9,'RED'], | |
96 |
|
|
96 | '1;32': [10,'SEA GREEN'], '1;33': [11,'YELLOW'], | |
97 |
|
|
97 | '1;34': [12,'LIGHT BLUE'], '1;35': | |
98 | '1;36': [14,'LIGHT STEEL BLUE'], '1;37': [15,'YELLOW']} |
|
98 | [13,'MEDIUM VIOLET RED'], | |
99 |
|
99 | '1;36': [14,'LIGHT STEEL BLUE'],'1;37': [15,'YELLOW']} | ||
100 | ANSI_STYLES_WHITE ={'0;30': [0,'BLACK'], '0;31': [1,'RED'], |
|
100 | ||
101 | '0;32': [2,'GREEN'], '0;33': [3,'BROWN'], |
|
101 | ANSI_STYLES_WHITE={'0;30': [0,'BLACK'], '0;31': [1,'RED'], | |
102 |
|
|
102 | '0;32': [2,'GREEN'], '0;33': [3,'BROWN'], | |
103 |
|
|
103 | '0;34': [4,'BLUE'], '0;35': [5,'PURPLE'], | |
104 |
|
|
104 | '0;36': [6,'CYAN'], '0;37': [7,'LIGHT GREY'], | |
105 |
|
|
105 | '1;30': [8,'DARK GREY'], '1;31': [9,'RED'], | |
106 |
|
|
106 | '1;32': [10,'SEA GREEN'], '1;33': [11,'YELLOW'], | |
107 |
|
|
107 | '1;34': [12,'LIGHT BLUE'], '1;35': | |
|
108 | [13,'MEDIUM VIOLET RED'], | |||
|
109 | '1;36': [14,'LIGHT STEEL BLUE'],'1;37': [15,'YELLOW']} | |||
108 |
|
110 | |||
109 | def __init__(self,parent,prompt,intro="",background_color="BLACK", |
|
111 | def __init__(self,parent,prompt,intro="",background_color="BLACK", | |
110 | pos=wx.DefaultPosition, ID = -1, size=wx.DefaultSize, |
|
112 | pos=wx.DefaultPosition, ID = -1, size=wx.DefaultSize, | |
@@ -451,13 +453,14 b' class WxConsoleView(stc.StyledTextCtrl):' | |||||
451 | #print pt |
|
453 | #print pt | |
452 | #self.Refresh(False) |
|
454 | #self.Refresh(False) | |
453 |
|
455 | |||
454 |
class |
|
456 | class IPShellWidget(wx.Panel): | |
455 | ''' |
|
457 | ''' | |
456 | This is wx.Panel that embbed the IPython Thread and the wx.StyledTextControl |
|
458 | This is wx.Panel that embbed the IPython Thread and the wx.StyledTextControl | |
457 |
If you want to port this to any other GUI toolkit, just replace the |
|
459 | If you want to port this to any other GUI toolkit, just replace the | |
458 |
by YOURGUIConsoleView and make YOURGUIIPythonView derivate |
|
460 | WxConsoleView by YOURGUIConsoleView and make YOURGUIIPythonView derivate | |
459 | I've choosed to derivate from a wx.Panel because it seems to be ore usefull |
|
461 | from whatever container you want. I've choosed to derivate from a wx.Panel | |
460 | Any idea to make it more 'genric' welcomed. |
|
462 | because it seems to be more useful | |
|
463 | Any idea to make it more 'generic' welcomed. | |||
461 | ''' |
|
464 | ''' | |
462 |
|
465 | |||
463 | def __init__(self, parent, ask_exit_handler=None, intro=None, |
|
466 | def __init__(self, parent, ask_exit_handler=None, intro=None, | |
@@ -514,9 +517,6 b' class WxIPythonViewPanel(wx.Panel):' | |||||
514 | self.cur_state = 'IDLE' |
|
517 | self.cur_state = 'IDLE' | |
515 | self.pager_state = 'DONE' |
|
518 | self.pager_state = 'DONE' | |
516 |
|
519 | |||
517 | def __del__(self): |
|
|||
518 | WxConsoleView.__del__() |
|
|||
519 |
|
||||
520 | #---------------------- IPython Thread Management ------------------------ |
|
520 | #---------------------- IPython Thread Management ------------------------ | |
521 | def stateDoExecuteLine(self): |
|
521 | def stateDoExecuteLine(self): | |
522 | #print >>sys.__stdout__,"command:",self.getCurrentLine() |
|
522 | #print >>sys.__stdout__,"command:",self.getCurrentLine() | |
@@ -703,4 +703,25 b' class WxIPythonViewPanel(wx.Panel):' | |||||
703 | Define a new status tracker |
|
703 | Define a new status tracker | |
704 | ''' |
|
704 | ''' | |
705 | self.updateStatusTracker = func |
|
705 | self.updateStatusTracker = func | |
706 |
|
706 | |||
|
707 | ||||
|
708 | if __name__ == '__main__': | |||
|
709 | # Some simple code to test the shell widget. | |||
|
710 | class MainWindow(wx.Frame): | |||
|
711 | def __init__(self, parent, id, title): | |||
|
712 | wx.Frame.__init__(self, parent, id, title, size=(300,250)) | |||
|
713 | self._sizer = wx.BoxSizer(wx.VERTICAL) | |||
|
714 | self.shell = IPShellWidget(self) | |||
|
715 | self._sizer.Add(self.shell, 1, wx.EXPAND) | |||
|
716 | self.SetSizer(self._sizer) | |||
|
717 | self.SetAutoLayout(1) | |||
|
718 | self.Show(True) | |||
|
719 | ||||
|
720 | app = wx.PySimpleApp() | |||
|
721 | frame = MainWindow(None, wx.ID_ANY, 'Ipython') | |||
|
722 | frame.SetSize((780, 460)) | |||
|
723 | shell = frame.shell | |||
|
724 | ||||
|
725 | app.MainLoop() | |||
|
726 | ||||
|
727 |
@@ -5,7 +5,7 b' import wx.aui' | |||||
5 | import wx.py |
|
5 | import wx.py | |
6 | from wx.lib.wordwrap import wordwrap |
|
6 | from wx.lib.wordwrap import wordwrap | |
7 |
|
7 | |||
8 |
from ipython_view import |
|
8 | from ipython_view import IPShellWidget | |
9 | from ipython_history import * |
|
9 | from ipython_history import * | |
10 |
|
10 | |||
11 | __version__ = 0.8 |
|
11 | __version__ = 0.8 | |
@@ -20,7 +20,8 b' __license__ = "BSD"' | |||||
20 | class MyFrame(wx.Frame): |
|
20 | class MyFrame(wx.Frame): | |
21 | """Creating one main frame for our |
|
21 | """Creating one main frame for our | |
22 | application with movables windows""" |
|
22 | application with movables windows""" | |
23 |
def __init__(self, parent=None, id=-1, title="WxIPython", |
|
23 | def __init__(self, parent=None, id=-1, title="WxIPython", | |
|
24 | pos=wx.DefaultPosition, | |||
24 | size=(800, 600), style=wx.DEFAULT_FRAME_STYLE): |
|
25 | size=(800, 600), style=wx.DEFAULT_FRAME_STYLE): | |
25 | wx.Frame.__init__(self, parent, id, title, pos, size, style) |
|
26 | wx.Frame.__init__(self, parent, id, title, pos, size, style) | |
26 | self._mgr = wx.aui.AuiManager() |
|
27 | self._mgr = wx.aui.AuiManager() | |
@@ -31,7 +32,7 b' class MyFrame(wx.Frame):' | |||||
31 | #create differents panels and make them persistant |
|
32 | #create differents panels and make them persistant | |
32 | self.history_panel = IPythonHistoryPanel(self) |
|
33 | self.history_panel = IPythonHistoryPanel(self) | |
33 |
|
34 | |||
34 |
self.ipython_panel = |
|
35 | self.ipython_panel = IPShellWidget(self,self.OnExitDlg, | |
35 | background_color = "BLACK") |
|
36 | background_color = "BLACK") | |
36 |
|
37 | |||
37 | #self.ipython_panel = WxIPythonViewPanel(self,self.OnExitDlg, |
|
38 | #self.ipython_panel = WxIPythonViewPanel(self,self.OnExitDlg, |
General Comments 0
You need to be logged in to leave comments.
Login now