Application console for Tkinter program?

Christian Gollwitzer auriocus at gmx.de
Sun Mar 6 04:23:14 EST 2016


Am 05.03.16 um 22:16 schrieb Terry Reedy:
> Not now. A console is a REPL + text display to read from and print to.
> The actual IDLE REPL is PyShell.ModifiedInterpreter, which subclasses
> stdlib code.InteractiveInterpreter.  Most of the additions are for
> interacting with the subprocess that runs user code.  You should start
> instead with the base class.
>
> The Shell text display is a subclass of a subclass of a class that
> contains a subclass of Toplevel with the complete IDLE Menu and a Text
> widget wrapper.  Again, this is too much baggage for an application
> console.
>
> The idlelib ColorDelegator syntax highlighter can be reused with a Text
> instance.  See turtledemo.__main__ for an example.  I don't know if (or
> how) IDLE's autocompletion modules could be reused in their current
> state.  I believe Shell's history 'list' consists of the statements in
> the Text instance prefixed by the '>>> ' prompt.

Thanks! I'll try to browse my way through the source code, these details 
help a lot. I still haven't understood the difference between exec() and 
eval(). I understand that for statements you want to exec them, for 
expressions you eval it and print the result. When the user has entered 
code, how does the REPL know if it should be eval'ed or exec'ed? I 
assume that you don't try to parse the Python code manually to find this 
out? Or you try to eval(), and if it doesn't compile, you exec()?

	Christian




More information about the Python-list mailing list