Не могу активировать OpenGLWidget

Нужно, чтобы по нажатию кнопки выводился рисунок на элемент OpenGL. (Модуль отрисовки обязательно должен быть импортирован)

main.py

# !/usr/bin/env python3

import sys

# Connecting modules for programmatic access to window elements
from PyQt5 import QtCore, QtGui, QtWidgets

# A module for accessing elements of the XML markup of a UI file
from PyQt5 import uic

from OpenGL.GL import *
from OpenGL.GLU import *
from OpenGL.GLUT import *

import create_draft


# Main window class
class MainWindow(QtWidgets.QMainWindow):
    def __init__(self):
        super().__init__()

        # Loading the window markup file
        uic.loadUi("minimal.ui", self)

        # Creating a flow for real-time pyopengl draw
        self.push_button_create_draft.clicked.connect(lambda: create_draft.create(self))


# Start, if the application is in the main thread
if __name__ == "__main__":
    app = QtWidgets.QApplication(sys.argv)
    window = MainWindow()
    window.show()

    # Safe shutdown of the application
    sys.exit(app.exec_())

create_draft.py

# !/usr/bin/env python3

from PyQt5 import QtCore

from OpenGL.GL import *
from OpenGL.GLU import *
from OpenGL.GLUT import *


def init():
    glEnable(GL_BLEND)
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
    glEnable(GL_DEPTH_TEST)


def load():
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
    glMatrixMode(GL_PROJECTION)
    glLoadIdentity()
    x, y, width, height = glGetDoublev(GL_VIEWPORT)
    gluPerspective(45, width / float(height or 1), 0.25, 200)

    glMatrixMode(GL_MODELVIEW)
    glLoadIdentity()

    gluLookAt(12, 12, 12, 0, 0, 0, 0, 1, 0)


def paint():
    load()
    glutWireSphere(2, 13, 13)
    

def create(self):
    width = self.openGLWidget.width()
    height = self.openGLWidget.height()

    glutInit()

    self.openGLWidget.initializeGL()
    self.openGLWidget.resizeGL(width, height)
    self.openGLWidget.initializeGL = init
    self.openGLWidget.paintGL = paint

window.ui

<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
 <class>MainWindow</class>
 <widget class="QMainWindow" name="MainWindow">
  <property name="geometry">
   <rect>
    <x>0</x>
    <y>0</y>
    <width>320</width>
    <height>240</height>
   </rect>
  </property>
  <property name="windowTitle">
   <string>MainWindow</string>
  </property>
  <widget class="QWidget" name="centralwidget">
   <widget class="QOpenGLWidget" name="openGLWidget">
    <property name="geometry">
     <rect>
      <x>-1</x>
      <y>-1</y>
      <width>321</width>
      <height>241</height>
     </rect>
    </property>
   </widget>
  </widget>
 </widget>
 <resources/>
 <connections/>
</ui>

Ответы (0 шт):