Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # pygame always background
- # Emanuele Ruffaldi 2016
- import sys, pygame
- import win32gui, win32con
- import sys, ctypes
- class WINDOWPOS(ctypes.Structure):
- _fields_ = [
- ('hwnd', ctypes.c_ulong),
- ('hwndInsertAfter', ctypes.c_ulong),
- ('x', ctypes.c_int),
- ('y', ctypes.c_int),
- ('cx', ctypes.c_int),
- ('cy', ctypes.c_int),
- ('flags', ctypes.c_ulong)
- ]
- def mywndproc(oldWndProc, hWnd, msg, wParam, lParam):
- if msg == win32con.WM_WINDOWPOSCHANGING:
- pos = WINDOWPOS.from_address(lParam)
- pos.hwndInsertAfter = win32con.HWND_BOTTOM
- elif msg == win32con.WM_DESTROY:
- win32gui.SetWindowLong(hWnd,win32con.GWL_WNDPROC,oldWndProc)
- return win32gui.CallWindowProc(oldWndProc, hWnd, msg, wParam, lParam)
- def main():
- pygame.init()
- size = width, height = 320, 240
- speed = [2, 2]
- black = 0, 0, 0
- screen = pygame.display.set_mode(size)
- info = pygame.display.get_wm_info() #retriving dei dati dell'oggetto display
- HWND = info["window"] #quello che ci serve la voce window.
- win32gui.SetWindowPos(HWND,win32con.HWND_BOTTOM, 0, 0, 0, 0,win32con.SWP_NOMOVE + win32con.SWP_NOSIZE) #comunicazione al sistema operativo della posizione della finestra.
- # super trick to avoid global
- oldWndProc = [None]
- oldWndProc[0] = win32gui.SetWindowLong(HWND,win32con.GWL_WNDPROC,lambda hWnd,msg,wParam,lParam: mywndproc(oldWndProc[0],hWnd,msg,wParam,lParam))
- while 1:
- for event in pygame.event.get():
- if event.type == pygame.QUIT:
- sys.exit(0)
- screen.fill(black)
- pygame.display.flip()
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement