You need to pass -c
as a string. Wrap it in quotes:
parser.add_argument('-c', action='store', dest='colour', type=str,
help='Choose Colour')
Otherwise python will pass the value of the variable -c
, whatever it is. Hope it helps!
Edit: Oh, that wasn't the problem... hahaha
Well, i figured out what it is anyway. When you're passing WH
as an argument to the script, you are not passing the value of the variable WH
- which is 255, 255, 255
- but instead you're passing the string literal "WH"
as the argument to draw.line
. Hence the error.
To fix this, you should specify the parameter nargs
, and discard the type
parameter, since the latter isn't needed:
parser.add_argument('-c', action='store', dest='colour', nargs=3,
help='Choose Colour')
...
colours = (int(i) for i in args.colours)
pygame.draw.line(screen, *colours,(nSX),(nSY),(nEX,nEY),1)
And when you're running it:
python LineGenerator.py -c 255, 255, 255
That's all! Hope it helps!