def setup(self): util.timer('Initializing GUI') app = QtGui.QApplication([]) view = pg.GraphicsView() view.resize(1000, 700) view.setWindowTitle('LED Music Visualizer') view.closeEvent = self._close_event self.on_close = None layout = pg.GraphicsLayout() view.setCentralItem(layout) spec_viewer_proxy = QtGui.QGraphicsProxyWidget(layout) spec_viewer = SpectrogramViewer() spec_viewer_proxy.setWidget(spec_viewer) layout.addItem(spec_viewer_proxy) layout.layout.setRowStretchFactor(0, 1) layout.nextRow() pixel_viewer_proxy = QtGui.QGraphicsProxyWidget(layout) pixel_viewer = PixelViewer() pixel_viewer_proxy.setWidget(pixel_viewer) layout.addItem(pixel_viewer_proxy) layout.layout.setRowStretchFactor(1, 0) layout.nextRow() labels_layout = pg.GraphicsLayout() fps_label = labels_layout.addLabel('FPS: ?') time_label = labels_layout.addLabel('Elapsed Time: ?') pause_label = labels_layout.addLabel('Resume') pause_label.mousePressEvent = self.__pause_pressed layout.addItem(labels_layout) layout.layout.setRowStretchFactor(2, 0) debug_view = pg.GraphicsView() debug_view.resize(800, 600) debug_view.setWindowTitle('Debug') debug_layout = pg.GraphicsLayout() debug_view.setCentralItem(debug_layout) self.app = app self.view = view self.spec_viewer = spec_viewer self.pixel_viewer = pixel_viewer self.fps_label = fps_label self.time_label = time_label self.pause_label = pause_label self.debug_view = debug_view self.debug_layout = debug_layout
def plot_txtFile(self): pg.setConfigOptions(antialias=True) self.ranges = [] self.markers = [] self.GraphicsLayout = pg.GraphicsLayout() self.graphicsView_.setCentralItem(self.GraphicsLayout) self.graphicsView_.show() self.plot = self.GraphicsLayout.addPlot(title=self.TxtFile.filepath) self.lead_plots = [] self.plot.addLegend() for i in range(len(self.TxtFile.channels)): if i % 2 == 0: colour = 'g' else: colour = 'y' offset = i * -self.offset data = self.TxtFile.data.iloc[:, i].values + offset data = TxtFile.filter_data(data, type='wavelet', sample_freq=self.TxtFile.sample_freq) self.plot.plot(y=data, name=self.TxtFile.channels[i], pen=colour) self.GraphicsLayout.setSpacing(0) self.GraphicsLayout.setContentsMargins(0., 0., 0., 0.)
def __init__(self, funct, funct_args, modifiers_list, modifiers_magnitude, kwargs_list, size=(800, 600), *args, **kwargs): super().__init__(*args, **kwargs) l = pg.GraphicsLayout(border=(100, 100, 100)) self.setCentralItem(l) self.show() self.setWindowTitle('combination imp plot') self.resize(size[0], size[1]) self.modifiers_list = modifiers_list self.modifiers_magnitude = modifiers_magnitude self.funct_args = funct_args self.funct = funct self.images = [] self.kwargs_list = kwargs_list funct_out = funct(funct_args, modifiers_list) for (i, (array, kwargs)) in enumerate(zip(funct_out, kwargs_list)): vb = l.addViewBox(lockAspect=True) #print(array,kwargs) img = pg.ImageItem(array, **kwargs) vb.addItem(img) vb.autoRange() self.images.append(img)
def delete_plot(self, col, row): del self.columns[col][row] l = self.layout.getItem(0, col) self.layout.removeItem(l) new_layout = pg.GraphicsLayout() new_layout.setBorder(pg.mkColor(150, 150, 150)) self.layout.addItem(new_layout, 0, col) # we recreate the entire column layout, since we can't # delete the new row... r = 0 first = True while True: if r != row: item = l.getItem(r, 0) if item == None: break if not first: new_layout.nextRow() else: first = False new_layout.addItem(item) item.show_x_axis(True if r == row - 1 else False) r += 1 if len(self.columns[col]) == 0: self.delete_column(col) self.create_menu()
def __init__(self, title): # # app, scene, plots # self.app = QtGui.QApplication(sys.argv) window = pg.GraphicsWindow() window.resize(1000, 600) mw = QtGui.QMainWindow() window.setParent(mw) mw.setCentralWidget(window) mw.setWindowTitle(title) mw.show() mw.raise_() mw.activateWindow() self.mw = mw layout = pg.GraphicsLayout() window.setCentralItem(layout) layout.window = window # keep window to avoid garbage collection layout.setContentsMargins(2, 2, 2, 2) # outermost margin self.layout = layout self.ray_idx = 0 self.rayplots = [] self.iw = None self.iw_visible = False
def initUi(self,datas): """初始化界面""" self.setWindowTitle(u'K线工具') # 主图,只能添加item self.pw = pg.PlotWidget() # 界面布局 self.lay_KL = pg.GraphicsLayout(border=(100, 100, 100)) self.lay_KL.setContentsMargins(10, 10, 10, 10) self.lay_KL.setSpacing(0) self.lay_KL.setBorder(color=(255, 255, 255, 255), width=0.8) # 设置边框颜色和线段粗细 self.lay_KL.setZValue(0) self.lay_KL.setMinimumHeight(140) # self.KLtitle = self.lay_KL.addLabel(u'') self.pw.setCentralItem(self.lay_KL) # 设置横坐标 xdict = {} self.axisTime = MyStringAxis(xdict, orientation='bottom') # 初始化子图 self.initplotKline() # self.initplotOI() # 注册十字光标 # self.crosshair = Crosshair(self.pw, self) # 设置界面,可以添加其他的例如文本框,下拉菜单项之类的 self.vb = QtWidgets.QVBoxLayout() self.vb.addWidget(self.pw) self.setLayout(self.vb) # 初始化完成 self.initCompleted = True self.oldsize=self.rect().height() self.customBox = {}
def InitPlot(self): print('Creating plot') QtGui.QApplication.processEvents() self.app = QtGui.QApplication([]) self.mainLayout = pg.GraphicsLayout(border=(100, 100, 100)) self.mainLayout.nextRow() self.earPlotLayout = self.mainLayout.addLayout(colspan=3) self.earPlotLayout.setContentsMargins(10, 10, 10, 10) self.earPlotLayout.addLabel("EAR plot", colspan=3) self.earPlotLayout.nextRow() self.earPlotLayout.addLabel('EAR', angle=-90, rowspan=2) self.earPlot = self.earPlotLayout.addPlot() self.earPlotLayout.nextRow() self.earPlotLayout.addLabel('Frame', col=1, colspan=2) self.mainLayout.nextRow() self.blinkNoBlinkPlotLayout = self.mainLayout.addLayout(colspan=3) self.blinkNoBlinkPlotLayout.setContentsMargins(10, 10, 10, 10) self.blinkNoBlinkPlotLayout.addLabel("Blink / No Blink plot", colspan=3) self.blinkNoBlinkPlotLayout.nextRow() self.blinkNoBlinkPlotLayout.addLabel('Blink', angle=-90, rowspan=2) self.blinkNoBlinkPlot = self.blinkNoBlinkPlotLayout.addPlot() self.blinkNoBlinkPlotLayout.nextRow() self.blinkNoBlinkPlotLayout.addLabel('Frame', col=1, colspan=2) self.view = pg.GraphicsView() self.view.setCentralItem(self.mainLayout) self.view.show() self.view.setWindowTitle('Plots') self.view.resize(800, 600) print('Done!')
def initUi(self): """初始化界面""" self.setWindowTitle(u'K线工具') # 主图 self.pw = pg.PlotWidget() # 界面布局 self.lay_KL = pg.GraphicsLayout(border=(100, 100, 100)) self.lay_KL.setContentsMargins(10, 10, 10, 10) self.lay_KL.setSpacing(0) self.lay_KL.setBorder(color=(255, 255, 255, 255), width=0.8) self.lay_KL.setZValue(0) self.KLtitle = self.lay_KL.addLabel(u'') self.pw.setCentralItem(self.lay_KL) # 设置横坐标 xdict = {} self.axisTime = MyStringAxis(xdict, orientation='bottom') # 初始化子图 self.initplotKline() self.initplotVol() self.initplotOI() # 注册十字光标 self.crosshair = Crosshair(self.pw, self) # 设置界面 self.vb = QtGui.QVBoxLayout() self.vb.addWidget(self.pw) self.setLayout(self.vb) # 初始化完成 self.initCompleted = True
def _default_container(self): container = pg.GraphicsLayout() container.setSpacing(10) # Add the x and y axes to the layout, along with the viewbox. for i, child in enumerate(self.children): container.addItem(child.y_axis, i, 0) container.addItem(child.viewbox, i, 1) try: # This raises an "already taken" QGridLayoutEngine error. The # obvious explanation is because the current viewbox also # occupies this cell. container.addItem(child.viewbox_norm, i, 1) except AttributeError: pass child._configure_viewbox() if self.x_axis is not None: container.addItem(self.x_axis, i + 1, 1) # Link the child viewboxes together for child in self.children[1:]: child.viewbox.setXLink(self.children[0].viewbox) return container
def __init__(self): pg.GraphicsView.__init__(self) self.setWindowTitle("Musicraft: Pitch and Note Plot") self.lay = pg.GraphicsLayout(border=(100, 100, 100)) self.setCentralItem(self.lay) #raw_plot = self.lay.addPlot() raw_plot = pg.PlotItem() self.lay.addItem(raw_plot) raw_plot.setYRange(-1024, 1024) raw_plot.setMaximumSize(200., 200.) self.recent_samples = np.zeros(AUDIO_SAMPLE_RATE, dtype=np.int16) # display one seconds worth of raw data self.raw_curve = raw_plot.plot(self.recent_samples) self.start_index = self.end_index = self.quiets = 0 self.thresholds = [pg.InfiniteLine(pos=y, angle=0, pen=None, movable=True) for y in (self.MIN_SIG_VOLUME, - self.MIN_SIG_VOLUME)] for is_other, th in enumerate(self.thresholds): raw_plot.addItem(th) th.sigPositionChanged.connect(self.threshold_changed) self.pitch_plot = PitchPlot() self.lay.addItem(self.pitch_plot, col=1, colspan=6) self.pitch_plot.setPreferredHeight(500.) self.init_audio() self.show()
def refresh_ui(self): if self.studyFolderPath: self.comboBox_txtsdyFiles.setEnabled(True) self.label_PatientID.setText( f"Patient ID: {self.studyData.get('id', 'NA')}") # Get rid of the old files list and add the new ones self.comboBox_txtsdyFiles.clear() self.comboBox_txtsdyFiles.addItem("Please select a file") txt_file_paths = glob(os.path.join(self.studyFolderPath, "*.txt")) sdy_file_paths = glob(os.path.join(self.studyFolderPath, "*.sdy")) for txt_file_path in txt_file_paths: labels = self.load_cph(f"{txt_file_path}.cph") labels.pop( 'pa', None) # Remove the PA key so doesn't count as a label self.comboBox_txtsdyFiles.addItem("{} - {} labels".format( txt_file_path, len(labels))) for sdy_file_path in sdy_file_paths: labels = self.load_cph(f"{sdy_file_path}.cph") labels.pop( 'pa', None) # Remove the PA key so doesn't count as a label self.comboBox_txtsdyFiles.addItem("{} - {} labels".format( sdy_file_path, len(labels))) # Clear the plot window self.GraphicsLayout = pg.GraphicsLayout() self.graphicsView_.setCentralItem(self.GraphicsLayout) self.graphicsView_.show() else: # If a study folder path isn't set, the file box shouldn't be clickable self.comboBox_txtsdyFiles.setEnabled(False)
def __init__(self): super(MyView, self).__init__() l = pg.GraphicsLayout(border=(100, 100, 100)) self.setCentralWidget(l) self.show() self.setWindowTitle('pyqtgraph example: GraphicsLayout') self.resize(800, 600) vb = l.addViewBox(lockAspect=True) self.img = pg.ImageItem() vb.addItem(self.img) l.nextRow() text = 'state of the network' self.label = l.addLabel(text, colspan=2) l.nextRow() l2 = l.addLayout(colspan=3) l2.setContentsMargins(10, 10, 10, 10) l2.addLabel('Amplitude, cross section', angle=-90) self.plot = l2.addPlot(colspan=2) self.curve = self.plot.plot() # self.plot.setYRange(0, 1) # self.sp_state = np.zeros(poppy.sp.getColumnDimensions(), dtype="uint32") # self.prev_sp_state = np.zeros(poppy.brain.L23_shape, dtype="uint32") # self.average_difference = 0.4 # self.data = np.zeros(100) self.timer = QtCore.QTimer() self.timer.timeout.connect(self.update) self.timer.start(1) self.counter = 0
def __init__(self, parent, nlines=1): super().__init__() self.parent = parent self.layout = qt.QHBoxLayout() self.setLayout(self.layout) self.view = pg.GraphicsView() self.graphLayout = pg.GraphicsLayout() self.view.setCentralItem(self.graphLayout) self.view.setBackground(None) self.graph = pg.PlotItem(background=None) self.graphLayout.addItem(self.graph) self.lines = {} self.pens = {} for i in range(nlines): self.pens[i] = pg.mkPen(color_order[i], width=2) self.lines[i] = pg.PlotDataItem([], [], pen=self.pens[i]) self.graph.addItem(self.lines[i]) self.xaxis = self.graph.getAxis('bottom') self.yaxis = self.graph.getAxis('left') self.xaxis.setPen(styles.graphPen) self.yaxis.setPen(styles.graphPen) self.layout.addWidget(self.view, 1)
def __init__(self, data, parent=None): self.parent = parent self.data = data super(HistogramLUTWidget, self).__init__(parent) # 继承 # 界面布局 self.pw = pg.PlotWidget() self.lay_KL = pg.GraphicsLayout(border=(100, 100, 100)) self.lay_KL.setContentsMargins(10, 10, 10, 10) self.lay_KL.setSpacing(0) self.lay_KL.setBorder(color=(255, 255, 255, 255), width=0.8) self.lay_KL.setZValue(0) self.pw.setCentralItem(self.lay_KL) # # 设置横坐标 # xdict = dict(enumerate(self.data["timeList"])) # self.axisTime = MyStringAxis(xdict, orientation='bottom') # # 初始化子图 self.initplotpnl() # # 注册十字光标 x = [] viwe = self.plt self.crosshair = CrosshairTool(self.pw, x, viwe, self) # 设置界面 self.vb = QtWidgets.QVBoxLayout() self.vb.addWidget(self.pw) self.setLayout(self.vb)
def __init__(self, mainwindow): super(LabelUI, self).__init__() self.setupUi(mainwindow) self.actionLoad_study.triggered.connect(self.load_study_folder) self.comboBox_txtsdyFiles.activated.connect(self.load_txtsdyFile) self.checkBox_Pa.clicked.connect(self.toggle_pa) self.GraphicsLayout = pg.GraphicsLayout() self.graphicsView_.setCentralItem(self.GraphicsLayout) self.graphicsView_.show() self.verticalLayout_Buttons.setAlignment(QtCore.Qt.AlignTop) self.pushButton_ExportStudy.clicked.connect(self.export_study) self.pushButton_ExportAll.clicked.connect(self.export_all) self.studyFolderPath = None self.studyData = dict() self.TxtSdyFile = None self.calculations = dict() with open("./information.txt", 'r') as f: self.textBrowser.setHtml("\n".join(f.readlines())) self.plot_pressure, self.plot_flow, self.plot_pressure_ratios = None, None, None self.plot_resistances, self.plot_ensemble_rest, self.plot_ensemble_hyp = None, None, None self.slider_group_rest, self.slider_group_hyp = None, None self.ensemble_data_rest, self.ensemble_data_hyp = None, None self.button_rest, self.button_hyp = None, None self.button_notch_rest, self.button_enddiastole_rest = None, None self.button_notch_hyp, self.button_enddiastole_hyp = None, None self.slider_notch_rest, self.slider_notch_hyp = None, None self.slider_enddiastole_rest, self.slider_enddiastole_hyp = None, None
def init_window(x=0, y=0, w=1440, h=1080, title='Hello World'): global _window_view, _window_layout, _window_imgs, _window_stats_label, _windows view = pg.GraphicsView() layout = pg.GraphicsLayout(border=(100, 100, 100)) view.setCentralItem(layout) view.setWindowTitle(title) view.setGeometry(x, y, w, h) view.show() imgs = [] imgs.append(_add_image_to_layout(layout, title='capture')) imgs.append(_add_image_to_layout(layout, title='processed')) imgs.append(_add_image_to_layout(layout, title='prediction')) layout.nextRow() stats_label = pg.LabelItem() layout.addItem(stats_label, colspan=3) _window_view = view _window_layout = layout _window_imgs = imgs _window_stats_label = stats_label _windows.append(view)
def create_plotwindow(title): ''' set up and return a plotlayout "window" ''' window = pg.GraphicsWindow() mw = QtGui.QMainWindow() window.setParent(mw) mw.setCentralWidget(window) mw.setWindowTitle(title) # window size rect = QtGui.QApplication.desktop().screenGeometry() w = 0.7 * rect.width() h = 0.7 * rect.height() mw.resize(w, h) global g_window g_window = mw layout = pg.GraphicsLayout(border=None) window.setCentralItem(layout) layout.window = window # keep window to avoid garbage collection layout.setContentsMargins(2, 2, 2, 2) # outermost margin layout.mw = mw mw.show() mw.raise_() return layout
def _plot_timeseries_qt(self): app = QtGui.QApplication([]) view = pg.GraphicsView() l = pg.GraphicsLayout(border=(100, 100, 100)) view.setCentralItem(l) view.show() view.setWindowTitle('Functional recordings from the pig intrinsic cardiac nervous system (ICN)') view.resize(800, 600) text = """ In this dataset, pigs were investigated for intrinsic cardiac nervous system (ICN) recoding via cardiovascular output monitoring after cervical vagi stimulation. """ l.addLabel(text, row=1, col=1) l.nextRow() p1 = l.addPlot(row=2, col=1, title="ECG") l.nextRow() p2 = l.addPlot(row=3, col=1, title="LVP") p3 = l.addPlot(row=4, col=1, title="RAE") self._df["time"] = self._df.index self._df = self._df[:500000] p1.plot(self._df["time"], self._df[self._df.keys()[0]]) p2.plot(self._df["time"], self._df[self._df.keys()[1]]) p3.plot(self._df["time"], self._df[self._df.keys()[2]]) if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): QtGui.QApplication.instance().exec_()
def BackinitUi(self): # 主图 self.pw = pg.PlotWidget() # 界面布局 self.lay_KL = pg.GraphicsLayout(border=(100, 100, 100)) self.lay_KL.setContentsMargins(10, 10, 10, 10) self.lay_KL.setSpacing(0) self.lay_KL.setBorder(color=(255, 255, 255, 255), width=0.8) self.lay_KL.setZValue(0) self.pw.setCentralItem(self.lay_KL) #self.lay_KL.addLabel("capital") # 设置横坐标 xdict = dict(enumerate(self.xAxis )) self.axisTime = MyStringAxis(xdict, orientation='bottom') # 初始化子图 self.initCapital() # # 注册十字光标 xAxis=self.xAxis viwe=self.pwOI self.crosshair=CrosshairTool(self.pw,xAxis,viwe,self) #设置界面 self.vb = QtWidgets.QVBoxLayout() self.vb.addWidget(self.pw) self.setLayout(self.vb) # 初始化完成 self.initCompleted = True
def __init__(self): QtGui.QMainWindow.__init__(self) Ui_MainWindow.__init__(self) self.setupUi(self) self.actionopen.triggered.connect(self.onOpen) self.actionsave.triggered.connect(self.onSave) self.actionlaplace.triggered.connect(self.onLaplace) self.actioncanny.triggered.connect(self.onCanny) self.actiongray.triggered.connect(self.onGray) self.actionsobel.triggered.connect(self.onSobel) self.actionprewitt.triggered.connect(self.onPrewitt) self.actionredo.triggered.connect(self.onRedo) self.actiondraw.triggered.connect(self.onDraw) self.actionDFT.triggered.connect(self.onDFT) self.actionhistogram.triggered.connect(self.onHistogram) self.im = [] self.view = pg.GraphicsView(self.graphicsView) self.l = pg.GraphicsLayout(border=(100, 100, 100)) self.view.setCentralItem(self.l) self.view.show() self.view.setWindowTitle('Image') self.view.resize(640, 480) self.vb = self.l.addViewBox(lockAspect=True) self.img = pg.ImageItem() self.vb.addItem(self.img) self.vb.autoRange()
def __init__(self): super(HeatmapPlot, self).__init__() self.setWindowTitle('heatmap') self.layout = pg.GraphicsLayout() self.setCentralWidget(self.layout) xdict = {} self.baxis = MyCodeAxis(xdict, orientation='bottom') self.laxis = MyCodeAxis(xdict, orientation='left') self.plot_item = pg.PlotItem() self.default_vb = self.plot_item.vb self.plot_item.getAxis('left').hide() self.plot_item.getAxis('bottom').hide() self.heatmap_vb = pg.ViewBox() self.layout.addItem(self.laxis, row=2, col=0) self.layout.addItem(self.plot_item, row=2, col=1) self.layout.scene().addItem(self.heatmap_vb) self.layout.addItem(self.baxis, row=3, col=1) self.heatmap_vb.setXLink(self.default_vb) self.baxis.linkToView(self.heatmap_vb) self.laxis.linkToView(self.heatmap_vb) self.old = None
def setup(self): # Setup graph vw = self.graphWidget.getViewWidget() l = pg.GraphicsLayout() l.setBorder(pg.mkPen(cosmetic=False, width=4.0, color='r')) vw.setCentralItem(l) self.plt = l.addPlot(0,0) # axis.setTickSpacing([(3, 0), (1, 0), (0.25, 0)]) bottom = self.plt.getAxis('bottom') left = self.plt.getAxis('left') bottom.setGrid(100) bottom.setTickSpacing(100, 25) left.setGrid(100) left.setTickSpacing(1, 0.5) # Setup Async Events self.addTimedEvent('getData', start=False) # 20 tps self.addTimedEvent('updateStatus', 1000) # 1 tps # Setup buttons self.addButtonCallbackAnonymous('button_start', lambda: (self.startTimedEvent('getData', 50), self.serverHandler.startServerAcquisition())) self.addButtonCallbackAnonymous('button_pause', lambda: (self.stopTimedEvent('getData'))) self.addButtonCallbackAnonymous('button_reset', lambda: (self.stopTimedEvent('getData'), self.serverHandler.discardCounts(), self.plt.clear())) self.addButtonCallbackAnonymous('button_stop' , lambda: (self.stopTimedEvent('getData'), self.serverHandler.stopServerAcquisition())) self.addButtonCallbackAnonymous('button_exit' , lambda: (self.serverHandler.signalTerminate(), QtWidgets.QApplication.quit())) # Setup other widgets self.led_PXI.turn_off() self.led_PXI.setFixedSize(20, 20)
def __init__(self, data_queue, plots, plot_names, beh_intervals=None, parent=None): super().__init__(parent=parent) self.parent = parent self.graphics_layout = pg.GraphicsLayout(border=(0, 0, 0)) self.graphics_layout.layout.setSpacing(0) self.graphics_layout.layout.setContentsMargins(0, 0, 0, 0) self.setCentralItem(self.graphics_layout) self.timer = QtCore.QTimer(self) self.timer.setInterval(10) self.timer.timeout.connect(self.on_new_data) self.behavior_time = {} self.plot_items = [] self.vertical_lines = [] self.plots = plots self.add_plots(plot_names, beh_intervals) # Convert all sets to strings if beh_intervals: self.behavior_time = { time: ', '.join(behavior) for time, behavior in self.behavior_time.items() } else: self.behavior_time = None self.data_queue = data_queue self.timer.start()
def __init__(self, model=None): super().__init__() self.model = model layout = QtWidgets.QVBoxLayout() self.setLayout(layout) self.plot_selector = PlotSelector() self.gv = pg.GraphicsView() layout.addWidget(self.gv) layout.addWidget(self.plot_selector) self.cameras = self.model.cameras if len(self.cameras) > 0: self.camera = self.cameras[self.cameras.keys()[0]] else: self.camera = None if self.camera: self.camera.begin_acquisition() self.glayout = pg.GraphicsLayout() self.vb = self.glayout.addViewBox() self.gv.setCentralItem(self.glayout) self.get_img() self.timer = QtCore.QTimer() self.timer.timeout.connect(self.get_img) self.timer.start(200)
def __init__(self): QtGui.QDialog.__init__(self) uic.loadUi(second_win_file, self) self.setWindowFlags(QtCore.Qt.Window) self.layout_graphicos = pg.GraphicsLayout( border=(100, 0, 100) ) #para ordenar los graphicos(items) asi como el simil con los widgets self.graphicsView.setCentralItem(self.layout_graphicos) self.closeable = False
def _init_ui(self) -> None: """""" self.setWindowTitle("ChartWidget of vn.py") self._layout = pg.GraphicsLayout() self._layout.setContentsMargins(10, 10, 10, 10) self._layout.setSpacing(0) self._layout.setBorder(color=GREY_COLOR, width=0.8) self._layout.setZValue(0) self.setCentralItem(self._layout)
def _init_ui(self) -> None: """""" self._layout = pg.GraphicsLayout() self._layout.setContentsMargins(10, 10, 10, 10) self._layout.setSpacing(0) self._layout.setBorder(color=GREY_COLOR, width=0.8) self._layout.setZValue(0) self.setCentralItem(self._layout) self._x_axis = DatetimeAxis(self._manager, orientation='bottom')
def show(self, img_list): view = pg.GraphicsView() l = pg.GraphicsLayout(border=(100, 100, 100)) view.setCentralItem(l) view.show() for img in img_list: ii = pg.ImageItem(img.astype(np.float).T) vb = l.addViewBox(lockAspect=True, invertY=True) vb.addItem(ii) QtGui.QApplication.exec_()
def __init__(self, display_panel): from gui import PALMS super().__init__() self.display_panel = display_panel self.main_window = self.display_panel.main_window # Layout self.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) self.layout = pg.GraphicsLayout() self.layout.layout.setColumnFixedWidth(0, self.main_window.axis_width) # self.setBackground('w') # Variables self.axes: Optional[Dict[View, pg.AxisItem]] = {} self.vbs: Optional[Dict[View, pg.ViewBox]] = {} self.main_plot = pg.PlotItem(enableMenu=False) self.main_plot.hideButtons() self.main_plot.hideAxis('left') self.main_plot.hideAxis('bottom') self.main_plot.temporary_items = [] self.main_vb: pg.ViewBox = self.main_plot.getViewBox() self.main_vb.sigXRangeChanged.connect(self.zoomChanged) # self.main_vb.sigYRangeChanged.connect(self.setYRange) self.main_vb.setXRange(0, 1) self.main_vb.setYRange(0, 1) self.main_vb.setMouseEnabled(False, False) self.main_plot.setZValue(-sys.maxsize - 1) self.main_vb.enableAutoRange(axis=pg.ViewBox.XYAxes) self.axis_bottom = pg.AxisItem( 'bottom', parent=self.main_vb, showValues=False ) # ticks are disabled, because each view has separately created GridItem() # self.axis_bottom.setPen(pg.mkPen(color='k', width=1)) self.axis_bottom.setLabel('time', units='s') self.axis_bottom.showLabel(PALMS.config['show_xaxis_label']) # self.axis_bottom.setFixedHeight(self.axis_bottom.height()) self.label_cursor_position = pg.LabelItem(justify='left', color=[255, 255, 255, 0]) self.event_cursor_global_position = None # Connections self.maxWidthChanged.connect(self.main_window.checkAxesWidths) self.main_vb.sigResized.connect(self.updateViews) self.main_window.cursorReadoutStatus.connect(self.setCursorReadout) # self.proxy = pg.SignalProxy(self.scene().sigMouseMoved, rateLimit=60, slot=self.mouseMoved) self.buildLayout() self.setCursorReadout(self.main_window.cursor_readout) self.signal_annotation_added.connect(self.plot_vline) self.signal_annotation_deleted.connect(self.plot_vline) self.mouseWheelTimer = QTimerWithPause(interval=500) self.mouseWheelTimer.timeout.connect(self.reset_wheelEvents) self.mouseWheelTimer.resume() self.ALL_VIEWS_HIDDEN = False
def __init__(self, xmin=None, ymin=None, xlabel=None, xlabelunits=None, setTitles=True, **kwargs): super(multiPlotWidget, self).__init__() ''' multiPlotWidget - main pyQtGraph display widgets ''' self.multiPlotView = pg.GraphicsView(useOpenGL=True) self.multiPlotWidget = pg.GraphicsLayout() self.multiPlotView.setCentralItem(self.multiPlotWidget) ''' multiPlotWidgets - holds the base plotWidgets for each Twiss plot ''' self.multiPlotWidgets = {} ''' curves - a dictionary containing {directory: [individual plotItems for each twiss plot,]} ''' self.curves = {} for n, param in enumerate(self.plotParams): if param == 'next_row': self.multiPlotWidget.nextRow() else: ''' p - the relevant plotWidget for each param in plotParams ''' if setTitles: p = self.multiPlotWidget.addPlot(title=param['label']) else: p = self.multiPlotWidget.addPlot() ''' this just links the horizontal axis for all plots. The first plot is selected to be the master axis ''' if n == 0: self.linkAxis = p.vb else: p.setXLink(self.linkAxis) p.showGrid(x=True, y=True) p.setLabel('left', text=param['name'], units=param['units'], **{'font-size': '12pt', 'font-family': 'Arial'}) p.setLabel('bottom', text=xlabel, units=xlabelunits) if 'xlabel' in param and param['xlabel'] is not None: xlu = param['xlabelunits'] if 'xlabelunits' in param else None p.setLabel('bottom', text=param['xlabel'], units=xlu) ''' set lower plot limit for all plots ''' if xmin is not None: p.vb.setLimits(xMin=xmin) if ymin is not None: p.vb.setLimits(yMin=ymin) # paramater xmin/ymin overrides global setting if 'xmin' in param and param['xmin'] is not None: p.vb.setLimits(xMin=param['xmin']) if 'ymin' in param and param['ymin'] is not None: p.vb.setLimits(yMin=param['ymin']) ''' set the vertical viewRange according to the plotParams ''' if 'range' in param: p.vb.setYRange(*param['range']) ''' record the plotWidget in the dictionary indexed by Twiss item ''' self.multiPlotWidgets[param['label']] = p self.layout = QVBoxLayout() self.setLayout(self.layout) self.layout.addWidget(self.multiPlotView) ''' used for style cycling ''' self.plotColor = 0 self.shadowCurves = []