pyopengltk icon indicating copy to clipboard operation
pyopengltk copied to clipboard

cannot import name 'OpenGLFrame' from 'pyopengltk' | MacOS |

Open ajh123 opened this issue 4 years ago • 1 comments

@jonwright , @einarf Im running Python 3.7.3 on macOS Catalina, I tried to import the OpenGLFrame like this

from OpenGL import GL
from pyopengltk import OpenGLFrame

Which resulted in this error cannot import name 'OpenGLFrame' from 'pyopengltk'

Edit: after that i tried to make a frame like this

class AppOgl(OpenGLFrame):

	def initgl(self):
		"""Initalize gl states when the frame is created"""
		GL.glViewport(0, 0, self.width, self.height)
		GL.glClearColor(0.0, 1.0, 0.0, 0.0)    
		self.start = time.time()
		self.nframes = 0

	def redraw(self):
		"""Render a single frame"""
		GL.glClear(GL.GL_COLOR_BUFFER_BIT)
		tm = time.time() - self.start
		self.nframes += 1
		print("fps",self.nframes / tm, end="\r" )


if __name__ == '__main__':
	root = tkinter.Tk()
	app = AppOgl(root, width=320, height=200)
	app.pack(fill=tkinter.BOTH, expand=tkinter.YES)
	app.animate = 1
	app.after(100, app.printContext)
	app.mainloop()

Edit 2 : Which still resulted in this error cannot import name 'OpenGLFrame' from 'pyopengltk'

Edit 3: I used pip to install this

ajh123 avatar May 14 '20 10:05 ajh123

Yep. There is still work ongoing to support OS X for the tk window. I think the version I tried to make was using CGL, but I think I'll have to try again using AGL: https://github.com/jonwright/pyopengltk/pull/11

Do feel free to give it a go yourself if you need OS X support. A lot can for example be learned from looking at how pyglet uses AGL when creating OS X context.

einarf avatar May 14 '20 12:05 einarf