hi
(repost)
I am trying to use a button in the menu of my window(addwidget) to add
another dock to my dock area. ( see file attached)
The widget gets added and it seems to function but i get the following
error:
AttributeError: 'NoneType' object has no attribute 'type'
Traceback (most recent call last):
..pyqtgraph\dockarea\Dock.py", line 170, in resizeEvent
self.setOrientation()
..\pyqtgraph\dockarea\Dock.py", line 143, in setOrientation
if self.container().type() == 'tab':
AttributeError: 'NoneType' object has no attribute 'type'
The error does not happen if the main window is empty ( for the 1st widget
you add), but the following ones do the same
can anybody help?
There is a second button I added(add widget hack), in which I use a
workaround, by creating a temporary area to which I add a widget, and then
move it back to the original one.
Am I missing something ? Am trying to find the proper way of doing it!
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/pyqtgraph/0b15e902-0d0e-47c9-961a-b32e132922bd%40googlegroups.com.
import pyqtgraph as pg
from pyqtgraph.Qt import QtCore, QtGui
from pyqtgraph.dockarea import *
from PySide2.QtWidgets import QWidget, QMainWindow, QSplitter
count =0
def addWidgetToWindow():
mywidget = QWidget()
mywidget.setStyleSheet("background-color : red;")
global count
mywidget.setWindowTitle("my widget"+str(count))
d = Dock( name=mywidget.windowTitle(), size=(300, 200), closable=True)
global area
area.addDock(d, "left")
d.addWidget(mywidget)
count= count+1
def addWidgetToWindowModif():
mywidget = QWidget()
mywidget.setStyleSheet("background-color : red;")
global count
mywidget.setWindowTitle("my widget" + str(count))
d = Dock(name=mywidget.windowTitle(), size=(300, 200), closable=True)
global area
a = DockArea.addTempArea(area)
a.addDock(d, "left")
d.addWidget(mywidget)
area.moveDock(d,"bottom", None)
count = count + 1
d.container().setChildrenCollapsible(False)
if __name__ == '__main__':
import sys
global area
app = QtGui.QApplication([])
win = QMainWindow()
area = DockArea()
win.setCentralWidget(area)
win.resize(1000, 500)
menu = win.menuBar()
AddWidget_act = menu.addAction("AddWidget")
AddWidget_act.triggered.connect(addWidgetToWindow)
AddWidgetHack_act = menu.addAction("AddWidgetHack")
AddWidgetHack_act.triggered.connect(addWidgetToWindowModif)
addWidgetToWindow()
addWidgetToWindow()
win.show()
if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
QtGui.QApplication.instance().exec_()