Created
February 6, 2023 11:05
-
-
Save 8Observer8/213c5119d1302805e9ee4be12c9885ff to your computer and use it in GitHub Desktop.
Button over OpenGL canvas in PyQt6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from OpenGL.GL import * | |
from PyQt6.QtCore import QSize, Qt | |
from PyQt6.QtOpenGLWidgets import QOpenGLWidget | |
from PyQt6.QtWidgets import QApplication, QPushButton, QVBoxLayout | |
class OpenGLWidget(QOpenGLWidget): | |
def __init__(self): | |
super().__init__() | |
self.setFixedSize(QSize(300, 300)) | |
self.setWindowTitle("OpenGL, PyQt6, Python") | |
vbox = QVBoxLayout() | |
button = QPushButton("My Button") | |
vbox.addWidget(button) | |
self.setLayout(vbox) | |
def initializeGL(self): | |
glClearColor(0.2, 0.3, 0.2, 1) | |
def paintGL(self): | |
glClear(GL_COLOR_BUFFER_BIT) | |
if __name__ == "__main__": | |
QApplication.setAttribute(Qt.ApplicationAttribute.AA_UseDesktopOpenGL) | |
app = QApplication(sys.argv) | |
widget = OpenGLWidget() | |
widget.show() | |
sys.exit(app.exec()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment