![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Jul 2005
Posts: 1
Rep Power: 0
![]() |
Python and Pygame
Well, I am a newb when it comes to Python, but not programming in general. I am an experienced PHP programmer, but that's off-topic. Anyway, I downloaded Python v2.3 and Pygame v1.6 for Python 2.3 and installed both; Python to Program Files\Python23 and Pygame to Program Files\Python23\Lib\site-packages. Now, to my bleak understanding, to use a module in Python, you use Import. So, I do this:
import pygame Now, when I try to do anythin with that module I get errors: >>>pygame.init()
Traceback (most recent call last):
File "<pyshell#6>", line 1, in -toplevel-
pygame.init()
AttributeError: 'module' object has no attribute 'init'I have read all of the intro articles at pygame.org on how to install and get it working, and they all say to just use import. I know it's importing pygame because when I print pygame it tells me the directory of the installed module. >>>print pygame <module 'pygame' from 'C:\Program Files\Python23\lib\pygame.pyc'> I would really appreciate any help at all. |
|
|
|
|
|
#2 |
|
Programming Guru
![]() |
That's odd...
HMMMmmm... o_o;; Pygame doesn't even work on my computer, but still even that worked for me... x_x Errr.... durr.... Try import pygame help(pygame) See if it shows you the init function. And then run: import pygame dir(pygame) It should show as: ['ACTIVEEVENT', 'ANYFORMAT', 'ASYNCBLIT', 'AUDIO_S16', 'AUDIO_S16LSB', 'AUDIO_S16MSB', 'AUDIO_S16SYS', 'AUDIO_S8', 'AUDIO_U16', 'AUDIO_U16LSB', 'AUDIO_U16MSB', 'AUDIO_U16SYS', 'AUDIO_U8', 'Color', 'DOUBLEBUF', 'FULLSCREEN', 'GL_ACCUM_ALPHA_SIZE', 'GL_ACCUM_BLUE_SIZE', 'GL_ACCUM_GREEN_SIZE', 'GL_ACCUM_RED_SIZE', 'GL_ALPHA_SIZE', 'GL_BLUE_SIZE', 'GL_BUFFER_SIZE', 'GL_DEPTH_SIZE', 'GL_DOUBLEBUFFER', 'GL_GREEN_SIZE', 'GL_MULTISAMPLEBUFFERS', 'GL_MULTISAMPLESAMPLES', 'GL_RED_SIZE', 'GL_STENCIL_SIZE', 'GL_STEREO', 'HAT_CENTERED', 'HAT_DOWN', 'HAT_LEFT', 'HAT_LEFTDOWN', 'HAT_LEFTUP', 'HAT_RIGHT', 'HAT_RIGHTDOWN', 'HAT_RIGHTUP', 'HAT_UP', 'HWACCEL', 'HWPALETTE', 'HWSURFACE', 'JOYAXISMOTION', 'JOYBALLMOTION', 'JOYBUTTONDOWN', 'JOYBUTTONUP', 'JOYHATMOTION', 'KEYDOWN', 'KEYUP', 'KMOD_ALT', 'KMOD_CAPS', 'KMOD_CTRL', 'KMOD_LALT', 'KMOD_LCTRL', 'KMOD_LMETA', 'KMOD_LSHIFT', 'KMOD_META', 'KMOD_MODE', 'KMOD_NONE', 'KMOD_NUM', 'KMOD_RALT', 'KMOD_RCTRL', 'KMOD_RMETA', 'KMOD_RSHIFT', 'KMOD_SHIFT', 'K_0', 'K_1', 'K_2', 'K_3', 'K_4', 'K_5', 'K_6', 'K_7', 'K_8', 'K_9', 'K_AMPERSAND', 'K_ASTERISK', 'K_AT', 'K_BACKQUOTE', 'K_BACKSLASH', 'K_BACKSPACE', 'K_BREAK', 'K_CAPSLOCK', 'K_CARET', 'K_CLEAR', 'K_COLON', 'K_COMMA', 'K_DELETE', 'K_DOLLAR', 'K_DOWN', 'K_END', 'K_EQUALS', 'K_ESCAPE', 'K_EURO', 'K_EXCLAIM', 'K_F1', 'K_F10', 'K_F11', 'K_F12', 'K_F13', 'K_F14', 'K_F15', 'K_F2', 'K_F3', 'K_F4', 'K_F5', 'K_F6', 'K_F7', 'K_F8', 'K_F9', 'K_FIRST', 'K_GREATER', 'K_HASH', 'K_HELP', 'K_HOME', 'K_INSERT', 'K_KP0', 'K_KP1', 'K_KP2', 'K_KP3', 'K_KP4', 'K_KP5', 'K_KP6', 'K_KP7', 'K_KP8', 'K_KP9', 'K_KP_DIVIDE', 'K_KP_ENTER', 'K_KP_EQUALS', 'K_KP_MINUS', 'K_KP_MULTIPLY', 'K_KP_PERIOD', 'K_KP_PLUS', 'K_LALT', 'K_LAST', 'K_LCTRL', 'K_LEFT', 'K_LEFTBRACKET', 'K_LEFTPAREN', 'K_LESS', 'K_LMETA', 'K_LSHIFT', 'K_LSUPER', 'K_MENU', 'K_MINUS', 'K_MODE', 'K_NUMLOCK', 'K_PAGEDOWN', 'K_PAGEUP', 'K_PAUSE', 'K_PERIOD', 'K_PLUS', 'K_POWER', 'K_PRINT', 'K_QUESTION', 'K_QUOTE', 'K_QUOTEDBL', 'K_RALT', 'K_RCTRL', 'K_RETURN', 'K_RIGHT', 'K_RIGHTBRACKET', 'K_RIGHTPAREN', 'K_RMETA', 'K_RSHIFT', 'K_RSUPER', 'K_SCROLLOCK', 'K_SEMICOLON', 'K_SLASH', 'K_SPACE', 'K_SYSREQ', 'K_TAB', 'K_UNDERSCORE', 'K_UNKNOWN', 'K_UP', 'K_a', 'K_b', 'K_c', 'K_d', 'K_e', 'K_f', 'K_g', 'K_h', 'K_i', 'K_j', 'K_k', 'K_l', 'K_m', 'K_n', 'K_o', 'K_p', 'K_q', 'K_r', 'K_s', 'K_t', 'K_u', 'K_v', 'K_w', 'K_x', 'K_y', 'K_z', 'MOUSEBUTTONDOWN', 'MOUSEBUTTONUP', 'MOUSEMOTION', 'NOEVENT', 'NOFRAME', 'NUMEVENTS', 'OPENGL', 'OPENGLBLIT', 'PREALLOC', 'QUIT', 'RESIZABLE', 'RLEACCEL', 'RLEACCELOK', 'Rect', 'SRCALPHA', 'SRCCOLORKEY', 'SWSURFACE', 'SYSWMEVENT', 'Surface', 'SurfaceType', 'USEREVENT', 'VIDEOEXPOSE', 'VIDEORESIZE', '__builtins__', '__doc__', '__file__', '__name__', '__path__', '__rect_constructor', '__rect_reduce', '__version__', 'base', 'cdrom', 'color', 'colordict', 'constants', 'cursors', 'display', 'draw', 'error', 'event', 'font', 'get_error', 'image', 'init', 'joystick', 'key', 'locals', 'mixer', 'mouse', 'movie', 'msg', 'quit', 'rect', 'register_quit', 'segfault', 'sndarray', 'sprite', 'string', 'surface', 'surfarray', 'sysfont', 'time', 'transform', 'ver', 'vernum', 'version'] I don't believe init is actually completely necessary though, I think it just makes it more stable for certain commands. |
|
|
|
|
|
#3 |
|
Professional Programmer
Join Date: Apr 2005
Location: London, England
Posts: 459
Rep Power: 4
![]() |
Ok, run this and show me the ouput:
import pygame print dir(pygame) <edit>ahhh, beaten to it</edit> |
|
|
|
|
|
#4 |
|
Programming Guru
![]() |
WOOOT!
![]() ...hehehehe :p ... What am I doing here again? >_> *runs* |
|
|
|
|
|
#5 |
|
Professional Programmer
Join Date: Feb 2005
Posts: 434
Rep Power: 4
![]() |
Looking at your result:
>>>print pygame <module 'pygame' from 'C:\Program Files\Python23\lib\pygame.pyc'>
__________________
I looked it up on the Intergnats! |
|
|
|
|
|
#6 |
|
Programming Guru
![]() |
Ahhh, clever leprachaun you are. :eek:
|
|
|
|
|
|
#7 | |
|
Newbie
Join Date: Jul 2005
Posts: 2
Rep Power: 0
![]() |
Guido says it best himself...
Quote:
|
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|