How to make a pygame window fullscreen without hiding the taskbar

Viewed 355

I'm currently learning pygame. I've set up a window and set it to fullscreen:

import pygame

WIN = pygame.display.set_mode((0, 0), pygame.FULLSCREEN)
pygame.display.set_caption("First Game!")
WHITE = (255, 255, 255)
FPS = 60


def draw_window():
    WIN.fill(WHITE)
    pygame.display.update()


def main():
    clock = pygame.time.Clock()
    run = True
    while run:
        clock.tick(FPS)
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                run = False
        draw_window()

    pygame.quit()


if __name__ == "__main__":
    main()

The problem is that the taskbar is being hidden. How do I make the window fullscreen without hiding the taskbar? I want to do something like this, just in pygame:

import tkinter as tk

window = Tk()
window.state("zoomed")

window.mainloop()

This makes the window fullscreen without hiding the taskbar

1 Answers

I can only provide a general solution for Windows systems.

Create a resizable window (pygame.RESIZABLE) and use ShowWindow to maximize the window:

import sys
import ctypes
import pygame

pygame.init()
WIN = pygame.display.set_mode((0, 0), pygame.RESIZABLE)
if sys.platform == "win32":
    HWND = pygame.display.get_wm_info()['window']
    SW_MAXIMIZE = 3
    ctypes.windll.user32.ShowWindow(HWND, SW_MAXIMIZE)

See also how do I maximize the window?.

There should be similar solutions for other operating systems. Maybe someone else can add additional answers.

Related