I'm creating a plot with multiple AxisItems, that get resized occasionally, but I'm trying to preserve the value of the original width in the AxisItem.preferredWidth() property (or AxisItem.minimumWidth()
Setting the value seems to have no effect. The following assert code will fail. Any help would be appreciated.
import pyqtgraph as pg
import sys
from pyqtgraph.Qt import QtGui, QtCore
class plotWidget(pg.GraphicsView):
def __init__(self):
super().__init__()
self.layout = pg.GraphicsLayout()
self.setCentralWidget(self.layout)
self.main_plot = pg.PlotItem()
ax = self.main_plot.getAxis('left')
new_min_width = 100
ax.setMinimumWidth(new_min_width)
self.layout.addItem(self.main_plot)
# assert test will fail
assert ax.minimumWidth() == new_min_width
if __name__ == '__main__':
pg.mkQApp()
win = plotWidget()
win.show()
if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
QtGui.QApplication.instance().exec_()