Closed lordmauve closed 9 years ago
Original comment by Arve Seljebu (Bitbucket: arve0, GitHub: arve0):
Further investigation shows that the problem is only when inside a virtualenv, though SDL2 works inside virtualenv. SDL2 is also a bit snappier than SDL, ~1 second load time vs ~6 seconds.
All examples works OK, except music.py (I'm missing a codec) and ptext.py. The tracebacks follows:
music.py (fails for both SDL and SDL2)
Traceback (most recent call last):
File "/Users/arve/.virtualenvs/3.4/bin/pgzrun", line 9, in <module>
load_entry_point('pgzero==1.1rc1', 'console_scripts', 'pgzrun')()
File "/Users/arve/.virtualenvs/3.4/lib/python3.4/site-packages/pgzero/runner.py", line 45, in main
PGZeroGame(mod).run()
File "/Users/arve/.virtualenvs/3.4/lib/python3.4/site-packages/pgzero/game.py", line 195, in run
self.dispatch_event(event)
File "/Users/arve/.virtualenvs/3.4/lib/python3.4/site-packages/pgzero/game.py", line 131, in dispatch_event
handler(event)
File "/Users/arve/.virtualenvs/3.4/lib/python3.4/site-packages/pgzero/game.py", line 125, in <lambda>
return lambda event: handler(**prep_args(event))
File "music.py", line 28, in on_mouse_down
music.play(t)
File "/Users/arve/.virtualenvs/3.4/lib/python3.4/site-packages/pgzero/music.py", line 51, in play
_play(name, -1)
File "/Users/arve/.virtualenvs/3.4/lib/python3.4/site-packages/pgzero/music.py", line 40, in _play
_music.load(path)
File "pygame_sdl2/mixer_music.pyx", line 53, in pygame_sdl2.mixer_music.load (gen3/pygame_sdl2.mixer_music.c:1018)
pygame_sdl2.error.error: b'Unrecognized music format'
ptext.py
Traceback (most recent call last):
File "/Users/arve/.virtualenvs/3.4/bin/pgzrun", line 9, in <module>
load_entry_point('pgzero==1.1rc1', 'console_scripts', 'pgzrun')()
File "/Users/arve/.virtualenvs/3.4/lib/python3.4/site-packages/pgzero/runner.py", line 45, in main
PGZeroGame(mod).run()
File "/Users/arve/.virtualenvs/3.4/lib/python3.4/site-packages/pgzero/game.py", line 204, in run
draw()
File "ptext.py", line 115, in draw
gcolor="#442200"
File "/Users/arve/.virtualenvs/3.4/lib/python3.4/site-packages/pgzero/screen.py", line 59, in text
ptext.draw(*args, surf=self._surf, **kwargs)
File "/Users/arve/.virtualenvs/3.4/lib/python3.4/site-packages/pgzero/ptext.py", line 320, in draw
ocolor, owidth, scolor, shadow, gcolor, alpha, align, lineheight, angle, cache)
File "/Users/arve/.virtualenvs/3.4/lib/python3.4/site-packages/pgzero/ptext.py", line 229, in getsurf
lineheight=lineheight, cache=cache)
File "/Users/arve/.virtualenvs/3.4/lib/python3.4/site-packages/pgzero/ptext.py", line 256, in getsurf
array = pygame.surfarray.pixels3d(lsurf)
AttributeError: 'module' object has no attribute 'surfarray'
I'll leave it with this, as pgzero actually works as described if following the installation manual. My bad on the virtualenv.
Original comment by Daniel Pope (Bitbucket: lordmauve, GitHub: lordmauve):
Great news. Could you verify that all the examples work and do a pull request to add this as an extra section to the installation docs? If it's possible to install without virtualenv, even with some bootstrap in pgzero.runner, that would be even better. Or just as simple as you can make it.
Original comment by Arve Seljebu (Bitbucket: arve0, GitHub: arve0):
Using pygame sdl2 works!
brew install python3 sdl2 sdl2_gfx sdl2_image sdl2_mixer sdl2_ttf
mkvirtualenv -p /usr/local/bin/python3 pygame_sdl2
pip install cython
git clone https://github.com/renpy/pygame_sdl2
cd pygame_sdl2/
python fix_virtualenv.py
pip install .
cd ..
hg clone https://bitbucket.org/lordmauve/pgzero
cd pgzero
wget https://gist.github.com/arve0/c1be371566a9099747a4/raw/3227645c10b28241b50ab35b1cc7006036ff391c/runner.py -O pgzero/runner.py
pip install .
wget https://gist.github.com/arve0/a22efe8f591610799ba6/raw/c61d4895afc87d9a304f83467db90e46cd97cbba/hangman.py
pgzrun hangman.py
Original comment by Arve Seljebu (Bitbucket: arve0, GitHub: arve0):
Here is some debug info.
Code to reproduce is found here.
A more detailed description in images:
pgzrun hangman_solution.py
- opens pygame in background window:
Focus pygame with mouse - brings window to front, but menubar shows "Terminal".
Press abc
characters - characters echoed in terminal, pygame is unaffected (see picture above).
Originally reported by: Matt Wheeler (Bitbucket: funkyhat, GitHub: funkyhat)
On OSX the pgzero window doesn't get focus.
This appears to be caused by https://bitbucket.org/pygame/pygame/issue/203/window-does-not-get-focus-on-os-x-with