Commit 1489643a authored by Luke Campagnola's avatar Luke Campagnola
Browse files

GraphicsLayout: added convenience method for creating sub-layouts

parent b78662c3
......@@ -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) = 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(, n))
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment