P'sao
P'sao

Reputation: 2996

build cmd into Tkinter window

Hi i was wondering if you could have the comand prompt box pop into the Tkinter window when you start the program? Some thing like:

from Tkinter import *
admin = Tk()
cmd = Cmd(admin)
cmd.pack()
admin.mainloop()

I'm on windows

Upvotes: 4

Views: 9801

Answers (2)

Death_Dealer
Death_Dealer

Reputation: 335

http://tkinter.unpythonic.net/wiki/CmdTkHere is what you want, this is not just opening a cmd window. its embedding cmd.exe into a Tkinter.Frame. And a note here if you rename the python script to ".pyw" extension, the console will be hidden. Except for in a virtual environment's.

Upvotes: 4

rectangletangle
rectangletangle

Reputation: 52911

I don't believe there is any built in console widget. It may be possible to whip up a custom one using the Tkinter Text widget. However, that would take a bit of effort/time.

Another possible option is simply have your program launch command prompt.

Two different ways to launch command prompt on a Windows machine.

import subprocess, os

subprocess.Popen('cmd.exe')

os.system("cmd.exe") 

EDIT:

Unforunetly I don't believe there is any built in widget like that. However I thought of another possible solution, check out the code for the IDLE GUI, it has a console and the GUI portion is entirley written using Tkinter. So you may be able to utelize that code.

Upvotes: 1

Related Questions