def __init__(self, parent=None, *, show_navbar=True): super().__init__(parent) mpl.rcParams.update({ "text.color": "white", "axes.labelcolor": "white", "xtick.color": "white", "ytick.color": "white", "font.size": 8 }) layout = QVBoxLayout(self) layout.setContentsMargins(0, 0, 0, 0) self.figure = Figure(facecolor="none") self.canvas = WrappedCanvas(self.figure) self.setStyleSheet("background-color:palette(alternate-base);") layout.addWidget(self.canvas) if not show_navbar: return navbar = NavBar(self.canvas, self, coordinates=False) navbar_container = QWidget() navbar_container.setContentsMargins(0, 0, 0, 0) navbar_container.setFixedHeight(50) navbar_layout = QHBoxLayout(navbar_container) navbar_layout.addWidget(navbar) navbar_layout.setAlignment(navbar, Qt.AlignCenter) layout.addWidget(navbar_container)
def __init__(self, parent=None): super().__init__(parent=parent) setMplDefaults() self.plot = MPLPlot() layout = QtGui.QVBoxLayout(self) layout.addWidget(self.plot) layout.addWidget(NavBar(self.plot, self))
def initUI(self): # The graph widgets self.Graph = PlotCanvas(False, False, parent=self) self.toolbar = NavBar(self.Graph, self) control_panel = ButtonPanel(self) fncs.AllInOneLayout(self, [self.Graph, control_panel], Stretches=[4, 1], VH='h') self.show()
def __init__(self, parent=None): super().__init__(parent=parent) setMplDefaults() self.plot = MPLPlot() self.mplBar = NavBar(self.plot, self) self.addMplBarOptions() self.mplBar.setIconSize(QtCore.QSize(16, 16)) self.layout = QtGui.QVBoxLayout(self) self.layout.addWidget(self.plot) self.layout.addWidget(self.mplBar)
def __init__(self, parent=None): super().__init__(parent=parent) setMplDefaults() self.plot = MPLPlot() self.mplBar = NavBar(self.plot, self) self.addMplBarOptions() self.toolLayout = QtGui.QHBoxLayout() self.layout = QtGui.QVBoxLayout(self) self.layout.addLayout(self.toolLayout) self.layout.addWidget(self.plot) self.layout.addWidget(self.mplBar)
def __init__(self, parent: Optional[QtWidgets.QWidget] = None): super().__init__(parent=parent) #: the plot widget self.plot = MPLPlot() #: the matplotlib toolbar self.mplBar = NavBar(self.plot, self) self.addMplBarOptions() defaultIconSize = int(16 * dpiScalingFactor(self)) self.mplBar.setIconSize(QtCore.QSize(defaultIconSize, defaultIconSize)) layout = QtWidgets.QVBoxLayout(self) layout.addWidget(self.plot) layout.addWidget(self.mplBar) self.setLayout(layout)
def __init__(self, parent, log_handlers: [StreamHandler]): self._logger = getLogger(__name__) for h in log_handlers: self._logger.addHandler(h) self._logger.debug("Initializing") super().__init__(Figure(figsize=(5, 5))) self.setParent(parent) self._new = True self._nav_bar = NavBar(self, parent) self._nav_bar.update() # self._leg_plot_links = dict() self._plots = list() # name, coords, active self._v_lines = list() self._base_strings = dict() # self.figure.canvas.mpl_connect('pick_event', self._onpick) self._logger.debug("Initialized")
def __init__(self, parent: Optional[QtWidgets.QWidget] = None): super().__init__(parent=parent) setMplDefaults(self) scaling = np.rint(self.logicalDpiX() / 96.0) defaultIconSize = 16 * scaling self.plot = MPLPlot() self.mplBar = NavBar(self.plot, self) self.addMplBarOptions() self.mplBar.setIconSize(QtCore.QSize(defaultIconSize, defaultIconSize)) layout = QtWidgets.QVBoxLayout(self) layout.addWidget(self.plot) layout.addWidget(self.mplBar) self.setLayout(layout)
def __init__(self, data_id, parent=None): super().__init__(parent) self.data_id = data_id search_str = 'run ID = ' idx = self.data_id.find(search_str) + len(search_str) run_id = int(self.data_id[idx:].strip()) self.setWindowTitle(f"{get_app_title()} (#{run_id})") self.active_dataset = None self.data = {} self.data_struct = {} self.adding_queue = {} self.plot_data_pending = False self.current_plot_choice_info = None # plot settings set_matplotlib_defaults() # data chosing widgets self.structure_widget = DataStructure() self.plot_choice = PlotChoice() chooser_layout = QtWidgets.QVBoxLayout() chooser_layout.addWidget(self.structure_widget) chooser_layout.addWidget(self.plot_choice) # plot control widgets self.plot = MPLPlot(width=5, height=4) plot_layout = QtWidgets.QVBoxLayout() plot_layout.addWidget(self.plot) plot_layout.addWidget(NavBar(self.plot, self)) # Main layout self.frame = QtWidgets.QFrame() main_layout = QtWidgets.QHBoxLayout(self.frame) main_layout.addLayout(chooser_layout) main_layout.addLayout(plot_layout) # data processing threads self.data_adder = DataAdder() self.data_adder_thread = QtCore.QThread() self.data_adder.moveToThread(self.data_adder_thread) self.data_adder.data_updated.connect(self.data_from_adder) self.data_adder.data_updated.connect(self.data_adder_thread.quit) self.data_adder_thread.started.connect(self.data_adder.run) self.plot_data = PlotData() self.plot_data_thread = QtCore.QThread() self.plot_data.moveToThread(self.plot_data_thread) self.plot_data.data_processed.connect(self.update_plot) self.plot_data.data_processed.connect(self.plot_data_thread.quit) self.plot_data_thread.started.connect(self.plot_data.process_data) # signals/slots for data selection etc. self.data_added.connect(self.structure_widget.update) self.data_added.connect(self.update_plot_data) self.structure_widget.itemSelectionChanged.connect(self.activate_data) self.data_activated.connect(self.plot_choice.set_options) self.plot_choice.choice_updated.connect(self.update_plot_data) # activate window self.frame.setFocus() self.setCentralWidget(self.frame) self.activateWindow()
def __init__(self) -> None: """ViolinGUI Constructor. Defines all aspects of the GUI.""" # ## Setup section # Inherits from QMainWindow super().__init__() self.rootdir = get_project_root() # QMainWindow basic properties self.setWindowTitle("SCOUTS - Violins") self.setWindowIcon( QIcon( os.path.abspath(os.path.join(self.rootdir, 'src', 'scouts.ico')))) # Creates QWidget as QMainWindow's central widget self.page = QWidget(self) self.setCentralWidget(self.page) # Miscellaneous initialization values self.threadpool = QThreadPool() # Threadpool for workers self.population_df = None # DataFrame of whole population (raw data) self.summary_df = None # DataFrame indicating which SCOUTS output corresponds to which rule self.summary_path = None # path to all DataFrames generated by SCOUTS self.main_layout = QVBoxLayout(self.page) # Title section # Title self.title = QLabel(self.page) self.title.setText('SCOUTS - Violins') self.title.setStyleSheet(self.style['title']) self.title.adjustSize() self.main_layout.addWidget(self.title) # ## Input section # Input header self.input_header = QLabel(self.page) self.input_header.setText('Load data') self.input_header.setStyleSheet(self.style['header']) self.input_header.adjustSize() self.main_layout.addWidget(self.input_header) # Input/Output frame self.input_frame = QFrame(self.page) self.input_frame.setFrameShape(QFrame.StyledPanel) self.input_frame.setLayout(QFormLayout()) self.main_layout.addWidget(self.input_frame) # Raw data button self.input_button = QPushButton(self.page) self.input_button.setStyleSheet(self.style['button']) self.set_icon(self.input_button, 'x-office-spreadsheet') self.input_button.setObjectName('file') self.input_button.setText(' Load raw data file') self.input_button.setToolTip( 'Load raw data file (the file given to SCOUTS as the input file)') self.input_button.clicked.connect(self.get_path) # SCOUTS results button self.output_button = QPushButton(self.page) self.output_button.setStyleSheet(self.style['button']) self.set_icon(self.output_button, 'folder') self.output_button.setObjectName('folder') self.output_button.setText(' Load SCOUTS results') self.output_button.setToolTip( 'Load data from SCOUTS analysis ' '(the folder given to SCOUTS as the output folder)') self.output_button.clicked.connect(self.get_path) # Add widgets above to input frame Layout self.input_frame.layout().addRow(self.input_button) self.input_frame.layout().addRow(self.output_button) # ## Samples section # Samples header self.samples_header = QLabel(self.page) self.samples_header.setText('Select sample names') self.samples_header.setStyleSheet(self.style['header']) self.samples_header.adjustSize() self.main_layout.addWidget(self.samples_header) # Samples frame self.samples_frame = QFrame(self.page) self.samples_frame.setFrameShape(QFrame.StyledPanel) self.samples_frame.setLayout(QFormLayout()) self.main_layout.addWidget(self.samples_frame) # Samples label self.samples_label = QLabel(self.page) self.samples_label.setText( 'Write sample names delimited by semicolons below.\nEx: Control;Treat_01;Pac-03' ) self.samples_label.setStyleSheet(self.style['label']) # Sample names line edit self.sample_names = QLineEdit(self.page) self.sample_names.setStyleSheet(self.style['line edit']) # Add widgets above to samples frame Layout self.samples_frame.layout().addRow(self.samples_label) self.samples_frame.layout().addRow(self.sample_names) # ## Analysis section # Analysis header self.analysis_header = QLabel(self.page) self.analysis_header.setText('Plot parameters') self.analysis_header.setStyleSheet(self.style['header']) self.analysis_header.adjustSize() self.main_layout.addWidget(self.analysis_header) # Analysis frame self.analysis_frame = QFrame(self.page) self.analysis_frame.setFrameShape(QFrame.StyledPanel) self.analysis_frame.setLayout(QFormLayout()) self.main_layout.addWidget(self.analysis_frame) # Analysis labels self.analysis_label_01 = QLabel(self.page) self.analysis_label_01.setText('Compare') self.analysis_label_01.setStyleSheet(self.style['label']) self.analysis_label_02 = QLabel(self.page) self.analysis_label_02.setText('with') self.analysis_label_02.setStyleSheet(self.style['label']) self.analysis_label_03 = QLabel(self.page) self.analysis_label_03.setText('for marker') self.analysis_label_03.setStyleSheet(self.style['label']) self.analysis_label_04 = QLabel(self.page) self.analysis_label_04.setText('Outlier type') self.analysis_label_04.setStyleSheet(self.style['label']) # Analysis drop-down boxes self.drop_down_01 = QComboBox(self.page) self.drop_down_01.addItems([ 'whole population', 'non-outliers', 'top outliers', 'bottom outliers', 'none' ]) self.drop_down_01.setStyleSheet(self.style['drop down']) self.drop_down_01.setCurrentIndex(2) self.drop_down_02 = QComboBox(self.page) self.drop_down_02.addItems([ 'whole population', 'non-outliers', 'top outliers', 'bottom outliers', 'none' ]) self.drop_down_02.setStyleSheet(self.style['drop down']) self.drop_down_02.setCurrentIndex(0) self.drop_down_03 = QComboBox(self.page) self.drop_down_03.setStyleSheet(self.style['drop down']) self.drop_down_04 = QComboBox(self.page) self.drop_down_04.addItems(['OutS', 'OutR']) self.drop_down_04.setStyleSheet(self.style['drop down']) # Add widgets above to samples frame Layout self.analysis_frame.layout().addRow(self.analysis_label_01, self.drop_down_01) self.analysis_frame.layout().addRow(self.analysis_label_02, self.drop_down_02) self.analysis_frame.layout().addRow(self.analysis_label_03, self.drop_down_03) self.analysis_frame.layout().addRow(self.analysis_label_04, self.drop_down_04) self.legend_checkbox = QCheckBox(self.page) self.legend_checkbox.setText('Add legend to the plot') self.legend_checkbox.setStyleSheet(self.style['checkbox']) self.main_layout.addWidget(self.legend_checkbox) # Plot button (stand-alone) self.plot_button = QPushButton(self.page) self.set_icon(self.plot_button, 'system-run') self.plot_button.setText(' Plot') self.plot_button.setToolTip( 'Plot data after loading the input data and selecting parameters') self.plot_button.setStyleSheet(self.style['run button']) self.plot_button.setEnabled(False) self.plot_button.clicked.connect(self.run_plot) self.main_layout.addWidget(self.plot_button) # ## Secondary Window # This is used to plot the violins only self.secondary_window = QMainWindow(self) self.secondary_window.resize(720, 720) self.dynamic_canvas = DynamicCanvas(self.secondary_window, width=6, height=6, dpi=120) self.secondary_window.setCentralWidget(self.dynamic_canvas) self.secondary_window.addToolBar( NavBar(self.dynamic_canvas, self.secondary_window))
def __init__(self, dataId, parent=None): super().__init__(parent) self.dataId = dataId self.setWindowTitle(getAppTitle() + f" ({dataId})") self.data = {} self.addingQueue = {} self.currentlyProcessingPlotData = False self.pendingPlotData = False # plot settings setMplDefaults() # data chosing widgets self.structureWidget = DataStructure() self.plotChoice = PlotChoice() chooserLayout = QVBoxLayout() chooserLayout.addWidget(self.structureWidget) chooserLayout.addWidget(self.plotChoice) # plot control widgets self.plot = MPLPlot() plotLayout = QVBoxLayout() plotLayout.addWidget(self.plot) plotLayout.addWidget(NavBar(self.plot, self)) # Main layout self.frame = QFrame() mainLayout = QHBoxLayout(self.frame) mainLayout.addLayout(chooserLayout) mainLayout.addLayout(plotLayout) # data processing threads self.dataAdder = DataAdder() self.dataAdderThread = QThread() self.dataAdder.moveToThread(self.dataAdderThread) self.dataAdder.dataUpdated.connect(self.dataFromAdder) self.dataAdder.dataUpdated.connect(self.dataAdderThread.quit) self.dataAdderThread.started.connect(self.dataAdder.run) self.plotData = PlotData() self.plotDataThread = QThread() self.plotData.moveToThread(self.plotDataThread) self.plotData.dataProcessed.connect(self.updatePlot) self.plotData.dataProcessed.connect(self.plotDataThread.quit) self.plotDataThread.started.connect(self.plotData.processData) # signals/slots for data selection etc. self.dataAdded.connect(self.structureWidget.update) self.dataAdded.connect(self.updatePlotChoices) self.dataAdded.connect(self.updatePlotData) self.structureWidget.itemSelectionChanged.connect(self.activateData) self.dataActivated.connect(self.plotChoice.setOptions) self.plotChoice.choiceUpdated.connect(self.updatePlotData) # activate window self.frame.setFocus() self.setCentralWidget(self.frame) self.activateWindow()
def __init__(self, parent): self.figure = plt.figure(facecolor='white') self.canvas = Canvas(self.figure) self.toolbar = NavBar(self.canvas, parent)