[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] how do I maximize the window?
- To: pygame-users@xxxxxxxx
- Subject: Re: [pygame] how do I maximize the window?
- From: inhahe <inhahe@xxxxxxxxx>
- Date: Sun, 14 Oct 2007 10:01:32 -0400
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: pygame-users-outgoing@xxxxxxxx
- Delivered-to: pygame-users@xxxxxxxx
- Delivery-date: Sun, 14 Oct 2007 10:01:41 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=gj2vjcPCKQzF+byl0nnuIok0xsc0L2KTMvfepk7THy4=; b=R+gwF5VgckQtgJSDMk9kBTAYbde8C0P8TmddJ1HYovpxPleSrOoYIKJH7EEpDy6/NzB/Ul1PViGAJ4m0E+c3zoK1nSWD5iNeSPCd21HofB/SCPSQxlVMAwdOOAGS3XfoEBci9Phm0+dPr2W3ndfChpnU1t6o8R6nK762m4OUo9I=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=mepuH5ciloEWzq3Az+pPmgXFwSu/I/jNzMEqdYuP7amnFc8ktoCrRdXJWxh6Abxxsq+uShPYr1kFkmn8C3hEj9jN2Rz+9CefOrCV9ZpPl+RF/xsc5dTWtCEH0hW32mOUCKslky+GZ300TaFPZNmqhXH5+CIFpDSdjA6wm9lktNY=
- In-reply-to: <20071014112533.GP17896@xxxxxxxxxx>
- References: <loom.20071014T045252-373@xxxxxxxxxxxxxx> <20071014112533.GP17896@xxxxxxxxxx>
- Reply-to: pygame-users@xxxxxxxx
- Sender: owner-pygame-users@xxxxxxxx
hmm, I'm having a problem with this. when i maximize, the title bar
goes into the right place, etc., but the actual viewing space is a
little too far up. it stops, with no border, a few pixels above the
taskbar, and starts a few pixels above the title bar but behind it so
stuff is covered up by the title bar. is there any solution to this?
On 10/14/07, John Popplewell <john@xxxxxxxxxxxxxxxxxxxxxx> wrote:
> On Sun, Oct 14, 2007 at 04:55:14AM +0000, Richard wrote:
> > How do I maximize the pygame window or start it maximized? not fullscreen, just
> > maximized. by code, not by clicking on the maximize button. i can't find a way
> > to do this. if there's really not a way to do it, that's kind of disappointing.
> Hi,
>
> you can't using a built-in Pygame function. There is iconify() but no
> corresponding restore() or maximize(). It is a limitation of the
> underlying SDL library, which is being fixed in SDL-1.3 (or SDL-2).
>
> For now, I use the ctypes module to call the platform-specific
> functions:
>
> 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_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
>
>
> I don't have any code for X, but I don't believe it's much more
> complicated.
>
> Equivalent functions could be added to Pygame with support for other
> Windowing systems,
>
> regards,
> John.
>
>