Re: idlelib re-use

2021-01-30 Thread Christian Gollwitzer

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
--
https://mail.python.org/mailman/listinfo/python-list


Re: idlelib re-use

2021-01-29 Thread Robin Becker

Thanks,

On 28/01/2021 19:57, Terry Reedy wrote:

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 I found this out trying to reuse the editor window and shell.

Another, for those thinking long term, is that implementation modules in idlelib are defined as private since 3.6 
(PEP-434, idlelib.__init__).  I pushed for this in order to be able to refactor to reduce interconnections, and break 
some things apart, and also to switch to ttk widgets.


For instance, breaking EditorFrame apart from EditorWindow would allow me to put multiple editors on multiple tabs of a 
notebook in an application window.  It would also allow others to put an editor window in their tkinter window.


+1
--
Robin Becker

--
https://mail.python.org/mailman/listinfo/python-list


Re: idlelib re-use

2021-01-28 Thread 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.


Another, for those thinking long term, is that implementation modules in 
idlelib are defined as private since 3.6 (PEP-434, idlelib.__init__).  I 
pushed for this in order to be able to refactor to reduce 
interconnections, and break some things apart, and also to switch to ttk 
widgets.


For instance, breaking EditorFrame apart from EditorWindow would allow 
me to put multiple editors on multiple tabs of a notebook in an 
application window.  It would also allow others to put an editor window 
in their tkinter window.



--
Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list


idlelib re-use

2021-01-28 Thread Robin Becker
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?
--
Robin Becker

--
https://mail.python.org/mailman/listinfo/python-list