954,525 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How can I specify the size of the python command line window in my code?

I am making a text adventure and would like the command line window to be a specific size when you run the .py file in the command line window. eg. 300 wide by 250 height. I found a thread on here that shows how to specify the text colour which I also wanted to know. http://www.daniweb.com/forums/post1150939.html#post1150939 Can anybody help? Thanks.

adanaz
Newbie Poster
10 posts since Mar 2010
Reputation Points: 10
Solved Threads: 0
 

My advice, run it from IDLE and you get an adjustable output window with a nice background that works across several common platforms.

vegaseat
DaniWeb's Hypocrite
Moderator
5,989 posts since Oct 2004
Reputation Points: 1,345
Solved Threads: 1,417
 

Thanks for the advice but I'm trying to make my game retro, like the old text based games such as Zork etc. The green text on a black background is classic.

adanaz
Newbie Poster
10 posts since Mar 2010
Reputation Points: 10
Solved Threads: 0
 
Thanks for the advice but I'm trying to make my game retro, like the old text based games such as Zork etc. The green text on a black background is classic.

Honestly, get pygame. Its easy to do a text based game with pygame. It will make a screen, and will update with text. Simple simple things.

Make a surface. Fill surface with black.
Make text surface. Write that text to the original surface.
Call for update, and repeat.

redyugi
Junior Poster in Training
80 posts since Jul 2009
Reputation Points: 15
Solved Threads: 30
 

Thanks, but I havnt got into the pygame stuff yet.

adanaz
Newbie Poster
10 posts since Mar 2010
Reputation Points: 10
Solved Threads: 0
 

Well that was just a suggestion. Good luck though

redyugi
Junior Poster in Training
80 posts since Jul 2009
Reputation Points: 15
Solved Threads: 30
 

for the width try

import os
os.system("mode con cols=50")

and for the length

os.system("mode con lines=20")

#you could also combine them
os.system("mode con cols=50 lines=20")


Play around with the numbers until ya find a size you like.
This is windows only.

Tech B
Posting Whiz in Training
268 posts since May 2009
Reputation Points: 59
Solved Threads: 33
 

THANKS ALOT DUDE! Finally I have the answer! Nice one!

adanaz
Newbie Poster
10 posts since Mar 2010
Reputation Points: 10
Solved Threads: 0
 

Your welcome. and don't forget to mark as solved. :)

Tech B
Posting Whiz in Training
268 posts since May 2009
Reputation Points: 59
Solved Threads: 33
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: