#!/usr/bin/python # updated may8th 2011 import os, sys, ctypes, thread if '..' not in sys.path: sys.path.append('..') import rpythonic freenect = rpythonic.module('libfreenect_sync') assert freenect cvaux = rpythonic.module('cvaux') assert cvaux gui = rpythonic.module('highgui', secondary=cvaux) assert gui cv = rpythonic.module('cv', secondary=gui) assert cv import time IPL_DEPTH_16S = 2147483664 IPL_DEPTH_8S = 2147483656 CV_WHOLE_SEQ = cv.CvSlice(0, 9999999) lock = thread.allocate_lock() class Shape(object): HAND = None storage_hull = cv.CreateMemStorage(0) storage_defects = cv.CreateMemStorage(0) def touches(self, other): pt1, pt2 = self.rectangle
#!/usr/bin/python #!../../pypy-1.6/bin/pypy import os, sys, time, subprocess, ctypes if ".." not in sys.path: sys.path.append("..") import rpythonic gtk = rpythonic.module("gtk") assert gtk gtk.init() wnck = rpythonic.module("wnck") assert wnck def glist(addr): class _GList(ctypes.Structure): _fields_ = [("data", ctypes.c_void_p), ("next", ctypes.c_void_p)] l = addr while l: print("addr", l) l = _GList.from_address(l) yield l.data l = l.next def glist2list(glist): global X
#!/usr/bin/python # july 21, 2011 import os,sys, time, ctypes if '..' not in sys.path: sys.path.append( '..' ) import rpythonic irr = rpythonic.module( 'Irrlicht' ) assert irr driverType = irr.E_DRIVER_TYPE['EDT_OPENGL'] windowSize = irr.dimension2du(0, 0, 0) ier = irr.IEventReceiver() abstract = irr.createDevice(driverType, windowSize, 16) #, False, False, False, ier) dev = irr.CIrrDeviceLinux( abstract ) abstract = dev.getVideoDriver() driver = irr.COpenGLDriver( abstract ) #driver = irr.CNullDriver( abstract ) # scolor still random? abstract = dev.getSceneManager() man = irr.CSceneManager( abstract ) scolor = irr.SColor() scolor.set( 255, 0, 0, 128 ) # should be blue - color becomes random? assert scolor.getBlue() == 128 def draw(): if dev.isWindowActive(): print( 'drawing' ) driver.beginScene(True, True, scolor) # wrong color? man.drawAll()
#!/usr/bin/python import os, sys, time, subprocess import wnck # apt-get install gnome-python-extras if '..' not in sys.path: sys.path.append('..') import rpythonic gtk = rpythonic.module('gtk') assert gtk gtk.init() class MultiBlender(object): def __init__(self, blenders=2): self._num_blenders = blenders self._not_ready = self._num_blenders self._waiting = False self._window = win = gtk.Window( ) #gtk.window_new( gtk.GTK_WINDOW_TOPLEVEL ) self._screen = wnck.screen_get_default() print(win) #win.set_title( 'ctypes_ooapi_gtk_test') # segfaults, name too long? win.set_title('GtkBlender') #win.set_default_size( 640, 480 ) win.set_border_width(2) win.connect('destroy', lambda *args: gtk.main_quit()) frame = gtk.Frame() win.add(frame) frame.set_border_width(4) self._notebook = note = gtk.Notebook()
class NaaliClientHandler(circuits.Component): def __init__(self): circuits.Component.__init__(self) self.client = Client() @circuits.handler("update") def update(self, deltatime): #print('delta', deltatime) if self.client.active: self.client.iterate() if '..' not in sys.path: sys.path.append('..') import rpythonic _rfb_ = rpythonic.module('vncserver') _rfbclient_ = rpythonic.module('vncclient') assert _rfb_ assert _rfbclient_ if PyQt4: class VncServerWindow(QtGui.QWidget): def closeEvent(self, ev): self._server.exit() ev.accept() class _VNCServer_antialias(QtGui.QCheckBox): def mouseReleaseEvent(self, ev): QtGui.QCheckBox.mouseReleaseEvent(self, ev) on = self.isChecked()
#!/usr/bin/python #!../../pypy-1.6/bin/pypy import os, sys, time, subprocess, ctypes if '..' not in sys.path: sys.path.append('..') import rpythonic gtk = rpythonic.module('gtk') assert gtk gtk.init() wnck = rpythonic.module('wnck') assert wnck def glist(addr): class _GList(ctypes.Structure): _fields_ = [('data', ctypes.c_void_p), ('next', ctypes.c_void_p)] l = addr while l: print('addr', l) l = _GList.from_address(l) yield l.data l = l.next def glist2list(glist): global X X = glist r = []
self.server.iterate() class NaaliClientHandler(circuits.Component): def __init__(self): circuits.Component.__init__(self) self.client = Client() @circuits.handler("update") def update(self, deltatime): #print('delta', deltatime) if self.client.active: self.client.iterate() if '..' not in sys.path: sys.path.append( '..' ) import rpythonic _rfb_ = rpythonic.module( 'vncserver' ) _rfbclient_ = rpythonic.module( 'vncclient' ) assert _rfb_ assert _rfbclient_ if PyQt4: class VncServerWindow( QtGui.QWidget ): def closeEvent( self, ev ): self._server.exit() ev.accept() class _VNCServer_antialias(QtGui.QCheckBox): def mouseReleaseEvent(self,ev): QtGui.QCheckBox.mouseReleaseEvent(self,ev) on = self.isChecked(); print( on ) self._server._antialias = on
#!/usr/bin/python # updated may8th 2011 import os, sys, ctypes, thread if '..' not in sys.path: sys.path.append( '..' ) import rpythonic freenect = rpythonic.module( 'libfreenect_sync' ) assert freenect cvaux = rpythonic.module( 'cvaux' ) assert cvaux gui = rpythonic.module( 'highgui', secondary=cvaux ) assert gui cv = rpythonic.module( 'cv', secondary=gui ) assert cv import time IPL_DEPTH_16S = 2147483664 IPL_DEPTH_8S = 2147483656 CV_WHOLE_SEQ = cv.CvSlice(0,9999999) lock = thread.allocate_lock() class Shape(object): HAND = None storage_hull = cv.CreateMemStorage(0) storage_defects = cv.CreateMemStorage(0) def touches( self, other ): pt1, pt2 = self.rectangle if other.rectangle[0] == pt1 or other.rectangle[1] == pt2: if other not in self.touching: self.touching.append( other )
#!/usr/bin/python import os,sys, time, subprocess import wnck # apt-get install gnome-python-extras if '..' not in sys.path: sys.path.append( '..' ) import rpythonic gtk = rpythonic.module( 'gtk' ) assert gtk gtk.init() class MultiBlender(object): def __init__(self, blenders=2): self._num_blenders = blenders self._not_ready = self._num_blenders self._waiting = False self._window = win = gtk.Window() #gtk.window_new( gtk.GTK_WINDOW_TOPLEVEL ) self._screen = wnck.screen_get_default() print( win ) #win.set_title( 'ctypes_ooapi_gtk_test') # segfaults, name too long? win.set_title('GtkBlender') #win.set_default_size( 640, 480 ) win.set_border_width( 2 ) win.connect( 'destroy', lambda *args: gtk.main_quit() ) frame = gtk.Frame() win.add( frame ) frame.set_border_width( 4 ) self._notebook = note = gtk.Notebook() frame.add( note ) self._pages = []
#!/usr/bin/python # july 21, 2011 import os, sys, time, ctypes if '..' not in sys.path: sys.path.append('..') import rpythonic ogre = rpythonic.module('Ogre') assert ogre # defaults: pluginFileName = "plugins.cfg" , configFileName = "ogre.cfg" , logFileName = "Ogre.log" root = ogre.Root('data/plugins.cfg', 'data/ogre.cfg', 'data/ogre.log') root.showConfigDialog() win = root.initialise(True, 'mywindow') win.setActive(True) man = root.createSceneManager('OctreeSceneManager', 'mymanager') cam = man.createCamera('mycamera') cam.setPosition(0, 0, 100) cam.lookAt(0, 0, 0) view = win.addViewport(cam) bg = view.getBackgroundColour() bg.setHSB(0.5, 0.5, 0.9) #Set a colour value from Hue, Saturation and Brightness. view.setBackgroundColour(bg) rgman = ogre.ResourceGroupManager.getSingleton() rgman.addResourceLocation('./data', 'FileSystem', 'General') # can be FileSystem or Zip rgman.initialiseAllResourceGroups() rootnode = man.getRootSceneNode()
#!/usr/bin/python # july 21, 2011 import os, sys, time, ctypes if '..' not in sys.path: sys.path.append('..') import rpythonic irr = rpythonic.module('Irrlicht') assert irr driverType = irr.E_DRIVER_TYPE['EDT_OPENGL'] windowSize = irr.dimension2du(0, 0, 0) ier = irr.IEventReceiver() abstract = irr.createDevice(driverType, windowSize, 16) #, False, False, False, ier) dev = irr.CIrrDeviceLinux(abstract) abstract = dev.getVideoDriver() driver = irr.COpenGLDriver(abstract) #driver = irr.CNullDriver( abstract ) # scolor still random? abstract = dev.getSceneManager() man = irr.CSceneManager(abstract) scolor = irr.SColor() scolor.set(255, 0, 0, 128) # should be blue - color becomes random? assert scolor.getBlue() == 128 def draw(): if dev.isWindowActive():
#!/usr/bin/python # july 21, 2011 import os,sys, time, ctypes if '..' not in sys.path: sys.path.append( '..' ) import rpythonic ogre = rpythonic.module( 'Ogre' ) assert ogre # defaults: pluginFileName = "plugins.cfg" , configFileName = "ogre.cfg" , logFileName = "Ogre.log" root = ogre.Root('data/plugins.cfg', 'data/ogre.cfg', 'data/ogre.log') root.showConfigDialog() win = root.initialise( True, 'mywindow' ) win.setActive(True) man = root.createSceneManager('OctreeSceneManager', 'mymanager') cam = man.createCamera( 'mycamera' ) cam.setPosition( 0, 0, 100 ) cam.lookAt( 0, 0, 0 ) view = win.addViewport( cam ) bg = view.getBackgroundColour() bg.setHSB( 0.5, 0.5, 0.9 ) #Set a colour value from Hue, Saturation and Brightness. view.setBackgroundColour( bg ) rgman = ogre.ResourceGroupManager.getSingleton() rgman.addResourceLocation( './data', 'FileSystem', 'General' ) # can be FileSystem or Zip rgman.initialiseAllResourceGroups() rootnode = man.getRootSceneNode() e = man.createEntity( 'mycube', 'Cube.mesh', groupName='General' ) node = rootnode.createChildSceneNode( ogre.Vector3(), ogre.Quaternion() )