Enable event loop integration with GLUT. Parameters ---------- app : ignored Ignored, it's only a placeholder to keep the call signature of all gui activation methods consistent, which simplifies the logic of supporting magics. N
(self, app=None)
| 327 | self.clear_inputhook() |
| 328 | |
| 329 | def enable_glut(self, app=None): |
| 330 | """Enable event loop integration with GLUT. |
| 331 | |
| 332 | Parameters |
| 333 | ---------- |
| 334 | |
| 335 | app : ignored |
| 336 | Ignored, it's only a placeholder to keep the call signature of all |
| 337 | gui activation methods consistent, which simplifies the logic of |
| 338 | supporting magics. |
| 339 | |
| 340 | Notes |
| 341 | ----- |
| 342 | |
| 343 | This methods sets the PyOS_InputHook for GLUT, which allows the GLUT to |
| 344 | integrate with terminal based applications like IPython. Due to GLUT |
| 345 | limitations, it is currently not possible to start the event loop |
| 346 | without first creating a window. You should thus not create another |
| 347 | window but use instead the created one. See 'gui-glut.py' in the |
| 348 | docs/examples/lib directory. |
| 349 | |
| 350 | The default screen mode is set to: |
| 351 | glut.GLUT_DOUBLE | glut.GLUT_RGBA | glut.GLUT_DEPTH |
| 352 | """ |
| 353 | |
| 354 | import OpenGL.GLUT as glut # @UnresolvedImport |
| 355 | from pydev_ipython.inputhookglut import glut_display_mode, glut_close, glut_display, glut_idle, inputhook_glut |
| 356 | |
| 357 | if GUI_GLUT not in self._apps: |
| 358 | argv = getattr(sys, "argv", []) |
| 359 | glut.glutInit(argv) |
| 360 | glut.glutInitDisplayMode(glut_display_mode) |
| 361 | # This is specific to freeglut |
| 362 | if bool(glut.glutSetOption): |
| 363 | glut.glutSetOption(glut.GLUT_ACTION_ON_WINDOW_CLOSE, glut.GLUT_ACTION_GLUTMAINLOOP_RETURNS) |
| 364 | glut.glutCreateWindow(argv[0] if len(argv) > 0 else "") |
| 365 | glut.glutReshapeWindow(1, 1) |
| 366 | glut.glutHideWindow() |
| 367 | glut.glutWMCloseFunc(glut_close) |
| 368 | glut.glutDisplayFunc(glut_display) |
| 369 | glut.glutIdleFunc(glut_idle) |
| 370 | else: |
| 371 | glut.glutWMCloseFunc(glut_close) |
| 372 | glut.glutDisplayFunc(glut_display) |
| 373 | glut.glutIdleFunc(glut_idle) |
| 374 | self.set_inputhook(inputhook_glut) |
| 375 | self._current_gui = GUI_GLUT |
| 376 | self._apps[GUI_GLUT] = True |
| 377 | |
| 378 | def disable_glut(self): |
| 379 | """Disable event loop integration with glut. |
nothing calls this directly
no test coverage detected