[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] wx Menu
import wx
import thread
import os, sys
global pygame
from pygame.locals import *
class SDLThread:
def __init__(self,screen):
self.m_bKeepGoing = self.m_bRunning = False
self.screen = screen
self.color = (255,0,0)
self.rect = (10,10,100,100)
def Start(self):
self.m_bKeepGoing = self.m_bRunning = True
thread.start_new_thread(self.Run, ())
def Stop(self):
self.m_bKeepGoing = False
def IsRunning(self):
return self.m_bRunning
def Run(self):
while self.m_bKeepGoing:
GetInput()
Draw()
self.m_bRunning = False;
class SDLPanel(wx.Panel):
def __init__(self,parent,ID,tplSize):
#I'm guessing it goes somewhere in here, but I don't know if that is true
#and how I should do it. I already tried some things, but they didn't work.
global pygame
wx.Panel.__init__(self, parent, ID, size=tplSize)
self.Fit()
os.environ['SDL_WINDOWID'] = str(self.GetHandle())
os.environ['SDL_VIDEODRIVER'] = 'windib'
import pygame
pygame.init()
icon = pygame.Surface((1,1));icon.set_alpha(0);pygame.display.set_icon(icon)
global Surface
Surface = pygame.display.set_mode(tplSize)
WindowInit()
self.thread = SDLThread(Surface)
self.thread.Start()
def __del__(self):
self.thread.Stop()
class MyFrame(wx.Frame):
def __init__(self, parent, ID, strTitle, tplSize):
wx.Frame.__init__(self, parent, ID, strTitle, size=tplSize)
self.pnlSDL = SDLPanel(self, -1, tplSize)
#self.Fit()
if __name__ == '__main__':
app = wx.PySimpleApp()
Title = "The Programmer's Paint - v.6.0.0 - Ian Mallett - 2008"
frame = MyFrame(None, wx.ID_ANY, Title, (800,600))
frame.Show()
app.MainLoop()
I edited this code a little, putting only the stuff that is relevant. I'm aware that that is what I must do, but I have no idea how.
I