【发布时间】:2015-12-13 18:55:41
【问题描述】:
我正在尝试在 PySide 上构建以下窗口:
对此我的解决方案是将其视为 3 列并按如下方式实现:
win = pg.GraphicsWindow()
win.resize(200, 500)
l = pg.GraphicsLayout(border='ff0000')
# The Overall layout consists of three columns with widths in the ratio of 1/8, 2/8, 5/8
# ======= col 1
vb = l.addViewBox(col=0, colspan=1, border='00ff00', lockAspect=True, enableMouse=False, invertY=True)
img = QtGui.QGraphicsPixmapItem(QtGui.QPixmap('heart.png')))
vb.addItem(img)
vb.scaleBy(10)
# ======= col 2
top_label = "Percent"
bottom_label = "85"
l_labels = l.addLayout(col=1, colspan=1)
l_labels.addLabel(top_label, row=0, col=0, rowspan=1, colspan=1, size='30pt', bold=True)
l_labels.addLabel(bottom_label, row=2, col=0, rowspan=4, colspan=1, size='200pt', color='606060')
l_labels.setContentsMargins(0, 0, 0, 100)
# ======= col 3
hr_plot = l.addPlot(col=2, colspan=6)
hr_plot.showGrid(x=False, y=True)
pen = pg.mkPen(color='#39e4f8', width=4)
hr_plot.plot(data, pen=pen,
symbol='o',
symbolPen=pen,
symbolBrush='#FFFFFF',
symbolSize=16)
win.addItem(l)
我的主要问题如下:
如何调整第一列的宽度(可以通过调整“ViewBox”的宽度或其他方式)?
【问题讨论】:
标签: python pyqt pyside pyqtgraph