##// END OF EJS Templates
Merged Laurent's fixes for various small issues with the standalone WX...
Fernando Perez -
r1595:b7059034 merge
parent child Browse files
Show More
@@ -0,0 +1,11 b''
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 """wxIPython -- An enhanced Interactive Python GUI fonrtend
4 This script starts the Wx graphical frontend.
5 This is experimental so far.
6 Currently it support only ipython0 instance. Will be upgraded to ipython1 one.
7 """
8
9 from IPython.gui.wx import wxIPython
10
11 wxIPython.main()
@@ -26,6 +26,7 b' def make_color_table(in_class):'
26 Helper function for building the *TermColors classes."""
26 Helper function for building the *TermColors classes."""
27
27
28 color_templates = (
28 color_templates = (
29 # Dark colors
29 ("Black" , "0;30"),
30 ("Black" , "0;30"),
30 ("Red" , "0;31"),
31 ("Red" , "0;31"),
31 ("Green" , "0;32"),
32 ("Green" , "0;32"),
@@ -34,6 +35,7 b' def make_color_table(in_class):'
34 ("Purple" , "0;35"),
35 ("Purple" , "0;35"),
35 ("Cyan" , "0;36"),
36 ("Cyan" , "0;36"),
36 ("LightGray" , "0;37"),
37 ("LightGray" , "0;37"),
38 # Light colors
37 ("DarkGray" , "1;30"),
39 ("DarkGray" , "1;30"),
38 ("LightRed" , "1;31"),
40 ("LightRed" , "1;31"),
39 ("LightGreen" , "1;32"),
41 ("LightGreen" , "1;32"),
@@ -41,7 +43,17 b' def make_color_table(in_class):'
41 ("LightBlue" , "1;34"),
43 ("LightBlue" , "1;34"),
42 ("LightPurple" , "1;35"),
44 ("LightPurple" , "1;35"),
43 ("LightCyan" , "1;36"),
45 ("LightCyan" , "1;36"),
44 ("White" , "1;37"), )
46 ("White" , "1;37"),
47 # Blinking colors. Probably should not be used in anything serious.
48 ("BlinkBlack" , "5;30"),
49 ("BlinkRed" , "5;31"),
50 ("BlinkGreen" , "5;32"),
51 ("BlinkYellow" , "5;33"),
52 ("BlinkBlue" , "5;34"),
53 ("BlinkPurple" , "5;35"),
54 ("BlinkCyan" , "5;36"),
55 ("BlinkLightGray", "5;37"),
56 )
45
57
46 for name,value in color_templates:
58 for name,value in color_templates:
47 setattr(in_class,name,in_class._base % value)
59 setattr(in_class,name,in_class._base % value)
@@ -154,6 +154,8 b' class NonBlockingIPShell(object):'
154 self._term = IPython.genutils.IOTerm(cin=cin, cout=cout, cerr=cerr)
154 self._term = IPython.genutils.IOTerm(cin=cin, cout=cout, cerr=cerr)
155
155
156 excepthook = sys.excepthook
156 excepthook = sys.excepthook
157 #Hack to save sys.displayhook, because ipython seems to overwrite it...
158 self.sys_displayhook_ori = sys.displayhook
157
159
158 self._IP = IPython.Shell.make_IPython(
160 self._IP = IPython.Shell.make_IPython(
159 argv,user_ns=user_ns,
161 argv,user_ns=user_ns,
@@ -161,6 +163,9 b' class NonBlockingIPShell(object):'
161 embedded=True,
163 embedded=True,
162 shell_class=IPython.Shell.InteractiveShell)
164 shell_class=IPython.Shell.InteractiveShell)
163
165
166 #we restore sys.displayhook
167 sys.displayhook = self.sys_displayhook_ori
168
164 #we replace IPython default encoding by wx locale encoding
169 #we replace IPython default encoding by wx locale encoding
165 loc = locale.getpreferredencoding()
170 loc = locale.getpreferredencoding()
166 if loc:
171 if loc:
@@ -195,8 +200,9 b' class NonBlockingIPShell(object):'
195
200
196 self._line_to_execute = line
201 self._line_to_execute = line
197 #we launch the ipython line execution in a thread to make it interruptible
202 #we launch the ipython line execution in a thread to make it interruptible
198 ce = _CodeExecutor(self, self._afterExecute)
203 #with include it in self namespace to be able to call ce.raise_exc(KeyboardInterrupt)
199 ce.start()
204 self.ce = _CodeExecutor(self, self._afterExecute)
205 self.ce.start()
200
206
201 #----------------------- IPython management section ----------------------
207 #----------------------- IPython management section ----------------------
202 def getDocText(self):
208 def getDocText(self):
@@ -30,6 +30,21 b' import wx.stc as stc'
30 import re
30 import re
31 from StringIO import StringIO
31 from StringIO import StringIO
32
32
33 import sys
34 import codecs
35 import locale
36 for enc in (locale.getpreferredencoding(),
37 sys.getfilesystemencoding(),
38 sys.getdefaultencoding()):
39 try:
40 codecs.lookup(enc)
41 ENCODING = enc
42 break
43 except LookupError:
44 pass
45 else:
46 ENCODING = 'utf-8'
47
33 from ipshell_nonblocking import NonBlockingIPShell
48 from ipshell_nonblocking import NonBlockingIPShell
34
49
35 class WxNonBlockingIPShell(NonBlockingIPShell):
50 class WxNonBlockingIPShell(NonBlockingIPShell):
@@ -604,7 +619,7 b' class IPShellWidget(wx.Panel):'
604 self.text_ctrl.write('\n')
619 self.text_ctrl.write('\n')
605 lines_to_execute = lines.replace('\t',' '*4)
620 lines_to_execute = lines.replace('\t',' '*4)
606 lines_to_execute = lines_to_execute.replace('\r','')
621 lines_to_execute = lines_to_execute.replace('\r','')
607 self.IP.doExecute(lines_to_execute.encode('cp1252'))
622 self.IP.doExecute(lines_to_execute.encode(ENCODING))
608 self.updateHistoryTracker(lines)
623 self.updateHistoryTracker(lines)
609 self.setCurrentState('WAIT_END_OF_EXECUTION')
624 self.setCurrentState('WAIT_END_OF_EXECUTION')
610
625
@@ -2,7 +2,7 b''
2 # -*- coding: iso-8859-15 -*-
2 # -*- coding: iso-8859-15 -*-
3
3
4 import wx.aui
4 import wx.aui
5
5 import sys
6 #used for about dialog
6 #used for about dialog
7 from wx.lib.wordwrap import wordwrap
7 from wx.lib.wordwrap import wordwrap
8
8
@@ -10,6 +10,9 b' from wx.lib.wordwrap import wordwrap'
10 from IPython.gui.wx.ipython_view import IPShellWidget
10 from IPython.gui.wx.ipython_view import IPShellWidget
11 from IPython.gui.wx.ipython_history import IPythonHistoryPanel
11 from IPython.gui.wx.ipython_history import IPythonHistoryPanel
12
12
13 #used to create options.conf file in user directory
14 from IPython.ipapi import get
15
13 __version__ = 0.8
16 __version__ = 0.8
14 __author__ = "Laurent Dufrechou"
17 __author__ = "Laurent Dufrechou"
15 __email__ = "laurent.dufrechou _at_ gmail.com"
18 __email__ = "laurent.dufrechou _at_ gmail.com"
@@ -84,7 +87,9 b' class MyFrame(wx.Frame):'
84 dlg.Destroy()
87 dlg.Destroy()
85
88
86 def optionSave(self, name, value):
89 def optionSave(self, name, value):
87 opt = open('options.conf','w')
90 ip = get()
91 path = ip.IP.rc.ipythondir
92 opt = open(path + '/options.conf','w')
88
93
89 try:
94 try:
90 options_ipython_panel = self.ipython_panel.getOptions()
95 options_ipython_panel = self.ipython_panel.getOptions()
@@ -98,7 +103,10 b' class MyFrame(wx.Frame):'
98 opt.close()
103 opt.close()
99
104
100 def optionLoad(self):
105 def optionLoad(self):
101 opt = open('options.conf','r')
106 try:
107 ip = get()
108 path = ip.IP.rc.ipythondir
109 opt = open(path + '/options.conf','r')
102 lines = opt.readlines()
110 lines = opt.readlines()
103 opt.close()
111 opt.close()
104
112
@@ -117,6 +125,10 b' class MyFrame(wx.Frame):'
117 self.ipython_panel.reloadOptions(options_ipython_panel)
125 self.ipython_panel.reloadOptions(options_ipython_panel)
118 self.history_panel.reloadOptions(options_history_panel)
126 self.history_panel.reloadOptions(options_history_panel)
119
127
128 except IOError:
129 print >>sys.__stdout__,"Could not open Options.conf, defaulting to default values."
130
131
120 def createMenu(self):
132 def createMenu(self):
121 """local method used to create one menu bar"""
133 """local method used to create one menu bar"""
122
134
@@ -64,7 +64,7 b' def install():'
64 f = ip_dir + r'\Manual in PDF.lnk'
64 f = ip_dir + r'\Manual in PDF.lnk'
65 mkshortcut(t,r'IPython Manual - PDF-Format',f)
65 mkshortcut(t,r'IPython Manual - PDF-Format',f)
66
66
67 t = prefix + r'\share\doc\ipython\manual\ipython.html'
67 t = prefix + r'\share\doc\ipython\manual\html\index.html'
68 f = ip_dir + r'\Manual in HTML.lnk'
68 f = ip_dir + r'\Manual in HTML.lnk'
69 mkshortcut(t,'IPython Manual - HTML-Format',f)
69 mkshortcut(t,'IPython Manual - HTML-Format',f)
70
70
1 NO CONTENT: file was removed
NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now