idlelib re-use
Christian Gollwitzer
auriocus at gmx.de
Sat Jan 30 17:03:55 EST 2021
Am 28.01.21 um 20:57 schrieb Terry Reedy:
> On 1/28/2021 5:53 AM, Robin Becker wrote:
>> I googled in vain for instances where parts of idlelib are re-used in
>> a simplistic way. I would like to use the editor functionality in a
>> tkinter window and also probably run code in a subprocess.
>>
>> Are there any examples around that do these sorts of things?
>
> turtledemo reuses IDLE's colorizer and read-only textviews. I have seen
> occasional hints on stackoverflow of other such uses.
>
> One barrier to reuse is that the parts are highly interconnected, with
> numerous import loops. (Changing the form of some imports from 'import
> x' to 'from x import y' can make IDLE startup fail.) Some objects, like
> EditorWindow, are too monolithic. You cannot put a toplevel inside
> another toplevel.
Yes, you can. There are two possiblities, the one is converting the
toplevel into a frame with wm_forget(), after which you can simply pack
it into another frame. The second one is configuring a frame as a
container, which allows to even embed a window from a foreign
application. I'm not sure this works on all platforms, though.
Christian
More information about the Python-list
mailing list