Closed BoxWizard000000 closed 5 years ago
The QTabWidget seems to resize the GRWidget to 0x0 temporarily, causing this division by zero. I've added a check against this in ff8c6ef097f3cce3d9914e524c47914081d98341 in the develop branch. This fix will be part of the next release.
What can I do in the meantime to fix this?
You can either replicate the change I madein that commit in your local installation of gr, or set the keepRatio
attribute of the widget to True until the widget has been properly sized by Qt.
I'm a bit wary about breaking my installation when editing it. I think I'll simply subclass and override it and let you know how it goes.
I decided to simply use introspection for now so I don't have to worry about messy inheritance rules. This seems to get it to display. I'm going to see if I can patch it at runtime rather than by a per object basis as well.
from types import MethodType
def _patchWidget(self, widget):
def _resizeEvent(self, event):
self._dwidth, self._dheight = self.width(), self.height()
self._mwidth = self.widthMM() * 0.001
self._mheight = self.heightMM() * 0.001
if self._mwidth > self._mheight:
self._sizex = 1.
if self.keepRatio:
self._sizey = 1.
self._mwidth = self._mheight
self._dwidth = self._dheight
elif self._mwidth > 0:
self._sizey = self._mheight / self._mwidth
else:
self._sizey = 1.
else:
if self.keepRatio:
self._sizex = 1.
self._mheight = self._mwidth
self._dheight = self._dwidth
elif self._mheight > 0:
self._sizex = self._mwidth / self._mheight
else:
self._sizex = 1.
self._sizey = 1.
setattr(widget, 'resizeEvent', MethodType(_resizeEvent, widget))
The fix is included in version 1.11.1.
I've been toying around with getting graphs to work in a tab view so I can easily add, remove, and view many graphs simultaneously.
Here's my code below. I try to do the example live plotter in a QTabWidget.
And here is the error:
I'm not entirely sure what to make this being new to Qt and GR still.
My OS is Ubuntu 19.04 and I'm running this on an Intel Core i7.