Reputation: 81
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:
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:
Thanks
Honza
Upvotes: 6
Views: 2782
Reputation: 335
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.
Upvotes: 1