Use of GLViewWidget in standalone PyQt application

445 views
Skip to first unread message

Alex Hanson

unread,
Mar 5, 2014, 6:04:17 PM3/5/14
to pyqt...@googlegroups.com
I am developing a PyQt app and want the center widget to be able to view STL files.

The class which defines the widget is as follows:


class GraphicsWidget(QtGui.QFrame):

   

    def __init__(self, parent):

        super(GraphicsWidget, self).__init__(parent)

        self.initWidget()


    def initWidget(self):    

        view = gl.GLViewWidget(self)

        self.setLayout(view)


and I call it in my main gui class:

class pyEC3PO(QtGui.QMainWindow):

   
def __init__(self):
       
super(pyEC3PO, self).__init__()
       
self.initUI()

   
def initUI(self):
        #Set QMainWindow properties
       
self.setDockOptions(QtGui.QMainWindow.VerticalTabs)

       
#Create center widget
       
self.center = GraphicsWidget(self)
       
self.setCentralWidget(self.center)

       
#Set left docks
       
self.importDock = MyDocks(self, 'Import')
       
self.embedDock = MyDocks(self, 'Embed')
       
self.addDockWidget(QtCore.Qt.LeftDockWidgetArea, self.importDock)
       
self.tabifyDockWidget(self.importDock, self.embedDock)

       
#Status bar
       
self.statusBar = self.statusBar()
       
self.statusBar.showMessage('Ready')
       
self.importDock.msg2StatusBar[str].connect(self.statusBar.showMessage)


       
self.resize(800,800)
       
self.centerWindow()
       
self.setWindowTitle('My GUI!')
       
self.show()

       
def centerWindow(self):
            screen
= QtGui.QDesktopWidget().screenGeometry()
            size
= self.geometry()
           
self.move((screen.width()-size.width())/2,
               
(screen.height()-size.height())/2)



When setlayout(view) is called in GraphicsWidget, I get the following type error:

    TypeError: QWidget.setLayout(QLayout): argument 1 has unexpected type 'GLViewWidget'


The documentation only says 2D elements can be embeded in your own applications. Does anyone know how to embed the GLViewWidget? Would Vispy be a good alternative?


Thank you,

Alex

Mathew Schwartz

unread,
Mar 5, 2014, 7:09:12 PM3/5/14
to pyqt...@googlegroups.com
theres an example folder in pyqtgraph that has the implementation of a 3d example.  

Luke would have more suggestions as to using vispy or not.


--
You received this message because you are subscribed to the Google Groups "pyqtgraph" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyqtgraph+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyqtgraph/d8699094-991b-431b-9f1b-6bf2c5ccf49f%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Luke Campagnola

unread,
Mar 5, 2014, 7:40:20 PM3/5/14
to pyqt...@googlegroups.com
On Wed, Mar 5, 2014 at 6:04 PM, Alex Hanson <hanso...@gmail.com> wrote:

When setlayout(view) is called in GraphicsWidget, I get the following type error:

    TypeError: QWidget.setLayout(QLayout): argument 1 has unexpected type 'GLViewWidget'


QWidget.setLayout() expects a QLayout as its argument, bit GLViewWidget inherits from QWidget, not QLayout. You need something like:

    layout = QtGui.QGridLayout()
    self.setLayout(layout)
    layout.addWidget(view)

More information on this topic: http://qt-project.org/doc/qt-4.8/layout.html

Would Vispy be a good alternative?


Not yet, but hopefully within a few months we will start to see features similar to pyqtgraph.opengl. VisPy will also have a native Qt widget that can be embedded exactly like pg.GLViewWidget.

Alex Hanson

unread,
Mar 10, 2014, 4:13:16 PM3/10/14
to pyqt...@googlegroups.com
Luke,

Thank you, this worked perfectly


--
You received this message because you are subscribed to a topic in the Google Groups "pyqtgraph" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pyqtgraph/JOZsBPCOoDI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pyqtgraph+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyqtgraph/CACZXET9F4L3eP%2BG1jX6PUWM1_41KPy-dkHX5HeCCSKv-Ga2g4A%40mail.gmail.com.

For more options, visit https://groups.google.com/groups/opt_out.



--
Alexander Hanson

University of Idaho
ME Graduate Student

245 Baker St.
Apt. 304
Moscow, ID 83843
Message has been deleted

Konyu Godwin

unread,
Aug 5, 2024, 4:53:21 AM8/5/24
to pyqtgraph

Website..👉 https://t.me/EgUNSNP43FY3MDJk .
There is a growing number of people who wish to buy shrooms online. It is often hard to tell which form of products to buy since you cannot see it physically. This is sometimes peculiar to newbies who haven’t tried shrooms before. They just don’t know how to go about it. Shroom Edibles are not so popularly discussed as often as you think. A lot of experienced shroom users have not even had a taste of these Psilonauts Psilocybin Chocolate Bar goodness that offer a premium psychedelic trip.
Website..👉 https://t.me/EgUNSNP43FY3MDJk
Shop..👉 https://t.me/EgUNSNP43FY3MDJk
https://t.me/EgUNSNP43FY3MDJk
Buy Albino Penis Envy Mushrooms, or “APE,” is a genetically isolated, non-pigmented strain of the famous Polkadot chocolate. But the lack of pigment gives the albino penile envy mushroom a bright white appearance.
https://t.me/EgUNSNP43FY3MDJk
https://t.me/EgUNSNP43FY3MDJk
https://t.me/EgUNSNP43FY3MDJk
Your best online shop to get platinum quality microdosing psychedelics products online, pain,anxiety pills, and research chemicals.
Be 100% assured about the quality and genuineness of the product, and you will also be able to buy quality psychedelics products at a fair price.
https://t.me/EgUNSNP43FY3MDJk
https://t.me/EgUNSNP43FY3MDJk
Website..👉 https://t.me/EgUNSNP43FY3MDJk
Reply all
Reply to author
Forward
0 new messages