PDA

View Full Version : Python: asking the desktop for an updated value



OgreProgrammer
January 25th, 2010, 12:23 PM
I can set my window start location(line 4), but when the user moves it, I dont know how to get the updated value(line 14). I know its probably in gtk+ somewhere, but that is just immense. I'm having a little trouble sorting through it.

My eventual goal is to have the user move the window into place, then I will write that location to a config file, and turn off the window decorator. Using that value I will draw a section of the desktop wallpaper to simulate a transparent background.

When the application is restarted it will thus be locked into place. I'll draw effects into that window, enhancing my desktop.

Basically I am customizing my desktop.



import pygame
import os

# this passes the string as values... to somewhere?
os.environ['SDL_VIDEO_WINDOW_POS'] = "200, 200"

pygame.init()
try:
screen = pygame.display.set_mode((400, 400))
# This should show a blank 200 by 200 window centered on the screen
pygame.display.flip()

while True:
event = pygame.event.wait()
if event.type == pygame.QUIT:
# it is not updated though. What holds the current value?
print os.environ['SDL_VIDEO_WINDOW_POS']
break
finally:
pygame.quit()

lavinog
January 29th, 2010, 06:10 PM
There are external ways to query X to get window positions.


xwininfo -name WindowTitle

Probably not the best way to go about this, but it should be a start.

OgreProgrammer
January 29th, 2010, 11:54 PM
Hey thanks lavinog.