Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
pygame.surface
#8
add function before while loop and this after function.
background = create_background(size)
Line 62 replace screen.fill(WHITE).
screen.blit(background, (0,0))

imagelist = [filename for filename in cd.iterdir() if filename.suffix in ['.png', '.jpg', '.bmp']]
starChoice = (random.choice(imagelist))
imagelist filename is a pathlib class. It is not a string.
try.
StarColor = pygame.image.load(str(starChoice))
99 percent of computer problems exists between chair and keyboard.
Reply


Messages In This Thread
pygame.surface - by Graham - Nov-28-2018, 12:52 PM
RE: pygame.surface - by Windspar - Nov-28-2018, 01:41 PM
RE: pygame.surface - by Graham - Nov-28-2018, 05:39 PM
RE: pygame.surface - by Windspar - Nov-29-2018, 02:02 AM
RE: pygame.surface - by Graham - Nov-29-2018, 09:13 AM
RE: pygame.surface - by Windspar - Nov-29-2018, 02:33 PM
RE: pygame.surface - by Graham - Nov-29-2018, 03:20 PM
RE: pygame.surface - by Windspar - Nov-29-2018, 03:22 PM
RE: pygame.surface - by Graham - Nov-29-2018, 03:57 PM
RE: pygame.surface - by Windspar - Nov-29-2018, 04:21 PM
RE: pygame.surface - by nilamo - Nov-29-2018, 04:45 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [PyGame] Surface and rectangle in pygame Fabrizio_fg 6 2,539 May-27-2023, 09:15 AM
Last Post: Fabrizio_fg
  [PyGame] Pygame is treating blob_group as a surface, when I need it to treat it as a Sprite. Swagford 1 1,366 Jan-24-2023, 09:58 PM
Last Post: metulburr
  Coloring a surface with transparency Sandor 4 2,401 Jan-02-2022, 08:11 AM
Last Post: Sandor
  Drawn line shift when that surface is copied to another in pygame Leo_Red 4 3,408 Feb-11-2021, 06:33 AM
Last Post: Leo_Red
  [PyGame] pygame.Surface.fill help Shemira 3 6,292 Nov-29-2019, 12:01 AM
Last Post: Shemira
  [PyGame] PLEASE HELP! TypeError: unsupported operand type(s) for +: 'pygame.Surface' and 'int' keyfive 1 5,368 Jun-19-2018, 01:20 PM
Last Post: volcano63

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020