2014-04-16 17:27:34 |
David Hornung |
description |
Hello,
i report a bug using PlotWidget. It appears if I closed my application(code below). But doesn't occur if watches every tab widget.
propably this could help regarding to this article http://stackoverflow.com/questions/12433491/is-this-pyqt-4-python-bug-or-wrongly-behaving-code
errors messages:
(python:30803): Gtk-CRITICAL **: IA__gtk_container_add: assertion 'GTK_IS_CONTAINER (container)' failed
(python:30803): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion 'GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(python:30803): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion 'GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(python:30803): Gtk-CRITICAL **: IA__gtk_container_add: assertion 'GTK_IS_CONTAINER (container)' failed
(python:30803): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion 'GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
.....
code snippet below:
app = QtGui.QApplication([])
mw = QtGui.QMainWindow()
cw = QtGui.QWidget(None)
cwl = QtGui.QGridLayout(cw)
tw = QtGui.QTabWidget(cw)
cwl.addWidget(tw)
mw.setCentralWidget(cw)
mw.resize(1024,600)
class MachineView():
def __init__(self, machine):
self.machine = machine
self.data = []
self.w = QtGui.QWidget(tw)
self.l = QtGui.QVBoxLayout(self.w)
self.pw = pg.PlotWidget(parent=self.w)
self.pwzoom = pg.PlotWidget(parent=self.w)
self.lr = pg.LinearRegionItem([400,700])
self.l.addWidget(self.pw)
self.l.addWidget(self.pwzoom)
self.pw.addItem(self.lr)
self.lr.sigRegionChanged.connect(self._updatePlot)
self.pwzoom.sigXRangeChanged.connect(self._updateRegion)
self.updateTimer = QtCore.QTimer()
self.updateTimer.timeout.connect(self.updateData)
self.updateTimer.start(3000)
self.updateData()
def updateData(self):
self.data = [1,2,3,2]# something what you want
self.pw.plot(self.data)
self.pwzoom.plot(self.data)
def getWidget(self):
return self.w
def _updatePlot(self):
self.pwzoom.setXRange(*self.lr.getRegion(), padding=0)
def _updateRegion(self):
self.lr.setRegion(self.pwzoom.getViewBox().viewRange()[0])
class Monitor():
def __init__(self):
self.machines = []
for pinMapping in cfg.pinMapping.values():
self.machines.extend(map(list, zip(*pinMapping))[0])
self.machineViews = {}
for machine in self.machines:
pw = MachineView(machine)
self.machineViews[machine] = pw
#cwl.addWidget(pw.getWidget())
tw.addTab(pw.getWidget(), machine)
mw.show() |
Hello,
i report a bug using PlotWidget. It appears if I closed my application(code below). But doesn't occur if watches every tab widget.
propably this could help regarding to this article http://stackoverflow.com/questions/12433491/is-this-pyqt-4-python-bug-or-wrongly-behaving-code
errors messages:
(python:30803): Gtk-CRITICAL **: IA__gtk_container_add: assertion 'GTK_IS_CONTAINER (container)' failed
(python:30803): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion 'GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(python:30803): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion 'GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(python:30803): Gtk-CRITICAL **: IA__gtk_container_add: assertion 'GTK_IS_CONTAINER (container)' failed
(python:30803): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion 'GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
.....
code snippet below:
app = QtGui.QApplication([])
mw = QtGui.QMainWindow()
cw = QtGui.QWidget(None)
cwl = QtGui.QGridLayout(cw)
tw = QtGui.QTabWidget(cw)
cwl.addWidget(tw)
mw.setCentralWidget(cw)
mw.resize(1024,600)
class MachineView():
def __init__(self, machine):
self.machine = machine
self.data = []
self.w = QtGui.QWidget(tw)
self.l = QtGui.QVBoxLayout(self.w)
self.pw = pg.PlotWidget(parent=self.w)
self.pwzoom = pg.PlotWidget(parent=self.w)
self.lr = pg.LinearRegionItem([400,700])
self.l.addWidget(self.pw)
self.l.addWidget(self.pwzoom)
self.pw.addItem(self.lr)
self.lr.sigRegionChanged.connect(self._updatePlot)
self.pwzoom.sigXRangeChanged.connect(self._updateRegion)
self.updateTimer = QtCore.QTimer()
self.updateTimer.timeout.connect(self.updateData)
self.updateTimer.start(3000)
self.updateData()
def updateData(self):
self.data = [1,2,3,2]# something what you want
self.pw.plot(self.data)
self.pwzoom.plot(self.data)
def getWidget(self):
return self.w
def _updatePlot(self):
self.pwzoom.setXRange(*self.lr.getRegion(), padding=0)
def _updateRegion(self):
self.lr.setRegion(self.pwzoom.getViewBox().viewRange()[0])
class Monitor():
def __init__(self):
self.machines = ["m1","m2","m3"]
self.machineViews = {}
for machine in self.machines:
pw = MachineView(machine)
self.machineViews[machine] = pw
#cwl.addWidget(pw.getWidget())
tw.addTab(pw.getWidget(), machine)
monitor = Montior()
mw.show() |
|