Show More
@@ -26,7 +26,6 b' __license__ = "BSD"' | |||||
26 |
|
26 | |||
27 | import wx |
|
27 | import wx | |
28 | import wx.stc as stc |
|
28 | import wx.stc as stc | |
29 | import wx.lib.newevent |
|
|||
30 |
|
29 | |||
31 | import re |
|
30 | import re | |
32 | import sys |
|
31 | import sys | |
@@ -39,7 +38,6 b' except Exception,e:' | |||||
39 |
|
38 | |||
40 | from ipshell_nonblocking import NonBlockingIPShell |
|
39 | from ipshell_nonblocking import NonBlockingIPShell | |
41 |
|
40 | |||
42 |
|
||||
43 | class WxNonBlockingIPShell(NonBlockingIPShell): |
|
41 | class WxNonBlockingIPShell(NonBlockingIPShell): | |
44 | ''' |
|
42 | ''' | |
45 | An NonBlockingIPShell Thread that is WX dependent. |
|
43 | An NonBlockingIPShell Thread that is WX dependent. | |
@@ -171,7 +169,7 b' class WxConsoleView(stc.StyledTextCtrl):' | |||||
171 | self.autocomplete_mode = autocomplete_mode |
|
169 | self.autocomplete_mode = autocomplete_mode | |
172 |
|
170 | |||
173 | self.Bind(wx.EVT_KEY_DOWN, self._onKeypress) |
|
171 | self.Bind(wx.EVT_KEY_DOWN, self._onKeypress) | |
174 |
|
172 | |||
175 | def buildStyles(self): |
|
173 | def buildStyles(self): | |
176 | #we define platform specific fonts |
|
174 | #we define platform specific fonts | |
177 | if wx.Platform == '__WXMSW__': |
|
175 | if wx.Platform == '__WXMSW__': | |
@@ -231,7 +229,7 b' class WxConsoleView(stc.StyledTextCtrl):' | |||||
231 | def getBackgroundColor(self,color): |
|
229 | def getBackgroundColor(self,color): | |
232 | return self.background_color |
|
230 | return self.background_color | |
233 |
|
231 | |||
234 |
def asyncWrite(self, |
|
232 | def asyncWrite(self, evt): | |
235 | ''' |
|
233 | ''' | |
236 | Write given text to buffer in an asynchroneous way. |
|
234 | Write given text to buffer in an asynchroneous way. | |
237 | It is used from another thread to be able to acces the GUI. |
|
235 | It is used from another thread to be able to acces the GUI. | |
@@ -245,6 +243,7 b' class WxConsoleView(stc.StyledTextCtrl):' | |||||
245 |
|
243 | |||
246 | #be sure not to be interrutpted before the MutexGuiLeave! |
|
244 | #be sure not to be interrutpted before the MutexGuiLeave! | |
247 | self.write(text) |
|
245 | self.write(text) | |
|
246 | ||||
248 | #print >>sys.__stdout__,'done' |
|
247 | #print >>sys.__stdout__,'done' | |
249 |
|
248 | |||
250 | except KeyboardInterrupt: |
|
249 | except KeyboardInterrupt: | |
@@ -526,6 +525,7 b' class IPShellWidget(wx.Panel):' | |||||
526 | ''' |
|
525 | ''' | |
527 | wx.Panel.__init__(self,parent,wx.ID_ANY) |
|
526 | wx.Panel.__init__(self,parent,wx.ID_ANY) | |
528 |
|
527 | |||
|
528 | self.parent = parent | |||
529 | ### IPython non blocking shell instanciation ### |
|
529 | ### IPython non blocking shell instanciation ### | |
530 | self.cout = StringIO() |
|
530 | self.cout = StringIO() | |
531 | self.add_button_handler = add_button_handler |
|
531 | self.add_button_handler = add_button_handler | |
@@ -558,9 +558,18 b' class IPShellWidget(wx.Panel):' | |||||
558 |
|
558 | |||
559 | option_text = wx.StaticText(self, -1, "Options:") |
|
559 | option_text = wx.StaticText(self, -1, "Options:") | |
560 | self.completion_option = wx.CheckBox(self, -1, "Scintilla Completion") |
|
560 | self.completion_option = wx.CheckBox(self, -1, "Scintilla Completion") | |
561 | self.completion_option.SetValue(False) |
|
561 | #self.completion_option.SetValue(False) | |
562 | self.background_option = wx.CheckBox(self, -1, "White Background") |
|
562 | self.background_option = wx.CheckBox(self, -1, "White Background") | |
563 | self.background_option.SetValue(False) |
|
563 | #self.background_option.SetValue(False) | |
|
564 | ||||
|
565 | self.options={'completion':{'value':'IPYTHON', | |||
|
566 | 'checkbox':self.completion_option,'STC':True,'IPYTHON':False, | |||
|
567 | 'setfunc':self.text_ctrl.setCompletionMethod}, | |||
|
568 | 'background_color':{'value':'BLACK', | |||
|
569 | 'checkbox':self.background_option,'WHITE':True,'BLACK':False, | |||
|
570 | 'setfunc':self.text_ctrl.setBackgroundColor}, | |||
|
571 | } | |||
|
572 | self.reloadOptions(self.options) | |||
564 |
|
573 | |||
565 | self.text_ctrl.Bind(wx.EVT_KEY_DOWN, self.keyPress) |
|
574 | self.text_ctrl.Bind(wx.EVT_KEY_DOWN, self.keyPress) | |
566 | self.completion_option.Bind(wx.EVT_CHECKBOX, self.evtCheckOptionCompletion) |
|
575 | self.completion_option.Bind(wx.EVT_CHECKBOX, self.evtCheckOptionCompletion) | |
@@ -765,19 +774,48 b' class IPShellWidget(wx.Panel):' | |||||
765 | #------------------------ Option Section --------------------------------- |
|
774 | #------------------------ Option Section --------------------------------- | |
766 | def evtCheckOptionCompletion(self, event): |
|
775 | def evtCheckOptionCompletion(self, event): | |
767 | if event.IsChecked(): |
|
776 | if event.IsChecked(): | |
768 |
self. |
|
777 | self.options['completion']['value']='STC' | |
769 | else: |
|
778 | else: | |
770 |
self. |
|
779 | self.options['completion']['value']='IPYTHON' | |
|
780 | self.text_ctrl.setCompletionMethod(self.options['completion']['value']) | |||
|
781 | self.updateOptionTracker('completion', | |||
|
782 | self.options['completion']['value']) | |||
771 | self.text_ctrl.SetFocus() |
|
783 | self.text_ctrl.SetFocus() | |
772 |
|
784 | |||
773 | def evtCheckOptionBackgroundColor(self, event): |
|
785 | def evtCheckOptionBackgroundColor(self, event): | |
774 | if event.IsChecked(): |
|
786 | if event.IsChecked(): | |
775 |
self. |
|
787 | self.options['background_color']['value']='WHITE' | |
776 | else: |
|
788 | else: | |
777 |
self. |
|
789 | self.options['background_color']['value']='BLACK' | |
|
790 | self.text_ctrl.setBackgroundColor(self.options['background_color']['value']) | |||
|
791 | self.updateOptionTracker('background_color', | |||
|
792 | self.options['background_color']['value']) | |||
778 | self.text_ctrl.SetFocus() |
|
793 | self.text_ctrl.SetFocus() | |
779 |
|
|
794 | ||
|
795 | def getOptions(self): | |||
|
796 | return self.options | |||
|
797 | ||||
|
798 | def reloadOptions(self,options): | |||
|
799 | self.options = options | |||
|
800 | for key in self.options.keys(): | |||
|
801 | value = self.options[key]['value'] | |||
|
802 | self.options[key]['checkbox'].SetValue(self.options[key][value]) | |||
|
803 | self.options[key]['setfunc'](value) | |||
|
804 | ||||
|
805 | ||||
780 | #------------------------ Hook Section ----------------------------------- |
|
806 | #------------------------ Hook Section ----------------------------------- | |
|
807 | def updateOptionTracker(self,name,value): | |||
|
808 | ''' | |||
|
809 | Default history tracker (does nothing) | |||
|
810 | ''' | |||
|
811 | pass | |||
|
812 | ||||
|
813 | def setOptionTrackerHook(self,func): | |||
|
814 | ''' | |||
|
815 | Define a new history tracker | |||
|
816 | ''' | |||
|
817 | self.updateOptionTracker = func | |||
|
818 | ||||
781 | def updateHistoryTracker(self,command_line): |
|
819 | def updateHistoryTracker(self,command_line): | |
782 | ''' |
|
820 | ''' | |
783 | Default history tracker (does nothing) |
|
821 | Default history tracker (does nothing) |
@@ -7,7 +7,7 b' import wx.aui' | |||||
7 | from wx.lib.wordwrap import wordwrap |
|
7 | from wx.lib.wordwrap import wordwrap | |
8 |
|
8 | |||
9 | #used for ipython GUI objects |
|
9 | #used for ipython GUI objects | |
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 | __version__ = 0.8 |
|
13 | __version__ = 0.8 | |
@@ -41,7 +41,10 b' class MyFrame(wx.Frame):' | |||||
41 | self.ipython_panel.setHistoryTrackerHook(self.history_panel.write) |
|
41 | self.ipython_panel.setHistoryTrackerHook(self.history_panel.write) | |
42 | self.ipython_panel.setStatusTrackerHook(self.updateStatus) |
|
42 | self.ipython_panel.setStatusTrackerHook(self.updateStatus) | |
43 | self.ipython_panel.setAskExitHandler(self.OnExitDlg) |
|
43 | self.ipython_panel.setAskExitHandler(self.OnExitDlg) | |
|
44 | self.ipython_panel.setOptionTrackerHook(self.optionSave) | |||
|
45 | self.optionLoad() | |||
44 |
|
46 | |||
|
47 | ||||
45 | self.statusbar = self.createStatus() |
|
48 | self.statusbar = self.createStatus() | |
46 | self.createMenu() |
|
49 | self.createMenu() | |
47 |
|
50 | |||
@@ -66,7 +69,7 b' class MyFrame(wx.Frame):' | |||||
66 | self.Bind(wx.EVT_MENU, self.OnShowHistoryPanel,id=wx.ID_HIGHEST+2) |
|
69 | self.Bind(wx.EVT_MENU, self.OnShowHistoryPanel,id=wx.ID_HIGHEST+2) | |
67 | self.Bind(wx.EVT_MENU, self.OnShowAbout, id=wx.ID_HIGHEST+3) |
|
70 | self.Bind(wx.EVT_MENU, self.OnShowAbout, id=wx.ID_HIGHEST+3) | |
68 | self.Bind(wx.EVT_MENU, self.OnShowAllPanel,id=wx.ID_HIGHEST+6) |
|
71 | self.Bind(wx.EVT_MENU, self.OnShowAllPanel,id=wx.ID_HIGHEST+6) | |
69 |
|
72 | |||
70 | warn_text = 'Hello from IPython and wxPython.\n' |
|
73 | warn_text = 'Hello from IPython and wxPython.\n' | |
71 | warn_text +='Please Note that this work is still EXPERIMENTAL\n' |
|
74 | warn_text +='Please Note that this work is still EXPERIMENTAL\n' | |
72 | warn_text +='It does NOT emulate currently all the IPython functions.\n' |
|
75 | warn_text +='It does NOT emulate currently all the IPython functions.\n' | |
@@ -78,7 +81,27 b' class MyFrame(wx.Frame):' | |||||
78 | ) |
|
81 | ) | |
79 | dlg.ShowModal() |
|
82 | dlg.ShowModal() | |
80 | dlg.Destroy() |
|
83 | dlg.Destroy() | |
81 |
|
84 | |||
|
85 | def optionSave(self, name, value): | |||
|
86 | opt = open('options.conf','w') | |||
|
87 | options = self.ipython_panel.getOptions() | |||
|
88 | for key in options.keys(): | |||
|
89 | opt.write(key + '=' + options[key]['value']+'\n') | |||
|
90 | opt.close() | |||
|
91 | ||||
|
92 | def optionLoad(self): | |||
|
93 | opt = open('options.conf','r') | |||
|
94 | lines = opt.readlines() | |||
|
95 | opt.close() | |||
|
96 | ||||
|
97 | options = self.ipython_panel.getOptions() | |||
|
98 | ||||
|
99 | for line in lines: | |||
|
100 | key = line.split('=')[0] | |||
|
101 | value = line.split('=')[1].replace('\n','') | |||
|
102 | options[key]['value'] = value | |||
|
103 | self.ipython_panel.reloadOptions(options) | |||
|
104 | ||||
82 | def createMenu(self): |
|
105 | def createMenu(self): | |
83 | """local method used to create one menu bar""" |
|
106 | """local method used to create one menu bar""" | |
84 |
|
107 |
General Comments 0
You need to be logged in to leave comments.
Login now