def setupUi(self, Dialog): # Based on auto-generated code from ui file from pymol.Qt import QtCore, QtWidgets Dialog.resize(400, 50) self.gridLayout = QtWidgets.QGridLayout(Dialog) label = QtWidgets.QLabel("Select loaded object:", Dialog) self.gridLayout.addWidget(label, 0, 0, 1, 1) self.select_object_combo_box = QtWidgets.QComboBox(Dialog) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed) self.select_object_combo_box.setSizePolicy(sizePolicy) self.select_object_combo_box.setEditable(True) self.gridLayout.addWidget(self.select_object_combo_box, 0, 1, 1, 1) label = QtWidgets.QLabel("Select loaded object:", Dialog) self.gridLayout.addWidget(label, 1, 0, 1, 1) self.select_object_combo_box2 = QtWidgets.QComboBox(Dialog) self.select_object_combo_box2.setSizePolicy(sizePolicy) self.select_object_combo_box2.setEditable(True) self.gridLayout.addWidget(self.select_object_combo_box2, 1, 1, 1, 1) self.buttonBox = QtWidgets.QDialogButtonBox(Dialog) self.buttonBox.setOrientation(QtCore.Qt.Horizontal) self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel | QtWidgets.QDialogButtonBox.Ok) self.gridLayout.addWidget(self.buttonBox, 2, 0, 1, 2) self.buttonBox.accepted.connect(Dialog.accept) self.buttonBox.rejected.connect(Dialog.reject)
def __init__(self, label_text="Input", value="", style=None): PyMod_form_item.__init__(self) # Label. self.label = QtWidgets.QLabel(label_text) # Entry. self.entry = QtWidgets.QPlainTextEdit(value) if style is not None: self.entry.setStyleSheet(style) else: self.entry.setStyleSheet(active_entry_style) self.entry.setWordWrapMode(QtGui.QTextOption.WrapAnywhere) expanding_size_policy = QtWidgets.QSizePolicy( QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) expanding_size_policy.setVerticalStretch(1) self.entry.setSizePolicy(expanding_size_policy) self.input = self.entry
def __init__(self, parent, protocol): super(Hmmscan_results_window_qt, self).__init__(parent) self.protocol = protocol self.query_len = len( self.protocol.query_element.my_sequence.replace('-', '')) ######################### # Configure the window. # ######################### self.setWindowTitle("HMMSCAN Results") # Sets the central widget. self.central_widget = QtWidgets.QWidget() self.setCentralWidget(self.central_widget) # The window has a main vbox layout. self.main_vbox = QtWidgets.QVBoxLayout() # Parameters used to draw the 'QGraphicsView' widgets for showing domains. self.preferred_size_policy = QtWidgets.QSizePolicy( QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred) self.view_bg_color = "transparent" self.full_seq_pen = QtGui.QPen(QtGui.QColor(0, 0, 0, 0), 2) self.full_seq_color = "#7f7f7f" qcolor = QtGui.QColor(0, 0, 0) qcolor.setNamedColor(self.full_seq_color) self.full_seq_brush = QtGui.QBrush(qcolor) self.font_qcolor = QtGui.QColor(220, 220, 220, 255) self.font_size = 7 ################ # Upper frame. # ################ self.upper_frame = QtWidgets.QFrame() self.upper_frame_layout = QtWidgets.QGridLayout() self.upper_frame.setLayout(self.upper_frame_layout) self.main_vbox.addWidget(self.upper_frame) if 'query_descr' in self.protocol.parsed_res[ 0] and self.protocol.parsed_res[0]['query_descr']: labelseq = self.protocol.query_element.my_header # + '\n' + querydescr else: try: if len(self.protocol.query_element.description) > 79: labelseq = self.protocol.query_element.description[:78] + '...' else: labelseq = self.protocol.query_element.description except TypeError: labelseq = self.protocol.query_element.my_header self.upper_frame_title = QtWidgets.QLabel( "HMMSCAN search results for " + labelseq) self.upper_frame_layout.addWidget(self.upper_frame_title) #------------------------- # Domain graphics frame. - #------------------------- # Builds the scene where to draw the domain representations. self.canvas_plot_scene = QtWidgets.QGraphicsScene() self.canvas_plot_view = QtWidgets.QGraphicsView(self.canvas_plot_scene) self.canvas_plot_view.setFixedHeight(120) self.canvas_plot_view.setSizePolicy(self.preferred_size_policy) self.canvas_plot_view.setStyleSheet("background: %s" % self.view_bg_color) self.upper_frame_layout.addWidget(self.canvas_plot_view) # Draw a rectangle with the full sequence. self.x_init = 10 y_init = 95 # 95 self.domain_y_init = y_init - 7 self.full_seq_rect_w = 800 full_seq_rect_h = 10 self.canvas_plot_scene.addRect(self.x_init, y_init, self.full_seq_rect_w, full_seq_rect_h, self.full_seq_pen, self.full_seq_brush) # Draw the labels for the N- and C-terminal residues. text_offset_y = 15 text_offset_x = 10 text_n = self.canvas_plot_scene.addText("1") text_n.setPos(self.x_init - text_offset_x, y_init + text_offset_y) text_n.setDefaultTextColor(self.font_qcolor) text_n.setFont(QtGui.QFont(text_n.font().family(), self.font_size)) c_label = str(self.query_len) text_c = self.canvas_plot_scene.addText(c_label) text_offset_x_add = 5 if len(c_label) > 2: text_offset_x_add = 10 text_c.setPos( self.x_init + self.full_seq_rect_w - text_offset_x - text_offset_x_add, y_init + text_offset_y) text_c.setDefaultTextColor(self.font_qcolor) text_c.setFont(QtGui.QFont(text_c.font().family(), self.font_size)) ################# # Middle frame. # ################# # Scroll area which contains the widgets, set as the centralWidget. self.middle_scroll = QtWidgets.QScrollArea() self.main_vbox.addWidget(self.middle_scroll) # Widget that contains the collection of Vertical Box. self.middle_widget = QtWidgets.QWidget() # Scroll area properties. self.middle_scroll.setWidgetResizable(True) self.middle_scroll.setWidget(self.middle_widget) # QFormLayout in the middle frame. self.middle_formlayout = QtWidgets.QFormLayout() self.middle_widget.setLayout(self.middle_formlayout) #----------------- # Results frame. - #----------------- # Set the frame and its layout. self.results_frame = QtWidgets.QFrame() self.middle_formlayout.addRow(self.results_frame) self.results_grid = QtWidgets.QGridLayout() self.results_frame.setLayout(self.results_grid) # Calls a method which actually displays the similarity searches results. self.display_hmmscan_hits() # Align the gridded widgets to the left. self.results_grid.setAlignment(QtCore.Qt.AlignLeft) self.results_grid.setHorizontalSpacing(30) ################# # Bottom frame. # ################# self.main_button = QtWidgets.QPushButton("Submit") self.main_button.clicked.connect( lambda a=None: self.protocol.hmmer_results_state()) self.main_vbox.addWidget(self.main_button) self.main_button.setFixedWidth(self.main_button.sizeHint().width()) # Sets the main vertical layout. self.central_widget.setLayout(self.main_vbox) self.main_vbox.setAlignment(self.main_button, QtCore.Qt.AlignCenter)