6

I'm creating Tkinter GUI and want to add windows CMD into tkinter widget. I would like to use console to connect to database. I did some research and found only pyconsole module, but with some bugs:

  • cls is not going to do what you expect;
  • edit is not going to show an editor (try start edit instead);
  • prompt anything fails too;
  • the color command is not implemented;
  • the great ^C isn't supported too (it actually copies text, instead of interrupting a process).

Especially ^C command ommited is huge limitation for sql scripts i want to run.

I'm able to open console like this:

Popen(["cmd.exe"], creationflags=CREATE_NEW_CONSOLE)

But with this approach I don't know how to interact with the GUI (is it even possible?)

Also my Text widget can read output from command line, but I need to also write in that command line, not just read it...

Is there a possibility to get regular CMD into Tkinter widget, which will react with the rest of widgets in GUI?

Desired behaviour would be CMD console on the right side as you can see on picture below (in tkinter window), that would interact with the Listbox on the left. I'm not looking for exact code (that's why no my code stated here), but method/solution how to put CMD into tkinter.

Photo: enter image description here enter image description here

Thanks

Honza

j_4321
  • 15,431
  • 3
  • 34
  • 61
zajcev
  • 81
  • 7
  • Does this answer your question? [build cmd into Tkinter window](https://stackoverflow.com/questions/5999627/build-cmd-into-tkinter-window) – user26742873 Jul 06 '20 at 13:14

1 Answers1

1

I think you can use an Entry to input the commands you want to execute. Then you can use subprocess.run and subprocess.Popen to execute the commands, and a Text or even better a tkinter.scrolledtext.ScrolledText widget to show the results.

gms
  • 325
  • 3
  • 9