Answer the question
In order to leave comments, you need to log in
Why does the window not appear around the edges?
I create a window in pygame:
win = pg.display.set_mode((1600, 900), pg.RESIZABLE)
Answer the question
In order to leave comments, you need to log in
pg.display.set_mode((0, 0), pg.FULLSCREEN)
UPD.
You can change the size of the window like this, given the taskbar. Will not work correctly if the taskbar is different from the standard one
https://stackoverflow.com/a/50454340
import pygame, os
os.environ['SDL_VIDEO_CENTERED'] = '1'
pygame.init()
info = pygame.display.Info()
screen_width, screen_height = info.current_w, info.current_h
win = pygame.display.set_mode((640, 480), pygame.RESIZABLE)
window_width, window_height = screen_width, screen_height - 50
window = pygame.display.set_mode((window_width, window_height))
pygame.display.update()
import sys
import pygame
if sys.platform == "win32":
from ctypes import windll, Structure, c_long, c_ulong, sizeof, byref
SW_HIDE = 0
SW_SHOWNORMAL = 1
SW_NORMAL = 1
SW_SHOWMINIMIZED = 2
SW_SHOWMAXIMIZED = 3
SW_MAXIMIZE = 3
SW_SHOWNOACTIVATE = 4
SW_SHOW = 5
SW_MINIMIZE = 6
SW_SHOWMINNOACTIVE = 7
SW_SHOWNA = 8
SW_RESTORE = 9
SW_SHOWDEFAULT = 10
SW_FORCEMINIMIZE = 11
SW_MAX = 11
SWP_NOSIZE = 0x0001
SWP_NOMOVE = 0x0002
SWP_NOZORDER = 0x0004
SWP_NOREDRAW = 0x0008
SWP_NOACTIVATE = 0x0010
SWP_FRAMECHANGED = 0x0020
SWP_SHOWWINDOW = 0x0040
SWP_HIDEWINDOW = 0x0080
SWP_NOCOPYBITS = 0x0100
SWP_NOOWNERZORDER = 0x0200
SWP_NOSENDCHANGING = 0x0400
SWP_DRAWFRAME = SWP_FRAMECHANGED
SWP_NOREPOSITION = SWP_NOOWNERZORDER
HWND_TOP = 0
HWND_BOTTOM = 1
HWND_TOPMOST = -1
HWND_NOTOPMOST = -2
user32 = windll.user32
IsIconic = user32.IsIconic
IsZoomed = user32.IsZoomed
ShowWindow = user32.ShowWindow
GetWindowRect = user32.GetWindowRect
SetWindowPos = user32.SetWindowPos
GetForegroundWindow = user32.GetForegroundWindow
SetForegroundWindow = user32.SetForegroundWindow
class RECT(Structure):
_fields_ = [
('left', c_long),
('top', c_long),
('right', c_long),
('bottom', c_long),
]
def width(self): return self.right - self.left
def height(self): return self.bottom - self.top
def getSDLWindow():
return pygame.display.get_wm_info()['window']
def SDL_IsIconic():
return IsIconic(getSDLWindow())
def SDL_IsMaximized():
return IsZoomed(getSDLWindow())
def SDL_Minimize():
return ShowWindow(getSDLWindow(), SW_MINIMIZE)
def SDL_Maximize():
return ShowWindow(getSDLWindow(), SW_MAXIMIZE)
def SDL_Restore():
return ShowWindow(getSDLWindow(), SW_RESTORE)
def SDL_Show(state):
state = (SW_HIDE, SW_SHOW)[bool(state)]
return ShowWindow(getSDLWindow(), state)
def SDL_Activate():
hWnd = getSDLWindow()
if GetForegroundWindow() != hWnd:
SetForegroundWindow(hWnd)
def SDL_GetWindowPos():
rc = RECT()
GetWindowRect(getSDLWindow(), byref(rc))
return rc.left, rc.top
def SDL_GetWindowSize():
rc = RECT()
GetWindowRect(getSDLWindow(), byref(rc))
return rc.width(), rc.height()
def SDL_SetWindowPos(x, y):
return SetWindowPos(getSDLWindow(), 0, x, y, 0, 0, SWP_NOZORDER | SWP_NOSIZE)
def SDL_AlwaysOnTop(state):
zorder = (HWND_NOTOPMOST, HWND_TOPMOST)[state]
return SetWindowPos(getSDLWindow(), zorder, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE)
else:
def SDL_IsIconic():
return 0
def SDL_IsMaximized():
return 0
def SDL_Minimize():
return 0
def SDL_Maximize():
return 0
def SDL_Restore():
return 0
def SDL_Show(state):
return 0
def SDL_Activate():
pass
def SDL_GetWindowPos():
return (-1, -1)
def SDL_SetWindowPos(x, y):
return 0
def SDL_AlwaysOnTop(state):
return 0
import pygame
import sys
from pygame.locals import QUIT
from sdl_window_utils import SDL_Maximize, SDL_GetWindowSize
pygame.init()
window_surface = pygame.display.set_mode((0, 0), pygame.RESIZABLE)
print(f'Before resize: {window_surface}')
SDL_Maximize()
w, h = SDL_GetWindowSize()
window_surface = pygame.display.set_mode((w, h))
pygame.display.update()
print(f'After resize: {window_surface}')
while True:
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
pygame 1.9.6
Hello from the pygame community. https://www.pygame.org/contribute.html
Before resize: <Surface(2560x1440x32 SW)>
After resize: <Surface(2576x1416x32 SW)>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question