1

this is my firdt post and i need some hepl. I have started learning pyhon and have got to the point where i am ready to make my own program.

I am writing a program that is a 'stat' checker for the MMO 'Realm of the Mad God' and want to be able to change the colour of the text depending on whether the stat is < or > 0.

I have looked on this forum and the answers are either too complicated for my non-programers mind or not relevant to what i need.

essentially, i would like the extract of code below to print in diffreent colours depending on what 'if' statement the computer runs.

if hpc < 0:
    print ('    HP is above average by ' + hpc)
else:
    if hpc == 0:
        print ('    HP is average')

If anybody can help me with this and attempt to explain it in 'simple' language, i would be much obliged,

Thanks in advance!

TGSpike
  • 45
  • 2
  • 5
  • The easiest way to do this is using what's called ANSI Escape Sequences - are you using Windows or Mac or Linux? – captainandcoke Mar 07 '13 at 21:40
  • I am using window 7 64 bit. I have seen ANSI on a couple of posts before but im not sure what it is or how to use it. Thanks for the quick reply! – TGSpike Mar 07 '13 at 22:01

1 Answers1

0

You need to add a module to python to accomplish this task in Windows. The colorama module can do this. https://pypi.python.org/pypi/colorama Alternatively, you can try using the win32api for python (it will work on 64 bit Windows I think) http://sourceforge.net/projects/pywin32/

captainandcoke
  • 1,085
  • 2
  • 13
  • 16
  • If your new to programming, I highly recommend trying to install Linux on your computer. I switched about 5 years ago and it's much easier to do anything programming related. You can even install Linux inside Windows with a virtual machine or dual boot it along side Windows. – captainandcoke Mar 07 '13 at 23:26