From 0122992cab79fb94b76233d6a8954bcdcf6b1cb0 2006-01-09 06:57:40 From: fperez Date: 2006-01-09 06:57:40 Subject: [PATCH] Arnd's wxversion support. --- diff --git a/IPython/Shell.py b/IPython/Shell.py index 7e58fb3..88f7e85 100644 --- a/IPython/Shell.py +++ b/IPython/Shell.py @@ -4,7 +4,7 @@ All the matplotlib support code was co-developed with John Hunter, matplotlib's author. -$Id: Shell.py 994 2006-01-08 08:29:44Z fperez $""" +$Id: Shell.py 998 2006-01-09 06:57:40Z fperez $""" #***************************************************************************** # Copyright (C) 2001-2006 Fernando Perez @@ -668,6 +668,26 @@ class IPShellWX(threading.Thread): def __init__(self,argv=None,user_ns=None,user_global_ns=None, debug=1,shell_class=MTInteractiveShell): + self.IP = make_IPython(argv,user_ns=user_ns, + user_global_ns=user_global_ns, + debug=debug, + shell_class=shell_class, + on_kill=[self.wxexit]) + + wantedwxversion=self.IP.rc.wxversion + if wantedwxversion!="0": + try: + import wxversion + except ImportError: + error('The wxversion module is needed for WX version selection') + else: + try: + wxversion.select(wantedwxversion) + except: + self.IP.InteractiveTB() + error('Requested wxPython version %s could not be loaded' % + wantedwxversion) + import wxPython.wx as wx threading.Thread.__init__(self) @@ -677,11 +697,7 @@ class IPShellWX(threading.Thread): # Allows us to use both Tk and GTK. self.tk = get_tk() - self.IP = make_IPython(argv,user_ns=user_ns, - user_global_ns=user_global_ns, - debug=debug, - shell_class=shell_class, - on_kill=[self.wxexit]) + # HACK: slot for banner in self; it will be passed to the mainloop # method only and .run() needs it. The actual value will be set by # .mainloop(). diff --git a/IPython/UserConfig/ipythonrc b/IPython/UserConfig/ipythonrc index ed4e75a..b2b1629 100644 --- a/IPython/UserConfig/ipythonrc +++ b/IPython/UserConfig/ipythonrc @@ -1,5 +1,5 @@ # -*- Mode: Shell-Script -*- Not really, but shows comments correctly -# $Id: ipythonrc 990 2006-01-04 06:59:02Z fperez $ +# $Id: ipythonrc 998 2006-01-09 06:57:40Z fperez $ #*************************************************************************** # @@ -330,6 +330,16 @@ xmode Context multi_line_specials 1 +# wxversion: request a specific wxPython version (used for -wthread) + +# Set this to the value of wxPython you want to use, but note that this +# feature requires you to have the wxversion Python module to work. If you +# don't have the wxversion module (try 'import wxversion' at the prompt to +# check) or simply want to leave the system to pick up the default, leave this +# variable at 0. + +wxversion 0 + #--------------------------------------------------------------------------- # Section: Readline configuration (readline is not available for MS-Windows) diff --git a/IPython/__init__.py b/IPython/__init__.py index 37754e7..2dfc1a5 100644 --- a/IPython/__init__.py +++ b/IPython/__init__.py @@ -27,7 +27,7 @@ IPython tries to: IPython requires Python 2.2 or newer. -$Id: __init__.py 775 2005-09-01 20:24:59Z fperez $""" +$Id: __init__.py 998 2006-01-09 06:57:40Z fperez $""" #***************************************************************************** # Copyright (C) 2001-2004 Fernando Perez. @@ -38,8 +38,8 @@ $Id: __init__.py 775 2005-09-01 20:24:59Z fperez $""" # Enforce proper version requirements import sys -if sys.version[0:3] < '2.2': - raise ImportError, 'Python Version 2.2 or above is required.' +if sys.version[0:3] < '2.3': + raise ImportError, 'Python Version 2.3 or above is required.' # Define what gets imported with a 'from IPython import *' __all__ = ['deep_reload','genutils','ultraTB','DPyGetOpt','Itpl','hooks', diff --git a/IPython/ipmaker.py b/IPython/ipmaker.py index cfff7f5..fd316f6 100644 --- a/IPython/ipmaker.py +++ b/IPython/ipmaker.py @@ -6,7 +6,7 @@ Requires Python 2.1 or better. This file contains the main make_IPython() starter function. -$Id: ipmaker.py 994 2006-01-08 08:29:44Z fperez $""" +$Id: ipmaker.py 998 2006-01-09 06:57:40Z fperez $""" #***************************************************************************** # Copyright (C) 2001-2006 Fernando Perez. @@ -159,6 +159,7 @@ object? -> Details about 'object'. ?object also works, ?? prints more. 'separate_out2|so2=s xmode=s wildcards_case_sensitive! ' 'magic_docstrings system_verbose! ' 'multi_line_specials! ' + 'wxversion=s ' 'autoedit_syntax!') # Options that can *only* appear at the cmd line (not in rcfiles). @@ -222,6 +223,7 @@ object? -> Details about 'object'. ?object also works, ?? prints more. Version = 0, xmode = 'Verbose', wildcards_case_sensitive = 1, + wxversion = '0', magic_docstrings = 0, # undocumented, for doc generation ) diff --git a/IPython/usage.py b/IPython/usage.py index 93f30c3..87a1c2f 100644 --- a/IPython/usage.py +++ b/IPython/usage.py @@ -6,7 +6,7 @@ # the file COPYING, distributed as part of this software. #***************************************************************************** -# $Id: usage.py 990 2006-01-04 06:59:02Z fperez $ +# $Id: usage.py 998 2006-01-09 06:57:40Z fperez $ from IPython import Release __author__ = '%s <%s>' % Release.authors['Fernando'] @@ -67,6 +67,11 @@ SPECIAL THREADING OPTIONS essentially the same functionality, respectively for GTK, QT and WXWidgets (via their Python interfaces). + Note that with -wthread, you can additionally use the -wxversion + option to request a specific version of wx to be used. This + requires that you have the 'wxversion' Python module installed, + which is part of recent wxPython distributions. + If -pylab is given, IPython loads special support for the mat- plotlib library (http://matplotlib.sourceforge.net), allowing interactive usage of any of its backends as defined in the @@ -380,6 +385,11 @@ REGULAR OPTIONS -Version Print version information and exit. + -wxversion + Select a specific version of wxPython (used in conjunction with + -wthread). Requires the wxversion module, part of recent + wxPython distributions. + -xmode Mode for exception reporting. The valid modes are Plain, Con- text, and Verbose. diff --git a/doc/ChangeLog b/doc/ChangeLog index fe004a3..e6f0c39 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,5 +1,10 @@ 2006-01-08 Fernando Perez + * IPython/Shell.py (IPShellWX.__init__): add support for WXPython + version selection (new -wxversion command line and ipythonrc + parameter). Patch contributed by Arnd Baecker + . + * IPython/iplib.py (embed_mainloop): fix tab-completion in embedded instances, for variables defined at the interactive prompt of the embedded ipython. Reported by Arnd. diff --git a/doc/ipython.1 b/doc/ipython.1 index b938d8a..14d9a88 100644 --- a/doc/ipython.1 +++ b/doc/ipython.1 @@ -50,6 +50,12 @@ three provide essentially the same functionality, respectively for GTK, QT and WXWidgets (via their Python interfaces). .br .sp 1 +Note that with \-wthread, you can additionally use the \-wxversion option to +request a specific version of wx to be used. This requires that you have the +'wxversion' Python module installed, which is part of recent wxPython +distributions. +.br +.sp 1 If \-pylab is given, IPython loads special support for the matplotlib library (http://matplotlib.sourceforge.net), allowing interactive usage of any of its backends as defined in the user's .matplotlibrc file. It automatically @@ -357,6 +363,11 @@ have in your personal files. .B \-Version Print version information and exit. .TP +.B -wxversion +Select a specific version of wxPython (used in conjunction with +\-wthread). Requires the wxversion module, part of recent wxPython +distributions. +.TP .B \-xmode Mode for exception reporting. The valid modes are Plain, Context, and Verbose. diff --git a/doc/manual_base.lyx b/doc/manual_base.lyx index ed250de..74f0a9f 100644 --- a/doc/manual_base.lyx +++ b/doc/manual_base.lyx @@ -164,6 +164,12 @@ Offer a flexible framework which can be used as the base environment for other systems with Python as the underlying language. Specifically scientific environments like Mathematica, IDL and Matlab inspired its design, but similar ideas can be useful in many fields. +\layout Enumerate + +Allow interactive testing of threaded graphical toolkits. + IPython has support for interactive, non-blocking control of GTK, Qt and + WX applications via special threading flags. + The normal Python shell can only do this for Tkinter applications. \layout Subsection Main features @@ -176,7 +182,26 @@ Dynamic object introspection. \family typewriter ? \family default -'). +', and using ` +\family typewriter +?? +\family default +' provides additional detail). +\layout Itemize + +Searching through modules and namespaces with ` +\family typewriter +* +\family default +' wildcards, both when using the ` +\family typewriter +? +\family default +' system and via the +\family typewriter +%psearch +\family default + command. \layout Itemize Completion in the local namespace, by typing TAB at the prompt. @@ -207,10 +232,6 @@ Complete system shell access. !! captures shell output into python variables for further use. \layout Itemize -All calls to the system (via aliases or via !) have their standard output/error - automatically stored as strings, and also available as lists. -\layout Itemize - Background execution of Python commands in a separate thread. IPython has an internal job manager called \family typewriter @@ -255,15 +276,35 @@ Filesystem navigation, via a magic ) for fast access to frequently visited directories. \layout Itemize +A lightweight persistence framework via the +\family typewriter +%store +\family default + command, which allows you to save arbitrary Python variables. + These get restored automatically when your session restarts. +\layout Itemize + Automatic indentation (optional) of code as you type (through the readline library). \layout Itemize Macro system for quickly re-executing multiple lines of previous input with a single name. + Macros can be stored persistently via +\family typewriter +%store +\family default + and edited via +\family typewriter +%edit +\family default +. + \layout Itemize Session logging (you can then later use these logs as code in your programs). + Logs can optionally timestamp all input, and also store session output + (marked as comments, so the log remains valid Python source code). \layout Itemize Session restoring: logs can be replayed to restore a previous session to @@ -405,12 +446,10 @@ Portability and Python requirements \series bold Python requirements: \series default -IPython works with Python version 2.2 or newer. - It has been tested with Python 2.4 and no problems have been reported. - Support for Python 2.1 hasn't been recently tested, since I don't have access - to it on any of my systems. - But I suspect there may be some problems with Python 2.1, because some of - the newer code may use 2.2 features. +IPython requires with Python version 2.3 or newer. + If you are still using Python 2.2 and can not upgrade, the last version + of IPython which worked with Python 2.2 was 0.6.15, so you will have to use + that. \layout Standard IPython is developed under @@ -465,12 +504,22 @@ Windows 9x support is present, and has been reported to work fine (at least on WinME). \layout Standard -Please note, however, that I have very little access to and experience with - Windows development. - For this reason, Windows-specific bugs tend to linger far longer than I - would like, and often I just can't find a satisfactory solution. - If any Windows user wants to join in with development help, all hands are - always welcome. +Note, that I have very little access to and experience with Windows development. + However, an excellent group of Win32 users (led by Ville Vainio), consistenly + contribute bugfixes and platform-specific enhancements, so they more than + make up for my deficiencies on that front. + In fact, Win32 users report using IPython as a system shell (see Sec.\SpecialChar ~ + +\begin_inset LatexCommand \ref{sec:IPython-as-shell} + +\end_inset + + for details), as it offers a level of control and features which the default + +\family typewriter +cmd.exe +\family default + doesn't provide. \layout Subsection Location @@ -481,7 +530,7 @@ IPython is generously hosted at \end_inset - by the SciPy project. + by the Enthought, Inc and the SciPy project. This site offers downloads, subversion access, mailing lists and a bug tracking system. I am very grateful to Enthought ( @@ -2476,6 +2525,21 @@ one \labelwidthstring 00.00.0000 \SpecialChar ~ + Note that with +\family typewriter +-wthread +\family default +, you can additionally use the -wxversion option to request a specific version + of wx to be used. + This requires that you have the +\family typewriter +wxversion +\family default + Python module installed, which is part of recent wxPython distributions. +\layout List +\labelwidthstring 00.00.0000 + +\SpecialChar ~ If \family typewriter -pylab @@ -3452,7 +3516,24 @@ IPYTHONDIR \family typewriter \series bold --xmode +-wxversion\SpecialChar ~ +: +\family default +\series default + Select a specific version of wxPython (used in conjunction with +\family typewriter +-wthread +\family default +). + Requires the wxversion module, part of recent wxPython distributions +\layout List +\labelwidthstring 00.00.0000 + + +\family typewriter +\series bold +-xmode\SpecialChar ~ + \series default : \family default @@ -6778,6 +6859,11 @@ from IPython.Extensions.PhysicalQInteractive import * import IPython.Extensions.PhysicalQInput \layout Section + +\begin_inset LatexCommand \label{sec:IPython-as-shell} + +\end_inset + IPython as a system shell \layout Standard