[Idle-dev] Embedding IDLE

Guido van Rossum guido@python.org
Fri, 24 Mar 2000 17:46:16 -0500


> Here are some suggestions to facilitate embedding IDLE as part of
> another Tkinter application.
> 
> I work on a molecular visualization program that is user extendable in
> Python.  I want to be able to start IDLE from this program.  IDLE will
> run in the same Python interpretter as the molecular visualization program.
> 
> To start an IDLE shell window within the molecular visualization program
> IDLE should not do some of the steps it does when started standalone:
> 
> 1) Don't do command-line argument parsing
> 2) Don't start the Tkinter event loop
> 3) Don't call Tkinter quit() when the last IDLE window is closed
> 4) Don't reset Tkinter _default_root to None
> 
> To achieve 1) and 2) the IDLE 0.5 shell window initialization code in
> PyShell.py main() needs to be separated out from the command-line argument
> parsing and event loop start-up.  This just involves packaging about 10
> lines of code in a separate routine.
> 
> When the last IDLE window closes, the FileList close_edit() method in
> FileList.py calls Tkinter quit() exitting the event loop.  This should
> only be done if the PyShell.py main() routine called Tkinter mainloop().
> 
> In the PyShell class the begin() routine sets Tkinter._default_root = None.
> I guess this is so that code run in IDLE sees a clean Tkinter.  This should
> not be done if IDLE is running within another Tkinter application as it can
> break the graphical interface of that application.  The _default_root = None
> code could be moved to PyShell.py main().  This changes the behaviour of
> IDLE, since Tkinter _default_root will then only be set once when starting
> IDLE standalone, instead of each time a PyShell is created.

All good suggestions -- we'll work on these!

> The molecular visualization code wants to redisplay the IDLE shell window
> if the user asks for it a second time.  It would be helpful to have a
> method of the IDLE EditorWindow class to determine if the window has been
> closed, so I don't try to raise a destroyed window.

I think you can already do this, using the open_shell() method of the
PyShellFileList class defined in PyShell.py?  Or do I misunderstand
what you want?

--Guido van Rossum (home page: http://www.python.org/~guido/)