GraphicsLayout: added convenience method for creating sub-layouts
This commit is contained in:
parent
b78662c33e
commit
1489643a30
@ -26,12 +26,15 @@ class GraphicsLayout(GraphicsWidget):
|
||||
self.currentRow += 1
|
||||
self.currentCol = 0
|
||||
|
||||
def nextCol(self, colspan=1):
|
||||
def nextColumn(self, colspan=1):
|
||||
"""Advance to next column, while returning the current column number
|
||||
(generally only for internal use--called by addItem)"""
|
||||
self.currentCol += colspan
|
||||
return self.currentCol-colspan
|
||||
|
||||
def nextCol(self, *args, **kargs):
|
||||
return self.nextColumn(*args, **kargs)
|
||||
|
||||
def addPlot(self, row=None, col=None, rowspan=1, colspan=1, **kargs):
|
||||
plot = PlotItem(**kargs)
|
||||
self.addItem(plot, row, col, rowspan, colspan)
|
||||
@ -47,7 +50,11 @@ class GraphicsLayout(GraphicsWidget):
|
||||
self.addItem(text, row, col, rowspan, colspan)
|
||||
return text
|
||||
|
||||
|
||||
def addLayout(self, row=None, col=None, rowspan=1, colspan=1, **kargs):
|
||||
layout = GraphicsLayout(**kargs)
|
||||
self.addItem(layout, row, col, rowspan, colspan)
|
||||
return layout
|
||||
|
||||
def addItem(self, item, row=None, col=None, rowspan=1, colspan=1):
|
||||
if row is None:
|
||||
row = self.currentRow
|
||||
|
@ -7,6 +7,6 @@ class GraphicsLayoutWidget(GraphicsView):
|
||||
def __init__(self, parent=None, **kargs):
|
||||
GraphicsView.__init__(self, parent)
|
||||
self.ci = GraphicsLayout(**kargs)
|
||||
for n in ['nextRow', 'nextCol', 'addPlot', 'addViewBox', 'addItem', 'getItem', 'addLabel']:
|
||||
for n in ['nextRow', 'nextCol', 'nextColumn', 'addPlot', 'addViewBox', 'addItem', 'getItem', 'addLabel', 'addLayout']:
|
||||
setattr(self, n, getattr(self.ci, n))
|
||||
self.setCentralItem(self.ci)
|
||||
|
Loading…
x
Reference in New Issue
Block a user