##// END OF EJS Templates
added a "warning experimental work" at startup
laurent.dufrechou -
Show More
@@ -1,195 +1,205 b''
1 #!/usr/bin/python
1 #!/usr/bin/python
2 # -*- coding: iso-8859-15 -*-
2 # -*- coding: iso-8859-15 -*-
3
3
4 import wx.aui
4 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 *
9 from ipython_history import *
9 from ipython_history import *
10
10
11 __version__ = 0.8
11 __version__ = 0.8
12 __author__ = "Laurent Dufrechou"
12 __author__ = "Laurent Dufrechou"
13 __email__ = "laurent.dufrechou _at_ gmail.com"
13 __email__ = "laurent.dufrechou _at_ gmail.com"
14 __license__ = "BSD"
14 __license__ = "BSD"
15
15
16 #-----------------------------------------
16 #-----------------------------------------
17 # Creating one main frame for our
17 # Creating one main frame for our
18 # application with movables windows
18 # application with movables windows
19 #-----------------------------------------
19 #-----------------------------------------
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", pos=wx.DefaultPosition,
23 def __init__(self, parent=None, id=-1, title="WxIPython", pos=wx.DefaultPosition,
24 size=(800, 600), style=wx.DEFAULT_FRAME_STYLE):
24 size=(800, 600), style=wx.DEFAULT_FRAME_STYLE):
25 wx.Frame.__init__(self, parent, id, title, pos, size, style)
25 wx.Frame.__init__(self, parent, id, title, pos, size, style)
26 self._mgr = wx.aui.AuiManager()
26 self._mgr = wx.aui.AuiManager()
27
27
28 # notify PyAUI which frame to use
28 # notify PyAUI which frame to use
29 self._mgr.SetManagedWindow(self)
29 self._mgr.SetManagedWindow(self)
30
30
31 #create differents panels and make them persistant
31 #create differents panels and make them persistant
32 self.history_panel = IPythonHistoryPanel(self)
32 self.history_panel = IPythonHistoryPanel(self)
33
33
34 self.ipython_panel = WxIPythonViewPanel(self,self.OnExitDlg,
34 self.ipython_panel = WxIPythonViewPanel(self,self.OnExitDlg,
35 background_color = "BLACK")
35 background_color = "BLACK")
36
36
37 #self.ipython_panel = WxIPythonViewPanel(self,self.OnExitDlg,
37 #self.ipython_panel = WxIPythonViewPanel(self,self.OnExitDlg,
38 # background_color = "WHITE")
38 # background_color = "WHITE")
39
39
40 self.ipython_panel.setHistoryTrackerHook(self.history_panel.write)
40 self.ipython_panel.setHistoryTrackerHook(self.history_panel.write)
41 self.ipython_panel.setStatusTrackerHook(self.updateStatus)
41 self.ipython_panel.setStatusTrackerHook(self.updateStatus)
42
42
43 self.statusbar = self.createStatus()
43 self.statusbar = self.createStatus()
44 self.createMenu()
44 self.createMenu()
45
45
46 ########################################################################
46 ########################################################################
47 ### add the panes to the manager
47 ### add the panes to the manager
48 # main panels
48 # main panels
49 self._mgr.AddPane(self.ipython_panel , wx.CENTER, "IPython Shell")
49 self._mgr.AddPane(self.ipython_panel , wx.CENTER, "IPython Shell")
50 self._mgr.AddPane(self.history_panel , wx.RIGHT, "IPython history")
50 self._mgr.AddPane(self.history_panel , wx.RIGHT, "IPython history")
51
51
52 # now we specify some panel characteristics
52 # now we specify some panel characteristics
53 self._mgr.GetPane(self.ipython_panel).CaptionVisible(True);
53 self._mgr.GetPane(self.ipython_panel).CaptionVisible(True);
54 self._mgr.GetPane(self.history_panel).CaptionVisible(True);
54 self._mgr.GetPane(self.history_panel).CaptionVisible(True);
55 self._mgr.GetPane(self.history_panel).MinSize((200,400));
55 self._mgr.GetPane(self.history_panel).MinSize((200,400));
56
56
57
57
58
58
59 # tell the manager to "commit" all the changes just made
59 # tell the manager to "commit" all the changes just made
60 self._mgr.Update()
60 self._mgr.Update()
61
61
62 #self.ipython_panel.run()
63
64 #global event handling
62 #global event handling
65 self.Bind(wx.EVT_CLOSE, self.OnClose)
63 self.Bind(wx.EVT_CLOSE, self.OnClose)
66 self.Bind(wx.EVT_MENU, self.OnClose,id=wx.ID_EXIT)
64 self.Bind(wx.EVT_MENU, self.OnClose,id=wx.ID_EXIT)
67 self.Bind(wx.EVT_MENU, self.OnShowIPythonPanel,id=wx.ID_HIGHEST+1)
65 self.Bind(wx.EVT_MENU, self.OnShowIPythonPanel,id=wx.ID_HIGHEST+1)
68 self.Bind(wx.EVT_MENU, self.OnShowHistoryPanel,id=wx.ID_HIGHEST+2)
66 self.Bind(wx.EVT_MENU, self.OnShowHistoryPanel,id=wx.ID_HIGHEST+2)
69 self.Bind(wx.EVT_MENU, self.OnShowAbout, id=wx.ID_HIGHEST+3)
67 self.Bind(wx.EVT_MENU, self.OnShowAbout, id=wx.ID_HIGHEST+3)
70 self.Bind(wx.EVT_MENU, self.OnShowAllPanel,id=wx.ID_HIGHEST+6)
68 self.Bind(wx.EVT_MENU, self.OnShowAllPanel,id=wx.ID_HIGHEST+6)
69
70 warn_text = 'Hello from IPython and wxPython.\n'
71 warn_text +='Please Note that this work is still EXPERIMENTAL\n'
72 warn_text +='It does NOT emulate currently all the IPython functions.\n'
73
74 dlg = wx.MessageDialog(self,
75 warn_text,
76 'Warning Box',
77 wx.OK | wx.ICON_INFORMATION
78 )
79 dlg.ShowModal()
80 dlg.Destroy()
71
81
72 def createMenu(self):
82 def createMenu(self):
73 """local method used to create one menu bar"""
83 """local method used to create one menu bar"""
74
84
75 mb = wx.MenuBar()
85 mb = wx.MenuBar()
76
86
77 file_menu = wx.Menu()
87 file_menu = wx.Menu()
78 file_menu.Append(wx.ID_EXIT, "Exit")
88 file_menu.Append(wx.ID_EXIT, "Exit")
79
89
80 view_menu = wx.Menu()
90 view_menu = wx.Menu()
81 view_menu.Append(wx.ID_HIGHEST+1, "Show IPython Panel")
91 view_menu.Append(wx.ID_HIGHEST+1, "Show IPython Panel")
82 view_menu.Append(wx.ID_HIGHEST+2, "Show History Panel")
92 view_menu.Append(wx.ID_HIGHEST+2, "Show History Panel")
83 view_menu.AppendSeparator()
93 view_menu.AppendSeparator()
84 view_menu.Append(wx.ID_HIGHEST+6, "Show All")
94 view_menu.Append(wx.ID_HIGHEST+6, "Show All")
85
95
86 about_menu = wx.Menu()
96 about_menu = wx.Menu()
87 about_menu.Append(wx.ID_HIGHEST+3, "About")
97 about_menu.Append(wx.ID_HIGHEST+3, "About")
88
98
89 #view_menu.AppendSeparator()
99 #view_menu.AppendSeparator()
90 #options_menu = wx.Menu()
100 #options_menu = wx.Menu()
91 #options_menu.AppendCheckItem(wx.ID_HIGHEST+7, "Allow Floating")
101 #options_menu.AppendCheckItem(wx.ID_HIGHEST+7, "Allow Floating")
92 #options_menu.AppendCheckItem(wx.ID_HIGHEST+8, "Transparent Hint")
102 #options_menu.AppendCheckItem(wx.ID_HIGHEST+8, "Transparent Hint")
93 #options_menu.AppendCheckItem(wx.ID_HIGHEST+9, "Transparent Hint Fade-in")
103 #options_menu.AppendCheckItem(wx.ID_HIGHEST+9, "Transparent Hint Fade-in")
94
104
95
105
96 mb.Append(file_menu, "File")
106 mb.Append(file_menu, "File")
97 mb.Append(view_menu, "View")
107 mb.Append(view_menu, "View")
98 mb.Append(about_menu, "About")
108 mb.Append(about_menu, "About")
99 #mb.Append(options_menu, "Options")
109 #mb.Append(options_menu, "Options")
100
110
101 self.SetMenuBar(mb)
111 self.SetMenuBar(mb)
102
112
103 def createStatus(self):
113 def createStatus(self):
104 statusbar = self.CreateStatusBar(2, wx.ST_SIZEGRIP)
114 statusbar = self.CreateStatusBar(2, wx.ST_SIZEGRIP)
105 statusbar.SetStatusWidths([-2, -3])
115 statusbar.SetStatusWidths([-2, -3])
106 statusbar.SetStatusText("Ready", 0)
116 statusbar.SetStatusText("Ready", 0)
107 statusbar.SetStatusText("WxIPython "+str(__version__), 1)
117 statusbar.SetStatusText("WxIPython "+str(__version__), 1)
108 return statusbar
118 return statusbar
109
119
110 def updateStatus(self,text):
120 def updateStatus(self,text):
111 states = {'IDLE':'Idle',
121 states = {'IDLE':'Idle',
112 'DO_EXECUTE_LINE':'Send command',
122 'DO_EXECUTE_LINE':'Send command',
113 'WAIT_END_OF_EXECUTION':'Running command',
123 'WAIT_END_OF_EXECUTION':'Running command',
114 'SHOW_DOC':'Showing doc',
124 'SHOW_DOC':'Showing doc',
115 'SHOW_PROMPT':'Showing prompt'}
125 'SHOW_PROMPT':'Showing prompt'}
116 self.statusbar.SetStatusText(states[text], 0)
126 self.statusbar.SetStatusText(states[text], 0)
117
127
118 def OnClose(self, event):
128 def OnClose(self, event):
119 """#event used to close program """
129 """#event used to close program """
120 # deinitialize the frame manager
130 # deinitialize the frame manager
121 self._mgr.UnInit()
131 self._mgr.UnInit()
122 self.Destroy()
132 self.Destroy()
123 event.Skip()
133 event.Skip()
124
134
125 def OnExitDlg(self, event):
135 def OnExitDlg(self, event):
126 dlg = wx.MessageDialog(self, 'Are you sure you want to quit WxIPython',
136 dlg = wx.MessageDialog(self, 'Are you sure you want to quit WxIPython',
127 'WxIPython exit',
137 'WxIPython exit',
128 wx.ICON_QUESTION |
138 wx.ICON_QUESTION |
129 wx.YES_NO | wx.NO_DEFAULT
139 wx.YES_NO | wx.NO_DEFAULT
130 )
140 )
131 if dlg.ShowModal() == wx.ID_YES:
141 if dlg.ShowModal() == wx.ID_YES:
132 dlg.Destroy()
142 dlg.Destroy()
133 self._mgr.UnInit()
143 self._mgr.UnInit()
134 self.Destroy()
144 self.Destroy()
135 dlg.Destroy()
145 dlg.Destroy()
136
146
137 #event to display IPython pannel
147 #event to display IPython pannel
138 def OnShowIPythonPanel(self,event):
148 def OnShowIPythonPanel(self,event):
139 """ #event to display Boxpannel """
149 """ #event to display Boxpannel """
140 self._mgr.GetPane(self.ipython_panel).Show(True)
150 self._mgr.GetPane(self.ipython_panel).Show(True)
141 self._mgr.Update()
151 self._mgr.Update()
142 #event to display History pannel
152 #event to display History pannel
143 def OnShowHistoryPanel(self,event):
153 def OnShowHistoryPanel(self,event):
144 self._mgr.GetPane(self.history_panel).Show(True)
154 self._mgr.GetPane(self.history_panel).Show(True)
145 self._mgr.Update()
155 self._mgr.Update()
146
156
147 def OnShowAllPanel(self,event):
157 def OnShowAllPanel(self,event):
148 """#event to display all Pannels"""
158 """#event to display all Pannels"""
149 self._mgr.GetPane(self.ipython_panel).Show(True)
159 self._mgr.GetPane(self.ipython_panel).Show(True)
150 self._mgr.GetPane(self.history_panel).Show(True)
160 self._mgr.GetPane(self.history_panel).Show(True)
151 self._mgr.Update()
161 self._mgr.Update()
152
162
153 def OnShowAbout(self, event):
163 def OnShowAbout(self, event):
154 # First we create and fill the info object
164 # First we create and fill the info object
155 info = wx.AboutDialogInfo()
165 info = wx.AboutDialogInfo()
156 info.Name = "WxIPython"
166 info.Name = "WxIPython"
157 info.Version = str(__version__)
167 info.Version = str(__version__)
158 info.Copyright = "(C) 2007 Laurent Dufrechou"
168 info.Copyright = "(C) 2007 Laurent Dufrechou"
159 info.Description = wordwrap(
169 info.Description = wordwrap(
160 "A Gui that embbed a multithreaded IPython Shell",
170 "A Gui that embbed a multithreaded IPython Shell",
161 350, wx.ClientDC(self))
171 350, wx.ClientDC(self))
162 info.WebSite = ("http://ipython.scipy.org/", "IPython home page")
172 info.WebSite = ("http://ipython.scipy.org/", "IPython home page")
163 info.Developers = [ "Laurent Dufrechou" ]
173 info.Developers = [ "Laurent Dufrechou" ]
164 licenseText="BSD License.\nAll rights reserved. This program and the accompanying materials are made available under the terms of the BSD which accompanies this distribution, and is available at http://www.opensource.org/licenses/bsd-license.php"
174 licenseText="BSD License.\nAll rights reserved. This program and the accompanying materials are made available under the terms of the BSD which accompanies this distribution, and is available at http://www.opensource.org/licenses/bsd-license.php"
165 info.License = wordwrap(licenseText, 500, wx.ClientDC(self))
175 info.License = wordwrap(licenseText, 500, wx.ClientDC(self))
166
176
167 # Then we call wx.AboutBox giving it that info object
177 # Then we call wx.AboutBox giving it that info object
168 wx.AboutBox(info)
178 wx.AboutBox(info)
169
179
170 #-----------------------------------------
180 #-----------------------------------------
171 #Creating our application
181 #Creating our application
172 #-----------------------------------------
182 #-----------------------------------------
173 class MyApp(wx.PySimpleApp):
183 class MyApp(wx.PySimpleApp):
174 """Creating our application"""
184 """Creating our application"""
175 def __init__(self):
185 def __init__(self):
176 wx.PySimpleApp.__init__(self)
186 wx.PySimpleApp.__init__(self)
177
187
178 self.frame = MyFrame()
188 self.frame = MyFrame()
179 self.frame.Show()
189 self.frame.Show()
180
190
181 #-----------------------------------------
191 #-----------------------------------------
182 #Main loop
192 #Main loop
183 #-----------------------------------------
193 #-----------------------------------------
184 def main():
194 def main():
185 app = MyApp()
195 app = MyApp()
186 app.SetTopWindow(app.frame)
196 app.SetTopWindow(app.frame)
187 app.MainLoop()
197 app.MainLoop()
188
198
189 #if launched as main program run this
199 #if launched as main program run this
190 if __name__ == '__main__':
200 if __name__ == '__main__':
191 import hotshot
201 import hotshot
192 prof = hotshot.Profile("hotshot_edi_stats")
202 prof = hotshot.Profile("hotshot_edi_stats")
193 prof.runcall(main)
203 prof.runcall(main)
194 prof.close()
204 prof.close()
195 #main()
205 #main()
General Comments 0
You need to be logged in to leave comments. Login now