Skip to content

Using keyword arguments to create Rects does not work. #3539

@Lirhio

Description

@Lirhio

I was hesitant to come here, as this is my first time opening an issue on a GitHub project, but I think reporting this (even though you're already aware of it) could improve the experience for a PyGame noob when the bug is fixed (if it actually is one).

I'm talking about using keyword arguments to create Rects using pygame.Rect.

button: pygame.Rect = pygame.Rect((100, 100, 200, 50))

^ The above code works perfectly

button: pygame.Rect = pygame.Rect(single_arg=(100, 100, 200, 50))

^ This doesn't work, when I try to draw the Rect using pygame.draw.rect, nothing is drawn on the screen. It's weird, I don't think it's supposed to work like that. The same behavior is observed when using (left=*, top=*, width=* height=*) or (left_top=*, width_height=*).

Update (as of this writing): The Rect is clearly created when I use print to check, but all of its information is reset. print(button) returns Rect(0, 0, 0, 0).

I have no idea if other pygame functions have the same behavior. I apologize if I'm accidentally duplicating an existing issue. I can provide more information about the executed code if needed. I hope this helps!

pygame.print_debug_info() below:

Platform:               Windows-10-10.0.19045-SP0
System:                 Windows
System Version:         10.0.19045
Processor:              Intel64 Family 6 Model 158 Stepping 10, GenuineIntel        SSE2: Yes       AVX2: Yes   NEON: No
Architecture:           Bits: 64bit     Linkage: WindowsPE

Python:                 CPython 3.13.4 (tags/v3.13.4:8a526ec, Jun  3 2025, 17:46:04) [MSC v.1943 64 bit (AMD64)]
GIL Enabled:            True
pygame version:         2.5.5
SDL versions:           Linked: 2.32.6  Compiled: 2.32.6
SDL Mixer versions:     Linked: 2.8.1   Compiled: 2.8.1
SDL Font versions:      Linked: 2.24.0  Compiled: 2.24.0
SDL Image versions:     Linked: 2.8.8   Compiled: 2.8.8
Freetype versions:      Linked: 2.11.1  Compiled: 2.11.1

Display Driver:         windows
Mixer Driver:           wasapi

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions