Package glitter :: Package contexts :: Module qt
[hide private]
[frames] | no frames]

Source Code for Module glitter.contexts.qt

 1  """Qt context creation and management. 
 2   
 3  @author: Stephan Wenger 
 4  @date: 2012-02-29 
 5  """ 
 6   
 7  try: 
 8      from PySide import QtOpenGL 
 9  except ImportError: 
10      from PyQt4 import QtOpenGL 
11   
12  from glitter.contexts.context import Context 
13   
14 -class QtContextWrapper(Context):
15 - def __init__(self, context):
16 super(QtContextWrapper, self).__init__(self) 17 if isinstance(context, QtOpenGL.QGLContext): 18 self._qt_context = context 19 else: 20 self._qt_context = context.context()
21
22 - def _bind(self):
23 self._qt_context.makeCurrent()
24
25 -class QtWidget(QtOpenGL.QGLWidget, Context):
26 - def __init__(self, *args, **kwargs):
27 QtOpenGL.QGLWidget.__init__(self, *args, **kwargs) 28 with self: 29 Context.__init__(self)
30
31 - def _bind(self):
32 self.makeCurrent()
33