08/01/08 01:45:06 3fTMIMrl.net
>>210
wiki に載ってるコードはwindowsだとだめなのかな。
os.environ['SDL_WINDOWID'] で環境変数いじってもpygame側に反映されないっぽい。
ctypes で putenv したらうまくいきました。
---- begin ----
$ diff -up wxpygametest.py.orig wxpygametest.py
--- wxpygametest.py.orig 2008-01-08 01:39:43.607875000 +0900
+++ wxpygametest.py 2008-01-08 01:40:18.717250000 +0900
@@ -2,6 +2,7 @@ import wx
import os
import thread
global pygame # when we import it, let's keep its proper name!
+import ctypes
class SDLThread:
def __init__(self,screen):
@@ -37,8 +38,8 @@ class SDLPanel(wx.Panel):
global pygame
wx.Panel.__init__(self, parent, ID, size=tplSize)
self.Fit()
- os.environ['SDL_WINDOWID'] = str(self.GetHandle())
- os.environ['SDL_VIDEODRIVER'] = 'windib'
+ ctypes.cdll.msvcrt._putenv("SDL_VIDEODRIVER=windib")
+ ctypes.cdll.msvcrt._putenv("SDL_WINDOWID=%d" % (self.GetHandle()))
import pygame # this has to happen after setting the environment variables.
pygame.display.init()
window = pygame.display.set_mode(tplSize)
---- end ----