Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Anchors right_target not working properly #671

Open
VitoR-InA opened this issue Feb 22, 2025 · 0 comments
Open

Anchors right_target not working properly #671

VitoR-InA opened this issue Feb 22, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@VitoR-InA
Copy link

Expected behaviour
Two buttons: LEFT and RIGHT should be positioned according to their parent element. But right_target does not work correctly.

Screenshots
Image

Code

import pygame
from pygame import Rect
from pygame import Window

from pygame_gui import UIManager
from pygame_gui.elements import UIButton, UIPanel


class test(Window):
    def __init__(self):
        pygame.init()
        super().__init__(fullscreen_desktop = True)
        self.clock = pygame.time.Clock()
        self.screen = self.get_surface()
        self.manager = UIManager(self.size)
        
        parent_panel = UIPanel(Rect(self.size[0] / 2 - 250, self.size[1] / 2 - 100, 500, 200), manager = self.manager)
        
        child_rect = Rect()
        child_rect.size = (200, 200)

        child_rect.topright = (-10, self.size[1] / 2 - 100)
        child_left = UIButton(child_rect, "RIGHT", self.manager, anchors = {"right_target":parent_panel})

        child_rect.topleft = (10, self.size[1] / 2 - 100)
        child_right = UIButton(child_rect, "LEFT", self.manager, anchors = {"left_target":parent_panel})

    def run(self):
        running = True
        while running:
            td = self.clock.tick(120) / 1000.0
            for event in pygame.event.get():
                self.manager.process_events(event)
                if event.type == pygame.QUIT: running = False
            
            self.screen.fill("#141414")
            self.manager.update(td)
            self.manager.draw_ui(self.screen)
            self.flip()
                

if __name__ == "__main__":
    test().run()

Platform and software (please complete the following information):

  • OS: Windows 11
  • Pygame GUI version 0.6.12
  • Pygame version 2.5.2
@VitoR-InA VitoR-InA added the bug Something isn't working label Feb 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant