1

Do PyQT or Pyside support OpenGL button/general widget overlays (I'm looking for something similar to this screenshot of FlashPrint ?

enter image description here

I'm having trouble even googling this as I don't know what to call it. Is overlay the correct term here? Also, if neither PyQT or Pyside support this are there any Python based GUI's that allow for this?

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
Chris Uchytil
  • 140
  • 1
  • 11
  • QOpenGlxxx does not support that no widget is on top of them. – eyllanesc Jun 20 '18 at 21:55
  • Are there any python based GUI's that allow for rendering with interactive overlays? I'm not tied to OpenGL (although sticking with it would be nice). – Chris Uchytil Jun 20 '18 at 22:32
  • see this: https://stackoverflow.com/questions/19199863/draw-rectangular-overlay-on-qwidget-at-click – eyllanesc Jun 20 '18 at 22:33
  • Thanks for the reference. The hope was to move towards a more advanced widgets (for reference https://austcadblog.files.wordpress.com/2013/11/fusion-360-1.png). If implementing this becomes overly complex I am willing to find an alternative to OpenGL. Are there any Python based GUI's that support this natively? – Chris Uchytil Jun 20 '18 at 22:43
  • I do not know, I do not know. – eyllanesc Jun 20 '18 at 22:44

3 Answers3

1

I don't know if it's still an actual question, but anyway:

If you're using QOpenGLWidget (which is recommended in newer Qt versions) you can create any of existing layouts as you would normally do with a QWidget and add your custom button into it. Here's (as an example) how it would like: enter image description here As you can see, I added a custom and fully interactive bar inherited from QWidget on top of green QOpenGLWidget on the left.

Also worth to mention, that you can specify Qt surface format to force use of OpenGl window rendering, using specific versions. Also if you would like to use OpenGL in your application add an attribute QApplication.setAttribute(Qt.AA_UseDesktopOpenGL) to use desktop OpenGL.

Artem
  • 563
  • 3
  • 17
0

Generally mixing OpenGL renders and OS renders (used for buttons or other controls) is not a good idea.

One solution is draw first the controls (better in memory) and get a "screen shot" of it. Then do OpenGL rendering. Then pass the image to OpenGL and render it on top of the previous renders. The drawback is that you loose all control reaction, they become just images.

The other way may work better. First render OpenGL. Then get that image (by for example glReadPixels). Then blit the image as a background. Then draw the controls.

Ripi2
  • 7,031
  • 1
  • 17
  • 33
  • The plan was to start small with buttons and work to something more advanced like this fusion 360 interface (https://austcadblog.files.wordpress.com/2013/11/fusion-360-1.png). When I say I want an overlay I simply mean I want the buttons to be within the bounds of the OpenGL window like both of these examples. Do the examples I list using something other than OpenGL to do the rendering to then allow them to overlay GUI elements? – Chris Uchytil Jun 20 '18 at 20:09
0

enter image description here

main.py

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())
8Observer8
  • 868
  • 10
  • 17