def makeObject(self, host): typ = self.type() args = self.args() if typ == 'plot': obj = pg.PlotWidget(name=self.name(), **args) elif typ == 'imageView': obj = pg.ImageView(**args) elif typ == 'canvas': obj = Canvas.Canvas(**args) elif typ == 'fileInput': obj = FileLoader.FileLoader(host.dataManager(), **args) #elif typ == 'database': #obj = DatabaseGui.DatabaseGui(host.dataManager(), **args) elif typ == 'table': obj = pg.TableWidget(**args) elif typ == 'dataTree': obj = pg.DataTreeWidget(**args) elif typ == 'parameterTree': obj = pg.parametertree.ParameterTree(**args) elif typ == 'graphicsView': obj = pg.GraphicsView(**args) elif typ == 'graphicsLayout': obj = pg.GraphicsLayoutWidget(**args) elif typ == 'viewBox': obj = pg.GraphicsView() obj.setCentralItem(pg.ViewBox(**args)) else: raise Exception( "Cannot automatically create element '%s' (type=%s)" % (self.name, typ)) #self.setObject(obj) ## handled indirectly.. return obj
def __init__(self): Qt.QWidget.__init__(self) self.lay = Qt.QGridLayout() self.lay.setSpacing(0) self.setLayout(self.lay) self.addBtn = Qt.QPushButton('Add Image') self.clearBtn = Qt.QPushButton('Clear Images') self.autoBtn = Qt.QPushButton('Auto Range') self.canvas = Canvas() self.lay.addWidget(self.addBtn, 0, 0) self.lay.addWidget(self.clearBtn, 0, 1) self.lay.addWidget(self.autoBtn, 0, 2) self.lay.addWidget(self.canvas, 1, 0, 1, 3) self.imageItems = [] self.z = -1000 self.canvas.view.setRange(Qt.QRectF(-0.01, -0.01, 0.02, 0.02)) self.connect(self.addBtn, Qt.SIGNAL('clicked()'), self.addImage) self.connect(self.clearBtn, Qt.SIGNAL('clicked()'), self.clearImages) self.connect(self.autoBtn, Qt.SIGNAL('clicked()'), self.autoRange)