def init_ui(self): # Sets title and UI layout self.setWindowTitle('Plotter') win = QtGui.QBoxLayout(QtGui.QBoxLayout.LeftToRight) # creates a plot widget and adds it to the window self.plotwidget = pg.PlotWidget() win.addWidget(self.plotwidget) #self.combo = pg.ComboBox() #win.addWidget(self.combo) butt_win = QtGui.QBoxLayout(QtGui.QBoxLayout.TopToBottom) # labels the buttons self.pauseButton = QtGui.QPushButton("Pause/Play") self.autoSetButton = QtGui.QPushButton("Autoset") self.calibrateButton = QtGui.QPushButton("Calibrate") self.saveButton = QtGui.QPushButton("Save") # adds the buttons to the button window butt_win.addWidget(self.pauseButton) butt_win.addWidget(self.autoSetButton) butt_win.addWidget(self.calibrateButton) butt_win.addWidget(self.saveButton) self.setGeometry(20, 50, 1000, 600) # Sets the layout win.addLayout(butt_win) # adds the button window to the main window self.setLayout(win) # sets the main layout self.show() # displays the window
def __init__(self): QtGui.QMainWindow.__init__(self) self.setWindowTitle('Turbulence visualization GUI') self.resize(800, 600) dockArea = da.DockArea() self.setCentralWidget(dockArea) ## Create controlling dock controlDock = da.Dock('Parameters', size=(200, 600)) dockArea.addDock(controlDock, 'left') # Although controlDock functions like a LayoutWidget already, # the margins don't behave nicely. Hence we use an extra middle hand #layout = pg.LayoutWidget() layout = QtGui.QBoxLayout(QtGui.QBoxLayout.TopToBottom) dummyWidget = QtGui.QWidget() dummyWidget.setLayout(layout) controlDock.addWidget(dummyWidget) layout.setAlignment(QtCore.Qt.AlignTop) # Add size controller layout.addWidget(SizeWidget()) # Add generator controller layout.addWidget(GeneratorChoiceWidget()) ## Create plotting dock volDock = da.Dock('Volumetric plot', size=(600, 800)) dockArea.addDock(volDock, 'right') global volumetricPlot volumetricPlot = VolumetricPlot() self.volumetricPlot = volumetricPlot # Store reference volDock.addWidget(volumetricPlot, 0, 0) # Set up transparency slider Tslider = QtGui.QSlider() Tslider.setMinimum(0) Tslider.setMaximum(255) Tslider.setValue(127) Tslider.valueChanged.connect(volumetricPlot.transparencyChanged) Tslider.sliderReleased.connect(volumetricPlot.updateVolumeData) volDock.addWidget(Tslider, 0, 1) Sslider = QtGui.QSlider() Sslider.setMinimum(0) Sslider.setMaximum(volumetricPlot.Nz) Sslider.setValue(volumetricPlot.sliceHeight) Sslider.valueChanged.connect(volumetricPlot.sliceHeightChanged) Sslider.sliderReleased.connect(volumetricPlot.sliceVolumeData) volDock.addWidget(Sslider, 0, 2) Pslider = QtGui.QSlider() Pslider.setMinimum(10) Pslider.setMaximum(150) Pslider.setValue(100) Pslider.valueChanged.connect(volumetricPlot.powerParamChanged) Pslider.sliderReleased.connect(volumetricPlot.updateVolumeData) volDock.addWidget(Pslider, 0, 3) self.show()
def init_ui(self): # Sets title and UI layout self.setWindowTitle('Plotter') win = QtGui.QBoxLayout(QtGui.QBoxLayout.LeftToRight) # creates a plot widget and adds it to the window self.plotwidget = pg.PlotWidget() self.plotwidget.setTitle("Test") self.plotwidget.setLabel('left', "Voltage(V)") self.plotwidget.setLabel('bottom', "Time(s)") self.plotwidget.showGrid(x=True, y=True) #self.plotwidget.addLegend() win.addWidget(self.plotwidget) #self.combo = pg.ComboBox() #win.addWidget(self.combo) butt_win = QtGui.QBoxLayout(QtGui.QBoxLayout.TopToBottom) #butt_win2 = QtGui.QBoxLayout(QtGui.QBoxLayout.TopToBottom) #butt_win = QtGui.QFormLayout() butt_win2 = QtGui.QFormLayout() # labels the buttons # ** Column 1 ** self.label1 = QtGui.QLabel("Plot 1") self.edit_freq_button1 = QtGui.QPushButton("Edit Frequency") self.edit_amp_button1 = QtGui.QPushButton("Edit Amplitude") self.edit_phase_button1 = QtGui.QPushButton("Edit Phase Angle") self.edit_color_button1 = QtGui.QPushButton("Edit Color") self.saveButton = QtGui.QPushButton("Save") # ** Column 2 ** # Label self.label2 = QtGui.QLabel("Plot 2") butt_win2.addRow(self.label2) # Frequency self.edit_freq_box2 = QtGui.QDoubleSpinBox() self.edit_freq_box2.setValue(self.frequency2) self.edit_freq_box2.setGeometry(1, 1, 1, 1) self.edit_freq_box2.setSingleStep(.1) self.edit_freq_box2.setMaximum(1000) butt_win2.addRow("Frequency", self.edit_freq_box2) self.freq_unit_box2 = QtGui.QComboBox() self.freq_unit_box2.addItems(["Hz", "kHz"]) butt_win2.addRow(self.freq_unit_box2) # Amplitude self.edit_amp_box2 = QtGui.QDoubleSpinBox() self.edit_amp_box2.setValue(self.amplitude2) self.edit_amp_box2.setGeometry(1, 1, 1, 1) self.edit_amp_box2.setSingleStep(.1) self.edit_amp_box2.setRange(-1000, 1000) butt_win2.addRow("Amplitude", self.edit_amp_box2) self.amp_unit_box2 = QtGui.QComboBox() self.amp_unit_box2.addItems(["V", "kV", "mV"]) butt_win2.addRow(self.amp_unit_box2) # Phase self.edit_phase_box2 = QtGui.QDoubleSpinBox() self.edit_phase_box2.setValue(self.phase2) self.edit_phase_box2.setGeometry(1, 1, 1, 1) self.edit_phase_box2.setSingleStep(15) self.edit_phase_box2.setRange(-360, 360) self.edit_phase_box2.setWrapping(True) butt_win2.addRow("Phase", self.edit_phase_box2) # Offset self.edit_offset_box2 = QtGui.QDoubleSpinBox() self.edit_offset_box2.setValue(self.offset2) self.edit_offset_box2.setGeometry(1, 1, 1, 1) self.edit_offset_box2.setSingleStep(.1) self.edit_offset_box2.setRange(-1000, 1000) butt_win2.addRow("Offset", self.edit_offset_box2) self.offset_unit_box2 = QtGui.QComboBox() self.offset_unit_box2.addItems(["V", "kV", "mV"]) butt_win2.addRow(self.offset_unit_box2) # Color self.color_box2 = QtGui.QComboBox() self.color_box2.addItems(["Red", "Blue", "Green", "White"]) self.color_box2.setCurrentIndex(3) butt_win2.addRow("Color", self.color_box2) self.details_button = QtGui.QPushButton("Details") #butt_win2.addRow("Amplitude", self.edit_freq_button2) # adds the buttons to the button window butt_win.addWidget(self.label1) butt_win.addWidget(self.edit_freq_button1) butt_win.addWidget(self.edit_amp_button1) butt_win.addWidget(self.edit_phase_button1) butt_win.addWidget(self.edit_color_button1) butt_win.addWidget(self.saveButton) #butt_win2.addWidget(self.label2) #butt_win2.addWidget(self.edit_freq_label2) #butt_win2.addWidget(self.edit_freq_button2) #butt_win2.addWidget(self.edit_freq_box2) #butt_win2.addWidget(self.edit_amp_button2) #butt_win2.addWidget(self.edit_offset_button2) #butt_win2.addWidget(self.edit_color_button2) #butt_win2.addWidget(self.details_button) self.setGeometry(20, 50, 1000, 600) # Sets the layout win.addLayout(butt_win) # adds the button window to the main window win.addLayout(butt_win2) self.setLayout(win) # sets the main layout self.show() # displays the window