1

I've been trying to do this for ages and can't find a way to do this, even though I have heard it is possible.

I want to be able to insert the python console into any tkinter widget (eg. frame, canvas, etc.).

How can I do this? Any help would be greatly appreciated.

P.S. This is not a duplicate. I do not want to redirect stdout to tkinter text as that doesn't work in while True loops. I need to EMBED the console in tkinter.

Andoo
  • 734
  • 6
  • 22
  • @2875563 This is not a duplicate. I want to embed the console, not redirect stdout. – Andoo Jun 15 '19 at 11:54
  • Like the console in idle? – Legorooj Jun 15 '19 at 12:45
  • Preferably like the python interpreter (the black console), but if idle is only what is possible, than that will have to work. – Andoo Jun 16 '19 at 10:44
  • I don't know exactly how to do it, but i do know that IDLE is coded in tkinter. Look in idlelib, all of the source code is there. – Legorooj Jun 16 '19 at 10:49
  • I tried that but because I am putting a tkinter fork (IDLE) into a tkinter window, things like `while True` loops don't seem to work. – Andoo Jun 16 '19 at 19:09
  • Hmm. I will look into this, and come back when I find something. – Legorooj Jun 18 '19 at 08:31
  • Will a custom `tk.Text` widget that imitates idle work? You could embed that pretty much anywhere. – Legorooj Jun 25 '19 at 11:03
  • Look into the `code` module, it might help, and is included in the standard lib, and is the interface to the pyconsole that idle uses. – Legorooj Jun 25 '19 at 12:16

0 Answers0