build cmd into Tkinter window

后端 未结 2 937
南笙
南笙 2021-01-22 11:07

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 =         


        
相关标签:
2条回答
  • 2021-01-22 11:22

    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.

    0 讨论(0)
  • 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.

    0 讨论(0)
提交回复
热议问题