##// END OF EJS Templates
More docstring work.
More docstring work.

File last commit:

r1458:4eaf1646
r1459:8d08214a
Show More
ipythonx.py
78 lines | 2.0 KiB | text/x-python | PythonLexer
Gael Varoquaux
Add demo app. Add callback for exit to the ipython0 code.
r1391 """
Entry point for a simple application giving a graphical frontend to
ipython.
"""
import wx
from wx_frontend import WxController
Gael Varoquaux
First cut of subprocess execution with redirection of stdin/stdout.
r1437 import __builtin__
Gael Varoquaux
Add demo app. Add callback for exit to the ipython0 code.
r1391
Gael Varoquaux
Fixed a race-condition in subprocess execution....
r1438 class IPythonXController(WxController):
Gael Varoquaux
Add demo app. Add callback for exit to the ipython0 code.
r1391 """ Sub class of WxController that adds some application-specific
bindings.
"""
Gael Varoquaux
Proper redirection of keystrokes to subprocesses.
r1450 debug = False
Gael Varoquaux
Add demo app. Add callback for exit to the ipython0 code.
r1391 def __init__(self, *args, **kwargs):
WxController.__init__(self, *args, **kwargs)
self.ipython0.ask_exit = self.do_exit
def _on_key_down(self, event, skip=True):
# Intercept Ctrl-D to quit
if event.KeyCode == ord('D') and event.ControlDown() and \
Gael Varoquaux
First cut of subprocess execution with redirection of stdin/stdout.
r1437 self.get_current_edit_buffer()=='' and \
gvaroquaux
Make process execution work under windows.
r1449 self._input_state == 'readline':
Gael Varoquaux
Add demo app. Add callback for exit to the ipython0 code.
r1391 wx.CallAfter(self.ask_exit)
else:
WxController._on_key_down(self, event, skip=skip)
def ask_exit(self):
""" Ask the user whether to exit.
"""
self.write('\n')
self.capture_output()
self.ipython0.shell.exit()
self.release_output()
wx.Yield()
if not self.ipython0.exit_now:
Gael Varoquaux
More tests of the frontend. Improve the ease of testing.
r1458 self.new_prompt(self.input_prompt_template.substitute(
number=self.last_result['number'] + 1))
Gael Varoquaux
Add demo app. Add callback for exit to the ipython0 code.
r1391
def do_exit(self):
""" Exits the interpreter, kills the windows.
"""
WxController.do_exit(self)
self.release_output()
Gael Varoquaux
Clean up exit code.
r1392 wx.CallAfter(wx.Exit)
Gael Varoquaux
Add demo app. Add callback for exit to the ipython0 code.
r1391
Gael Varoquaux
Fixed a race-condition in subprocess execution....
r1438 class IPythonX(wx.Frame):
""" Main frame of the IPythonX app.
Gael Varoquaux
Add demo app. Add callback for exit to the ipython0 code.
r1391 """
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, id, title, size=(300,250))
self._sizer = wx.BoxSizer(wx.VERTICAL)
Gael Varoquaux
Fixed a race-condition in subprocess execution....
r1438 self.shell = IPythonXController(self)
Gael Varoquaux
Add demo app. Add callback for exit to the ipython0 code.
r1391 self._sizer.Add(self.shell, 1, wx.EXPAND)
self.SetSizer(self._sizer)
self.SetAutoLayout(1)
self.Show(True)
def main():
app = wx.PySimpleApp()
Gael Varoquaux
Fixed a race-condition in subprocess execution....
r1438 frame = IPythonX(None, wx.ID_ANY, 'IPythonX')
Gael Varoquaux
Add demo app. Add callback for exit to the ipython0 code.
r1391 frame.shell.SetFocus()
frame.shell.app = app
frame.SetSize((680, 460))
app.MainLoop()
if __name__ == '__main__':
main()