I have made a simple pygame window as shown below. But when I click somewhere on the screen (not the pygame window itself), the window goes to the back. Therefore, how do I make sure that my pygame window always or conditionally(when click a particular place on screen) stays on top?
This project of mine is needed to be run on Ubuntu platform
This is my simple program
# Simple pygame program
# Import and initialize the pygame library
import pygame
pygame.init()
# Set up the drawing window
# Set the size of the pygame window
window_width = 500
window_height = 500
window_size = (window_width, window_height)
surface = pygame.display.set_mode(window_size, pygame.RESIZABLE)
# Run until the user asks to quit
running = True
while running:
# Fill the background with white
surface.fill((255, 255, 255))
# Draw a solid blue circle in the center
pygame.draw.circle(surface, (0, 0, 255), (int(surface.get_width()/2),
int(surface.get_height()/2)), 75)
# Flip the display
# magic
pygame.display.flip()
pygame.display.update()
# gives window size
# window_size = [pygame.display.Info().current_w, pygame.display.Info().current_h]
# print(window_size)
# Did the user click the window close button?
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
if event.type == pygame.VIDEORESIZE:
# There's some code to add back window content here.
surface = pygame.display.set_mode((event.w, event.h),
pygame.RESIZABLE)
# Done! Time to quit.
pygame.quit()