#!/usr/bin/env python
import pygame
from pygame.locals import *
#center screen
import os
#os.environ["SDL_VIDEO_CENTERED"] = "1" ## (UN)COMMENT TO SEE EFFECT
# WITH os.environ["SDL_VIDEO_CENTERED"] = "1" :
#when maximized: window does not make it to the top -> half of the taskbars
height??
#when resizing: need new screen (with new size), which pops the window back
to the middle
# WHAT! oh NO! (and writing os.environ["SDL_VIDEO_CENTERED"] = "0" there
does NOT work,
#the window is already initialised WITH those paramaters I guess)
# withOUT os.environ["SDL_VIDEO_CENTERED"] = "1" :
#resizing goes as planned, maximizing works normally, BUT! the screen starts
in the top left corner
# (or closelyby) WHAT! oh NO!
#my goal? to have a window at least under W32 (but preferably
crossplatform!), behave well,
# like a normal window?
#I want my user to have a fresh window put in the middle, he places it
somewhere, resize it #somewhat, and then, when the user closes the window: i
save the settings, so I start up at the
#same place, same size, next time! now, THATS service!
#any ideas???
#init pygame
pygame.init()
#load bmp as icon, black as transparancy key
try:
rawicon=pygame.image.load('icon.bmp')
except: #no icon found
rawicon=pygame.Surface((32,32))
rawicon.fill((0,0,0))
icon=pygame.Surface(rawicon.get_size())
icon.set_colorkey((0,0,0))
for i in range(0,rawicon.get_height()):
for j in range(0,rawicon.get_width()):
icon.set_at((i,j), rawicon.get_at((i,j)))
pygame.display.set_icon(icon)
#init screen
screen=pygame.display.set_mode((250,250), RESIZABLE)
pygame.display.set_caption("test")
mousecount=0 #to filter some mouse events
while 1:#loop till death:
#handle user input:
for event in pygame.event.get():#loop all events pygame detected:
#pgs.checkinput(event)
if event.type == QUIT: # detect user break/closewindowevent
print "close"
raise SystemExit
elif event.type == KEYDOWN and event.key == K_ESCAPE: #detect escape
print "escape"
raise SystemExit
elif event.type == VIDEORESIZE:#user changed screensize
print "resize from " + str(screen.get_size()) + " to "+
str(event.size)
screen=pygame.display.set_mode(event.size, RESIZABLE)
elif event.type == MOUSEMOTION:
if mousecount%250==0:#only show if mousecount/250 has no left
overs
print str(event)
mousecount+=1
else:
print str(event)
pygame.display.flip() # show screen
_________________________________________________________________
Help yourself to FREE treats served up daily at the Messenger Café. Stop by
today!
http://www.cafemessenger.com/info/info_sweetstuff2.html?ocid=TXT_TAGHM_OctHMtagline