Setting win32 console title from Python

runes rune.strand at gmail.com
Thu Apr 28 06:30:15 EDT 2005


Hi,
I'm trying to set the title of the console window (CMD.EXE) in Windows.
I want it set to the basename of the current directory and it should
stay after the script has finished.

Now, the console title is easily set with the DOS-command 'title
NewTitle'. But I'd like to do this from a Python script.

os.system('title NewTitle') will not do, because it spawns a new
process.

win32api.SetConsoleTitle('NewTitle') will not do either, because the
NewTitle is reset as soon as the script finishes.

Chris Gonnerman's WConio
<http://newcenturycomputers.net/projects/wconio.html>
has a settitle() method and
WConio.settitle("NewTitle") does what I want, but not under CMD.EXE,
only COMMAND.EXE.

Any ideas?




More information about the Python-list mailing list