How to use gfx in pygame
Asked Answered
B

2

14

I have a pygame game and I want to use pygame.gfxdraw.aacricle(), but whenever I do it gives me an error:

AttributeError: 'module' object has no attribute 'gfxdraw'

How do I install gfx for python 2.7?

Biddick answered 25/5, 2012 at 18:26 Comment(1)
Do you have pygame 1.9+ installed?Librettist
J
16

I had this same issue using gfxdraw in pygame as well. Once I imported the module explicitly, there were no issues. Adding this line after importing pygame fixed the issue:

import pygame.gfxdraw

Curiously, I don't need to import pygame.draw explicitly in order to use it.

Jacklighter answered 8/7, 2012 at 22:9 Comment(1)
Awesome, this is exactly what I had to do to fix the application I was developing (Python 2.7, latest pygame, Ubuntu x64).Hughes
N
0

Here is the compilation and installation guide for gfx.

For the basic install it's the standard:

python setup.py build
python setup.py install

Or did you already try this and run into some problems?

Nutrilite answered 25/5, 2012 at 18:28 Comment(7)
I went to that website and downloaded the file they suggested: swftools.org/download.html . It was an exe, so I ran it and gfx still isn't installed. I have no idea what the instruction means.Biddick
@Biddick did you get any sort of error/warning messages during the installation?Nutrilite
No it went through clean. It just didn't have any obvious effects.Biddick
In fact the download linked there isn't even a compressed fileBiddick
@Biddick it's not that unusual for install packages to be in .exe format. I am assuming you've tried to reinstall this? Is it possible you've run into some permission problems (though I would expect some error/warning messages in that case) i.e., did you have to install this as administrator? Is there a pygame forum you could post your query? Did you download this version? wiki.swftools.org/wiki/…Nutrilite
I don't believe this is pygame.gfxdraw , but gfx. I just tested my pygame, and import pygame.gfxdraw worked. I don't believe I did a second install, just pygame-1.9.2-pre.Librettist
Monkey, you got it, thanks! I would have expected "import pygame" to import everything, but apparently it doesn't. You should make that an answerBiddick

© 2022 - 2024 — McMap. All rights reserved.