Advertisement
Guest User

Untitled

a guest
Jul 28th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. # pygame always background
  2. # Emanuele Ruffaldi 2016
  3. import sys, pygame
  4. import win32gui, win32con
  5. import sys, ctypes
  6.  
  7. class WINDOWPOS(ctypes.Structure):
  8. _fields_ = [
  9. ('hwnd', ctypes.c_ulong),
  10. ('hwndInsertAfter', ctypes.c_ulong),
  11. ('x', ctypes.c_int),
  12. ('y', ctypes.c_int),
  13. ('cx', ctypes.c_int),
  14. ('cy', ctypes.c_int),
  15. ('flags', ctypes.c_ulong)
  16. ]
  17.  
  18. def mywndproc(oldWndProc, hWnd, msg, wParam, lParam):
  19. if msg == win32con.WM_WINDOWPOSCHANGING:
  20. pos = WINDOWPOS.from_address(lParam)
  21. pos.hwndInsertAfter = win32con.HWND_BOTTOM
  22. elif msg == win32con.WM_DESTROY:
  23. win32gui.SetWindowLong(hWnd,win32con.GWL_WNDPROC,oldWndProc)
  24. return win32gui.CallWindowProc(oldWndProc, hWnd, msg, wParam, lParam)
  25.  
  26. def main():
  27. pygame.init()
  28. size = width, height = 320, 240
  29. speed = [2, 2]
  30. black = 0, 0, 0
  31.  
  32. screen = pygame.display.set_mode(size)
  33.  
  34. info = pygame.display.get_wm_info() #retriving dei dati dell'oggetto display
  35. HWND = info["window"] #quello che ci serve la voce window.
  36. win32gui.SetWindowPos(HWND,win32con.HWND_BOTTOM, 0, 0, 0, 0,win32con.SWP_NOMOVE + win32con.SWP_NOSIZE) #comunicazione al sistema operativo della posizione della finestra.
  37.  
  38. # super trick to avoid global
  39. oldWndProc = [None]
  40. oldWndProc[0] = win32gui.SetWindowLong(HWND,win32con.GWL_WNDPROC,lambda hWnd,msg,wParam,lParam: mywndproc(oldWndProc[0],hWnd,msg,wParam,lParam))
  41.  
  42. while 1:
  43. for event in pygame.event.get():
  44. if event.type == pygame.QUIT:
  45. sys.exit(0)
  46.  
  47. screen.fill(black)
  48. pygame.display.flip()
  49.  
  50.  
  51. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement