SVG rendering in a PyGame application

In a pyGame application, I would like to render resolution-free GUI widgets described in SVG. What tool and/or library can I use to reach this goal ? (I like the OCEMP GUI toolkit but it seems to...

Python: Open file in zip without temporarily extracting it

How can I open files in a zip archive without extracting them first? I'm using pygame. To save disk space, I have all the images zipped up. Is it possible to load a given image directly from the...

How to load and play a video in pygame

I'm having a problem. I want to load and play a video in pygame but it doesn't start. The only thing that I am seeing is a black screen. Here is my code: import pygame from pygame import...

Embedding a Pygame window into a Tkinter or WxPython frame

A friend and I are making a game in pygame. We would like to have a pygame window embedded into a tkinter or WxPython frame, so that we can include text input, buttons, and dropdown menus that are...

How can I invert the thresholded image by using pygame?

I can't find the true approach in order to invert the result image. I tried to use inverse=True argument inside pygame.transform.threshold method but it results in errors. In other words, I need...

How to insert a slider in Pygame?

I am currenctly working on a physics simulation on Python, simulating a gas cloud in a chamber using Pygame . My problem is that I can't insert a working slider in my code to change the value of...

how do I place the pygame screen in the middle?

I made a game using pygame which includes an init. In other ".py" file I created another init which I run from the main game. But, the second init opened on the [0,0] place of the main init, and...

Key press is not being recognised by python's 'pygame.key.get_pressed()' module

I am trying to create a function where if a key is pressed, variables are changed. This will be put into a class that moves a sprite on a screen. The while loop is broken when the key is released....

How can I create a text input box with Pygame?

I want to get some text input from the user in Python and display what they are typing in a text box, and when they press enter, it gets stored in a string. I've looked everywhere, but I just...

Using enum for gamestates in Python

I'm currently working on a game in python with pyGame and want to use enums for the different states(gamestate, levelstate etc,) in the game. I have inherited my own GameState class from Enum...

Windows "Command Prompt" inside tkinter frame

How to run command prompt inside tkinter frame? I know how to do it with "pygame", but those methods doesn't work - command prompt just runs in another window. I tried to do it like this: import...

Update one sprite among a group of sprites [Pygame]

First post here. So I am trying to implement a Civilization type of movement game. At the moment, I have one sprite in a cell. I can click it and then if I click another grid, the sprite moves...

Pygame drawing not showing in Pygame window

So I was testing out pygame and I wanted to draw a simple rectangle. There are no error messages when I run the code but the rectangle doesn't show up in the window. What I see is a blank white...

Unable to lower FULLSCREEN resolution in pygame on PI Zero W

I am running Raspbian (buster) at a desktop resolution of ie: 1920x1080 on a Raspberry PI Zero W but wish to create a python game using pygame that runs FULLSCREEN at a lower resolution. I am...

Center window of a Pygame Zero game

I am using the easy-to-use Python library pgzero for programming games. How can I center the game window? )It always opens at a random position... import pgzrun TITLE = "Hello World" WIDTH =...

Pygame window not showing up

I recently downloaded pygame on my Mac, but for some reason, the window does not pop up with the screen or anything. I don't get an error message, it just runs but doesn't actually pop up a...

OpenCV-python not importing

I am using Pydroid to code in android. Though it is an ARM machine so I downloaded OpenCV-python wheel from PiWheels and successfully installed it using pip. But i can't import OpenCV anyways....

A-star algorithm results in weird, slow and inefficient choices

Today I attempted making the A-STAR pathfinding algorithm, with visualization in PyGame. The code is: import pygame,...

rect collision with list of rects

I have the code player_rect.colliderect(tile_rects): where player_rect is a single Rect, and tile_rects is a list of Rects. I get the error `builtins.TypeError: Argument must be rect style...

Pygame Surface Positioning

As I understood pygame drawing method, the 2nd argument of the blit function (screen.blit(surface, (0,0))) tells pygame where to draw the given surface (like an offset to start drawing from, or...

Tool to host online Python/Pygame experiment

Before the lockdown, I developed a Python-Pygame app as a psychology experiment I'm working on in my lab. We had three subjects coming and test it on our lab computers and it worked perfectly. As...

How to fix error: " No module named 'pygame' "

I installed the pygame module and it works just fine when I try to run it from PyCharm or Sublime Text, but when I try to run it from console or IDLE it says: " Error: No module named 'pygame'...

How can I play a sine/square wave using Pygame?

I'm trying to play a sine wave using Pygame's sndarray.make_sound function. However, when I use this array to play it: np.sin(2 * np.pi * np.arange(44100) * 440 / 44100).astype(np.float32) where...

How do I invert a pygame color?

How do I invert a pygame color? For example how would I invert: key_color = pygame.Color('grey')

how to know pygame.Rect's side that collide to other Rect?

I am using pygame, python3.9, I want to make to return which side(rect1) is collided with rect2. I've already tried this but it dosen't work. I just want internal module and pygame.(sorry for bad...

Python - called Tcl_FindHashEntry on deleted table when Pygame window is focused after using Tkinter

So I was working on a larger project and testing on a Mac when I noticed some weird behavior. I'm using Python 3.9.1 and macOS 11.0.1 – the bug doesn't occur on Windows 7, and I haven't tested...

Display SVG (from string) on Python Pygame

I have an SVG graphic represented in a string svg_string='<svg height="100" width="500"><ellipse cx="240" cy="50" rx="220" ry="30" style="fill:yellow" /><ellipse cx="220" cy="50" rx="190" ry="20"...

pygame cant stop the image from moving out of the screen when touching the bottom

I am attempting to create a window where a sprite is stopped if it tries to go past the edges. This has worked for all of the sides of the window except for the bottom. this is the function: def...

rendering freetype font with pygame

I was trying to print out just a simple title page using pygame. My original code looked like: import pygame import pygame.freetype pygame.init() pygame.display.set_caption('hello...

Every time I run `pip` to install any package, it shows me warnings

I get these warnings immediately after the pip is run and when pip has finished executing: Here it is as text: C:\Users\Raj Panpaliya> pip install pygame WARNING: Ignoring invalid distribution...