6
Contributors
11
Replies
51
Views
7 Years
Discussion Span
Last Post by DubWine
Featured Replies
  • for the width try [CODE] import os os.system("mode con cols=50") [/CODE] and for the length [CODE] os.system("mode con lines=20") #you could also combine them os.system("mode con cols=50 lines=20") [/CODE] Play around with the numbers until ya find a size you like. This is windows only. Read More

  • 2

    @DubWine hi, it seems that there are solutions by using the `ctypes` module and the `setconsolewindoinfo` method in windows api. See https://stackoverflow.com/questions/3646362/how-to-control-the-size-of-the-windows-shell-window-from-within-a-python-script for example. Also google the keywords python and setconsolewindowinfo. Edit: you can also read the console dimension without a subprocess as in http://rosettacode.org/wiki/Terminal_control/Dimensions#Python Read More

0

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

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.

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.

1

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.

Votes + Comments
This person knows their stuff!
0

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

0

@Tech B

Is there a way of using variables to set the cols and lines values?

2

@DubWine hi, it seems that there are solutions by using the ctypes module and the setconsolewindoinfo method in windows api. See https://stackoverflow.com/questions/3646362/how-to-control-the-size-of-the-windows-shell-window-from-within-a-python-script for example. Also google the keywords python and setconsolewindowinfo.

Edit: you can also read the console dimension without a subprocess as in http://rosettacode.org/wiki/Terminal_control/Dimensions#Python

Edited by Gribouillis

Votes + Comments
+ for Rosettacode. Amazing resource.
0

Can't seem to make an edit or comment to @Gribouillis, did I miss something?

Anyway... I figured it out; os.system() takes a string value so you can simply do:

width = "100"
height = "30"

os.system("mode con cols="+width+"lines="+height)

Thanks for the links @Gribouillis; ctypes looks more in depth and customisable so will check it out.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.