def __init__(self, *args, **kwargs): super(PyMod_plot_window_qt, self).__init__(*args, **kwargs) # Central widget. self.central_widget = QtWidgets.QWidget() self.setCentralWidget(self.central_widget) self.central_widget_layout = QtWidgets.QGridLayout() self.central_widget.setLayout(self.central_widget_layout) #------------------------------------------------ # Upper frame (contains the plot and controls). - #------------------------------------------------ expanding_size_policy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) preferred_size_policy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred) # The upper frame contains three frames: info, plot and controls frames. # The infor and controls frames will be displayed only if the 'use_controls' # argument is set to 'True' when calling the 'build_plotting_area' method. self.upper_frame = QtWidgets.QFrame() self.upper_frame.setStyleSheet("background-color: #646464") self.upper_frame_layout = QtWidgets.QGridLayout() self.upper_frame.setLayout(self.upper_frame_layout) self.upper_frame.setSizePolicy(expanding_size_policy) self.central_widget_layout.addWidget(self.upper_frame, 0, 0) # Info frame, it contains the messagebar of the plot. self.info_frame = QtWidgets.QFrame() self.info_frame_layout = QtWidgets.QHBoxLayout() self.info_frame.setLayout(self.info_frame_layout) self.info_frame.setSizePolicy(preferred_size_policy) self.info_label = QtWidgets.QLabel("") self.info_frame_layout.addWidget(self.info_label) # Plot frame. self.plot_frame = QtWidgets.QFrame() # self.plot_frame.setStyleSheet("background-color: red") self.plot_frame_layout = QtWidgets.QGridLayout() self.plot_frame.setLayout(self.plot_frame_layout) self.plot_frame.setSizePolicy(expanding_size_policy) self.build_plot_widget() # Controls frame. self.controls_frame = QtWidgets.QWidget() self.controls_frame.setStyleSheet("background-color: #747474") self.controls_frame_layout = QtWidgets.QGridLayout() self.controls_frame.setLayout(self.controls_frame_layout) self.controls_frame_layout.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignTop) self.controls_scrollarea = QtWidgets.QScrollArea() self.controls_scrollarea.setWidgetResizable(True) self.controls_scrollarea.setWidget(self.controls_frame) self.labels_title = QtWidgets.QLabel("Plots list") # Middle splitter. self.middle_splitter = QtWidgets.QSplitter(QtCore.Qt.Horizontal) self.middle_splitter.setSizePolicy(expanding_size_policy) #--------------------------------------- # Lower frame (contains some options). - #--------------------------------------- self.lower_frame = QtWidgets.QFrame() self.lower_frame_layout = QtWidgets.QGridLayout() self.lower_frame.setLayout(self.lower_frame_layout) self.central_widget_layout.addWidget(self.lower_frame, 1, 0) # View buttons. self.view_label = QtWidgets.QLabel("View:") self.lower_frame_layout.addWidget(self.view_label, 0, 0) self.home_view_button = QtWidgets.QPushButton("Fit to data") self.home_view_button.clicked.connect(self.on_home_button_click) self.lower_frame_layout.addWidget(self.home_view_button, 0, 1) # On click behaviour. The buttons will be shown later, in the # 'build_plotting_area' metohd. self.interact_buttons_group = QtWidgets.QButtonGroup() self.on_click_label = QtWidgets.QLabel("Interact on click:") self.interact_button = QtWidgets.QPushButton("Yes") self.interact_button.setCheckable(True) self.interact_buttons_group.addButton(self.interact_button) self.interact_button.clicked.connect(self.on_interact_button_click) self.no_interaction_button = QtWidgets.QPushButton("No") self.no_interaction_button.setCheckable(True) self.no_interaction_button.setChecked(True) self.interact_buttons_group.addButton(self.no_interaction_button) self.no_interaction_button.clicked.connect(self.on_no_interaction_button_click) # Show/hide all buttons. They will be shown later, in the 'build_plotting_area' # method. self.show_label = QtWidgets.QLabel("Show:") self.show_all_button = QtWidgets.QPushButton("All") self.show_all_button.clicked.connect(self.show_all_command) self.hide_all_button = QtWidgets.QPushButton("None") self.hide_all_button.clicked.connect(self.hide_all_command) self.lower_frame_layout.setAlignment(QtCore.Qt.AlignLeft) #--------------------- # Build a main menu. - #--------------------- self.save_to_csv_action = QtWidgets.QAction('Save to CSV', self) self.save_to_csv_action.triggered.connect(lambda a=None: self.save_to_csv_event()) self.save_to_png_action = QtWidgets.QAction('Save to PNG', self) self.save_to_png_action.triggered.connect(lambda a=None: self.save_to_png_event()) self.main_menubar = self.menuBar() self.file_menu = self.main_menubar.addMenu('File')
def initUI(self): #---------------------------- # Left frame (for headers). - #---------------------------- self.sequence_ID_groupbox = QtWidgets.QGroupBox('SEQUENCE ID') # self.sequence_ID_groupbox.setStyleSheet("QLabel {font: 14pt COURIER NEW font-weight: bold} ") id_frame_stylesheet = "QLabel {font: %spt %s; font-weight: %s; color: white}" % ( self.main_window.font_size, self.main_window.font, self.main_window.font_weight) self.sequence_ID_groupbox.setStyleSheet(id_frame_stylesheet) self.id_form_layout = QtWidgets.QFormLayout() #self.left_scroll self.left_scroll = QtWidgets.QScrollArea() self.left_scroll.setHorizontalScrollBarPolicy( QtCore.Qt.ScrollBarAlwaysOn) self.left_scroll.setVerticalScrollBarPolicy( QtCore.Qt.ScrollBarAsNeeded) self.left_scroll.resize(200, 400) self.left_scroll.setWidget( self.sequence_ID_groupbox ) # sequence_ID_groupbox dentro left_scroll area self.left_scroll.setWidgetResizable(True) #self.left_frame self.left_frame = QtWidgets.QFrame(self) self.left_frame.setFrameShape(QtWidgets.QFrame.StyledPanel) self.left_frame.resize(200, 400) self.left_frame.setStyleSheet(self.style) self.left_frame.setFrameShadow(QtWidgets.QFrame.Sunken) #self.left_frame_layout self.left_frame_layout = QtWidgets.QVBoxLayout(self) self.left_frame_layout.addWidget(self.left_scroll) self.left_frame.setLayout( self.left_frame_layout) # left_frame_layout dentro left_frame #------------------------------- # Right frame (for sequences). - #------------------------------- # This groupbox self.sequence_SEQ_groupbox = QtWidgets.QGroupBox('SEQUENCES') seq_frame_stylesheet = "QLabel {font: %spt %s; font-weight: %s; color: white}" % ( self.main_window.font_size, self.main_window.font, self.main_window.font_weight) self.sequence_SEQ_groupbox.setStyleSheet(seq_frame_stylesheet) self.seq_form_layout = QtWidgets.QFormLayout() #self.right_scroll self.right_scroll = QtWidgets.QScrollArea() self.right_scroll.setHorizontalScrollBarPolicy( QtCore.Qt.ScrollBarAlwaysOn) self.right_scroll.setVerticalScrollBarPolicy( QtCore.Qt.ScrollBarAsNeeded) self.right_scroll.resize(900, 400) self.right_scroll.setWidget( self.sequence_SEQ_groupbox ) # sequence_ID_groupbox dentro left_scroll area self.right_scroll.setWidgetResizable(True) #self.right_frame self.right_frame = QtWidgets.QFrame(self) self.right_frame.setFrameShape(QtWidgets.QFrame.StyledPanel) self.right_frame.resize(900, 400) self.right_frame.setStyleSheet(self.style) self.right_frame.setFrameShadow(QtWidgets.QFrame.Sunken) #self.right_frame_layout self.right_frame_layout = QtWidgets.QVBoxLayout(self) self.right_frame_layout.addWidget(self.right_scroll) self.right_frame.setLayout( self.right_frame_layout) # left_frame_layout dentro left_frame #connect the two Vertical Bars to move them togheter self.left_scroll.verticalScrollBar().valueChanged.connect( self.right_scroll.verticalScrollBar().setValue) self.right_scroll.verticalScrollBar().valueChanged.connect( self.left_scroll.verticalScrollBar().setValue) #---------------------------------- # Bottom part of the main window. - #---------------------------------- self.splitter1 = QtWidgets.QSplitter(QtCore.Qt.Horizontal) self.splitter1.addWidget(self.left_frame) self.splitter1.addWidget(self.right_frame) # creating sequence and position labels self.label_sequence = QtWidgets.QLabel(self) self.label_sequence.setText('Sequence:') self.label_sequence.setStyleSheet(small_font_style) self.textbox_sequence = QtWidgets.QLineEdit(self) self.textbox_sequence.setStyleSheet(self.style + "; " + small_font_style) self.textbox_sequence.setReadOnly(True) self.label_position = QtWidgets.QLabel(self) self.label_position.setText('Position:') self.label_position.setStyleSheet(small_font_style) self.textbox_position = QtWidgets.QLineEdit(self) self.textbox_position.setReadOnly(True) self.textbox_position.setStyleSheet(self.style + "; " + small_font_style) self.textbox_position.setMinimumWidth( 675) # Width of the residues message bar width. # creating an horizontal layout with sequence and position labels self.text_layout = QtWidgets.QHBoxLayout() self.text_layout.addWidget(self.label_sequence) self.text_layout.addWidget(self.textbox_sequence) self.text_layout.addWidget(self.label_position) self.text_layout.addWidget(self.textbox_position) # creating a layout with sequence window and labels self.grid = QtWidgets.QVBoxLayout() self.grid.addWidget(self.splitter1) self.grid.addLayout(self.text_layout) self.setLayout(self.grid)