[IPython-dev] wxPython console

Emmanuel Bacry emmanuel.bacry@polytechnique...
Thu Nov 3 13:21:47 CDT 2011



Thomas Kluyver-2 wrote:
> 
> On 3 November 2011 13:51, Emmanuel Bacry
> <emmanuel.bacry@polytechnique.fr>wrote:
> 
>> You mean use it directly within a wx main loop right ?
>>
> 
> Yes - it's just Python methods that you call to run code and so on. I'm
> assuming your widget takes care of actually letting the user type things
> in.
> 
> 
>> Yes I got that already, however how do I redirect output ?
>>
> 
> In Python, there are two kinds of output: firstly from "print x", for
> which
> you can simply redirect stdout - replace sys.stdout with an object with a
> .write() method, which will capture strings written to it and display them
> in your console.
> 
> Secondly, if you simply enter "x" at a prompt, IPython displays the value
> of x at an "Out [n]:" prompt. In such cases, Python calls sys.displayhook.
> This is called with the object itself, rather than its repr, so you can
> produce more complex displays. This is how we pretty-print datastructures,
> and also how the notebook can display rich objects like youtube videos.
> Have a look at IPython.core.displayhook to see our implementation of this.
> If you replace the displayhook attribute of an InteractiveShell object, it
> will take care of using that displayhook when you call run_cell.
> 
> OK.
>> For complete : it actually does exactly what happens when I hit the tab
>> key
>> on the ipython console ?
>>
> 
> It provides the machinery to find the completions for a given input. The
> frontend has to take care of catching the tab key (or some other shortcut)
> and applying or displaying the returned completion(s).
> 
> 
This is very clear Thank you

 


Thomas Kluyver-2 wrote:
> 
>> How do I manage multiple lines command ?
>>
> 
> You can use an InputSplitter to determine if another line is acceptable -
> have a look at the code for the terminal frontend:
> https://github.com/ipython/ipython/blob/master/IPython/frontend/terminal/interactiveshell.py#L318
> 
Will it tell me what is the level of indentation I need for an eventual
acceptable line ?


Thomas Kluyver-2 wrote:
> > Le me be clear : how do I know a command is not complete  so I should
> print
>> a prompt with a tab ?
>> Is there a method that deals with managing all that for me ?
>>
> 
> I'm not quite sure what you mean with this part, but hopefully what I've
> described above will help.
> 
Yes it does.

Thank you again

Emmanuel


-- 
View this message in context: http://old.nabble.com/wxPython-console-tp32057061p32775050.html
Sent from the IPython - Development mailing list archive at Nabble.com.



More information about the IPython-dev mailing list