5

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

1
  • 1
    I really don't think something like this can be done, I know Tkinter can tap into certain OS specific windows, like color selector or file window, but I doubt there's a way to embed the console. Maybe if you tell us what you're trying to accomplish we can better help you solve your issue. Commented May 14, 2011 at 4:14

2 Answers 2

4

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Dead link: any idea where I might find this?
1

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.

1 Comment

No. You know when you start a python program on windows and a command promkpt like window comes up along with your Tkinter window? i want the cmd like window to be put into the tkinter window or at least customize where the cmd like window will pop up?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.