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