# Created by Leo from: C:\Python23\Tom\leo\pyro.leo # << Cameratest declarations >> import Image import image_view import threading import rserve,pickle #import ArgImagePlugin,BmpImagePlugin,BufrStubImagePlugin,CurImagePlugin,DcxImagePlugin,EpsImagePlugin,FitsStubImagePlugin,FliImagePlugin,FpxImagePlugin,GbrImagePlugin,GifImagePlugin,GribStubImagePlugin,Hdf5StubImagePlugin,IcoImagePlugin,ImImagePlugin,ImtImagePlugin,IptcImagePlugin,JpegImagePlugin,McIdasImagePlugin,MicImagePlugin,MpegImagePlugin,MspImagePlugin,PalmImagePlugin,PcdImagePlugin,PcxImagePlugin,PdfImagePlugin,PixarImagePlugin,PngImagePlugin,PpmImagePlugin,PsdImagePlugin,SgiImagePlugin,SunImagePlugin,TgaImagePlugin,TiffImagePlugin,WmfImagePlugin,XbmImagePlugin,XpmImagePlugin,XVThumbImagePlugin import wx import time, string,bz2 import wx.lib.evtmgr as EventManager # -- end -- << Cameratest declarations >> # << Cameratest methods >> (1 of 2) class MyFrame(wx.Frame): # << class MyFrame methods >> (1 of 9) def __init__(self, parent, id, title): wx.Frame.__init__(self, parent, id, title, wx.DefaultPosition, wx.DefaultSize) tb = wx.ToolBar(self, -1, wx.DefaultPosition, wx.DefaultSize, wx.TB_HORIZONTAL| wx.NO_BORDER| wx.TB_FLAT) self.cam = dictofpyro['Camera2'] self.Bind(wx.EVT_CLOSE, self.OnCloseWindow, id = self.GetId()) maintimerID = wx.NewId() self.maintimer = wx.Timer(self, maintimerID) self.Bind(wx.EVT_TIMER, self.OnTimer, id=maintimerID)#EVT_TIMER(self, maintimerID, self.OnTimer) self.glob_thing = image_view.ImageView(self, -1) #self.splitter.SetMinimumPaneSize(20) #self.splitter.SplitHorizontally(self.glob_thing, self.text_thing, 0) self.imglst = [] self.imgiter = iter(self.imglst) self.itercount = 0 StartButtonID = wx.NewId() self.StartButton = wx.Button(tb, StartButtonID, "Go", wx.Point(20, 20)) #EVT_BUTTON(self, StartButtonID, self.OnGoClick) self.StartButton.SetBackgroundColour(wx.BLUE) self.StartButton.SetForegroundColour(wx.WHITE) self.StartButton.SetDefault() StopButtonID = wx.NewId() self.StopButton = wx.Button(tb, StopButtonID, "Stop", wx.Point(260, 20)) #EVT_BUTTON(self, StopButtonID, self.OnStopClick) self.StopButton.SetBackgroundColour(wx.RED) self.StopButton.SetForegroundColour(wx.WHITE) #cbID = wx.NewId() tb.AddControl(self.StartButton) self.Bind(wx.EVT_BUTTON, self.OnGoClick, id=StartButtonID) tb.AddSeparator() #cbID = wx.NewId() tb.AddControl(self.StopButton) self.Bind(wx.EVT_BUTTON, self.OnStopClick, id=StopButtonID) tb.AddSeparator() tb.AddSeparator() self.SetToolBar(tb) tb.Realize() # << class MyFrame methods >> (2 of 9) def OnTimer(self, event): #if self.itercount == 7: # bzthread = threading.Thread( group=None, target=self.getbz, name=None, args=(), kwargs={}) # bzthread.start() try: self.glob_thing.set_image(self.imgiter.next()) self.itercount = self.itercount + 1 except StopIteration: self.itercount = 0 self.getbz() self.glob_thing.set_image(self.imgiter.next()) # << class MyFrame methods >> (3 of 9) def getbz(self): self.imglst = [] tmpimg = pickle.loads(self.cam.OnPak()) lastimg = Image.fromstring('RGB',(160, 120),bz2.decompress(tmpimg[10])) for i in range(9): img = Image.fromstring('RGB',(160, 120),bz2.decompress(tmpimg[1])) im2 = Image.blend(lastimg,img,.5) self.imglst.append(im2) self.imgiter = iter(self.imglst) # << class MyFrame methods >> (4 of 9) def OnCombo(self, event): #print event.GetInt() self.cyclenum = event.GetInt() # << class MyFrame methods >> (5 of 9) def OnSavedir(self, event): #print event.GetInt() self.OnSavedir = event.GetString() # << class MyFrame methods >> (6 of 9) def OnDiffdir(self, event): #print event.GetInt() self.diffsavedir = event.GetString() # << class MyFrame methods >> (7 of 9) def OnCloseWindow(self, event): rserve.close() self.Destroy() # << class MyFrame methods >> (8 of 9) def OnGoClick(self, event): self.maintimer.Start(91) # << class MyFrame methods >> (9 of 9) def OnStopClick(self, event): self.maintimer.Stop() # -- end -- << class MyFrame methods >> # << Cameratest methods >> (2 of 2) class MyApp(wx.App): # << class MyApp methods >> def OnInit(self): # Create an instance of our customized Frame class frame = MyFrame(None, -1, "Transmition reception center") frame.Show(True) # Tell wxWindows that this is our main window self.SetTopWindow(frame) # Return a success flag return True # -- end -- << class MyApp methods >> # -- end -- << Cameratest methods >> #flnm = file('c:\\python23\\tom3\\pyro\\rserve\\Pyro_NS_URI') #read uri #outfle = file('c:\\python23\\snakelets\\webapps\\ROOT\\Pyro_NS_URI','w+')#write to servet #conntxt = flnm.readline() #outfle.write(conntxt) #dictofpyro = rserve.connect(conntxt) dictofpyro = rserve.connect(None)#Broadcast connect dictofpyro.log("connection from Camera") #flnm.close() #outfle.close() app = MyApp(0) # Create an instance of the application class app.MainLoop() # Tell it to start processing events