While I was learning how the layout of UI elements worked in pygame_gui, I have noticed that whenever I tried to make a window of a specific size, it would always come out smaller than I want it to.
import pygame
import pygame_gui
pygame.init()
pygame.display.set_caption('Quick Start')
window_surface = pygame.display.set_mode((800, 600))
background = pygame.Surface((800, 600))
background.fill(pygame.Color('#000000'))
manager = pygame_gui.UIManager((800, 600))
ui_window = pygame_gui.elements.UIWindow(rect=pygame.Rect((0, 0), (100, 100)),
window_display_title="UIWindow",
resizable= True)
clock = pygame.time.Clock()
is_running = True
while is_running:
time_delta = clock.tick(60)/1000.0
## print(time_delta)
print(ui_window.get_abs_rect())
pygame.draw.rect(background, "blue", pygame.Rect(0, 0, 100, 100)) ## This code draws the rectangle that I would expect the window to occupy
for event in pygame.event.get():
if event.type == pygame.QUIT:
is_running = False
manager.process_events(event)
manager.update(time_delta)
window_surface.blit(background, (0, 0))
manager.draw_ui(window_surface)
pygame.display.update()
New contributor
David Xu is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.