lordmauve / pgzero

A zero-boilerplate games programming framework for Python 3, based on Pygame.
https://pygame-zero.readthedocs.io/
GNU Lesser General Public License v3.0
530 stars 190 forks source link

add color string support for pgzero #237

Closed yonghuming closed 3 years ago

yonghuming commented 3 years ago
import pgzrun

def draw():
    screen.fill('red') # specify color useing string

pgzrun.go()

allow specilfy color using color string, just like turtle:

pencolor('red')
yonghuming commented 3 years ago
Requirement already satisfied: pip in /opt/hostedtoolcache/Python/3.9.1/x64/lib/python3.9/site-packages (20.3.1)
Collecting pip
  Downloading pip-20.3.3-py2.py3-none-any.whl (1.5 MB)
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 20.3.1
    Uninstalling pip-20.3.1:
      Successfully uninstalled pip-20.3.1
Successfully installed pip-20.3.3
Ignoring pygame: markers 'python_version < "3.8"' don't match your environment
Collecting pygame==2.0.0.dev6
  Downloading pygame-2.0.0.dev6.tar.gz (3.7 MB)
    ERROR: Command errored out with exit status 1:
     command: /opt/hostedtoolcache/Python/3.9.1/x64/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-3lszh_0i/pygame_d189f63c535b4639aa848516775d0e9c/setup.py'"'"'; __file__='"'"'/tmp/pip-install-3lszh_0i/pygame_d189f63c535b4639aa848516775d0e9c/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-o2i6z6n3
         cwd: /tmp/pip-install-3lszh_0i/pygame_d189f63c535b4639aa848516775d0e9c/
    Complete output (28 lines):

    WARNING, No "Setup" File Exists, Running "buildconfig/config.py"
    Using UNIX configuration...

    /bin/sh: 1: sdl2-config: not found
    /bin/sh: 1: sdl2-config: not found
    /bin/sh: 1: sdl2-config: not found
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-3lszh_0i/pygame_d189f63c535b4639aa848516775d0e9c/setup.py", line 258, in <module>
        buildconfig.config.main(AUTO_CONFIG)
      File "/tmp/pip-install-3lszh_0i/pygame_d189f63c535b4639aa848516775d0e9c/buildconfig/config.py", line 208, in main
        deps = CFG.main(**kwds)
      File "/tmp/pip-install-3lszh_0i/pygame_d189f63c535b4639aa848516775d0e9c/buildconfig/config_unix.py", line 223, in main
Error:         raise RuntimeError('Unable to run "sdl-config". Please make sure a development version of SDL is installed.')
    RuntimeError: Unable to run "sdl-config". Please make sure a development version of SDL is installed.

    Hunting dependencies...
    WARNING: "sdl2-config" failed!

    ---
    For help with compilation see:
        https://www.pygame.org/wiki/Compilation
    To contribute to pygame development see:
        https://www.pygame.org/contribute.html
    ---

    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
Error: Process completed with exit code 1.
yonghuming commented 3 years ago

@lordmauve why failed? it seems not caused by my code.

lordmauve commented 3 years ago

You can already do this. It is provided by pygame.Color and therefore works everywhere make_color() is used.

yonghuming commented 3 years ago

.

return tuple(pygame.Color(arg))

so `pygame.Color(arg)` works for color string. thank you