def __init__(self, parent, cmd): QtWidgets.QWidget.__init__(self, parent, Qt.Window) self.setMinimumSize(400, 500) self.cmd = cmd self.model = QtGui.QStandardItemModel(self) self.proxy_model = QtCoreModels.QSortFilterProxyModel(self) self.proxy_model.setSourceModel(self.model) self.setWindowTitle('PyMOL Advanced Settings') layout = QtWidgets.QVBoxLayout(self) self.setLayout(layout) self.filter_le = QtWidgets.QLineEdit(self) layout.addWidget(self.filter_le) self.filter_le.setPlaceholderText("Filter") self.filter_le.textChanged.connect(self.proxy_model.setFilterRegExp) self.populateData() self.table = QtWidgets.QTableView(self) self.table.setModel(self.proxy_model) layout.addWidget(self.table) self.formatTable() self.model.itemChanged.connect(self.itemChanged)
def initUI(self): self.setWindowTitle('PyMod Directory Selection') self.vertical_layout = QtWidgets.QVBoxLayout() # Main label. self.label = QtWidgets.QLabel( "Select a folder inside which to build the 'PyMod Directory'", self) self.vertical_layout.addWidget(self.label) # Entry and "Browse" button. self.horizontal_layout = QtWidgets.QHBoxLayout() self.main_entry = QtWidgets.QLineEdit(self.pymod.home_directory, self) self.main_entry.setStyleSheet("background-color: white; color: black") self.horizontal_layout.addWidget(self.main_entry) self.browse_button = QtWidgets.QPushButton("BROWSE", self) self.browse_button.clicked.connect(self.pymod_directory_browse_state) self.horizontal_layout.addWidget(self.browse_button) self.vertical_layout.addLayout(self.horizontal_layout) # "Submit" button. self.submit_button = QtWidgets.QPushButton("SUBMIT", self) self.submit_button.setFixedWidth(self.submit_button.sizeHint().width()) self.submit_button.clicked.connect(self.on_submit_button_press) self.vertical_layout.addWidget(self.submit_button) self.vertical_layout.setAlignment(self.submit_button, QtCore.Qt.AlignCenter) # Set the layouts. self.setLayout(self.vertical_layout)
def create_dialog(): dialog = QtWidgets.QDialog() dialog.setWindowTitle('Lighting Settings') sliders = [ "Diffuse Reflection", ('ambient', 0, 1, None), ('reflect', -1, 1, None), "Direct Light from Front", ('direct (+reflect)', -1, 1, None), # diffuse, coupled with "reflect" ('spec_direct', 0, 1, None), ('spec_direct_power', 0, 100, 1), "Free placeable directed Lights", ('light_count', 1, 8, 1), ('edit_light', 1, 7, 1), "Specular Reflection", ('spec_count', -1, 8, 1), # ('spec_power', -1, 200, 1), # deprecated since v1.5 ('shininess', 0, 100, None), # same as spec_power ('spec_reflect', -0.01, 1, None), ('specular', 0, 1, None), ('specular_intensity (=specular)', 0, 1, None), # same as specular "Ambient Occlusion (Surface only)", ('ambient_occlusion_mode', 0, 2, 1), ('ambient_occlusion_scale', 1.0, 50., None), ('ambient_occlusion_smooth', 1, 20, 1), "Ray trace only", ('power', 1, 10, None), ('reflect_power', 1, 10, None), ] layout = QtWidgets.QVBoxLayout(dialog) button_layout = QtWidgets.QHBoxLayout() layout.addLayout(button_layout) layout.setContentsMargins(5, 0, 5, 0) button_layout.addWidget( QtWidgets.QLabel("<font color=red>Presets:</font>")) presets = [ ("Default", preset_default), ("Metal", preset_metal), ("Plastic", preset_plastic), ("Rubber", preset_rubber), ("X-Ray", preset_xray), ] for name, fun in presets: btn = QtWidgets.QPushButton(name, dialog) btn.pressed.connect(fun) btn.setAutoDefault(False) button_layout.addWidget(btn) form_layout = QtWidgets.QFormLayout() form_layout.setContentsMargins(0, 0, 0, 0) form_layout.setVerticalSpacing(0) form_layout.setLabelAlignment(Qt.AlignLeft) layout.addLayout(form_layout) for i, item in enumerate(sliders, 1): if isinstance(item, str): label = QtWidgets.QLabel("<font color=blue>" + item + "</font>") form_layout.addRow(label) continue name, min, max, res = item if res is None: res = 0.01 if (max - min < 100) else 0.1 line_edit = QtWidgets.QLineEdit(dialog) slider = SettingSlider(dialog, name.split()[0], min, max, res, line_edit) h_layout = QtWidgets.QHBoxLayout() h_layout.addWidget(slider, 3) h_layout.addWidget(line_edit, 1) form_layout.addRow(name, h_layout) return dialog
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)
def display_paramenter_options(self, parameter): """ Used to display a series of widgets to choose the parameter value in PyMod options window. This is conditioned on the type of input widget of the 'parameter'. """ # Label with the name of the parameter. param_full_name_label = QtWidgets.QLabel(parameter.full_name) self.middle_formlayout.addWidget(param_full_name_label, self.row_counter, 0) # Do not display any input widget. if parameter.widget_type is None: pass # Display any a text entry input. elif parameter.widget_type == "path_entryfield": # Entry for the path. path_entryfield = QtWidgets.QLineEdit( str(parameter.get_starting_value())) if parameter.editable: path_entryfield.setStyleSheet(active_entry_style + "; " + small_font_style) else: path_entryfield.setStyleSheet(inactive_entry_style + "; " + small_font_style) path_entryfield.setEnabled(False) self.middle_formlayout.addWidget(path_entryfield, self.row_counter, 1) self.tools_params_dict[parameter.parent_tool.name][ parameter.name] = path_entryfield # Button for browsing the path. if parameter.editable: path_browse_button = QtWidgets.QPushButton("Browse") path_browse_button.setStyleSheet(small_font_style) if parameter.path_type in ("file", "directory"): path_browse_button.clicked.connect( lambda a=None, p=parameter: self.choose_path(p)) else: raise KeyError("Unknown 'path_type': %s" % str(parameter.path_type)) self.middle_formlayout.addWidget(path_browse_button, self.row_counter, 2) # Button to automatically identifying the path. if parameter.auto_find: auto_find_button = QtWidgets.QPushButton("Auto Find") auto_find_button.setStyleSheet(small_font_style) self.middle_formlayout.addWidget(auto_find_button, self.row_counter, 3) auto_find_button.clicked.connect( lambda a=None, e=path_entryfield: parameter. auto_find_command(e)) # Show the status of a parameter. elif parameter.widget_type == "show_status": text_to_show, status = parameter.get_status() status_entryfield = QtWidgets.QLineEdit(text_to_show) if status: status_entryfield.setStyleSheet("background-color: %s" % success_bg_color) else: status_entryfield.setStyleSheet("background-color: %s" % failure_bg_color) status_entryfield.setEnabled(False) status_entryfield.setFixedWidth(200) self.middle_formlayout.addWidget(status_entryfield, self.row_counter, 1) else: raise KeyError("Unkown 'widget_type': %s" % parameter.widget_type)
def build_panel_elements(self, parent): ''' Responsible for creating all panel elements in order and adding them to the layout. ''' self.create_new_form = parent.load_form("create_shortcut", None) self.help_form = parent.load_form("help_shortcut", None) self.confirm_change = parent.load_form("change_confirm", None) self.model = QtGui.QStandardItemModel(self) self.proxy_model = QtCoreModels.QSortFilterProxyModel(self) self.proxy_model.setSourceModel(self.model) self.proxy_model.setFilterCaseSensitivity(Qt.CaseInsensitive) self.proxy_model.setFilterKeyColumn(-1) self.setWindowTitle('Keyboard Shortcut Menu') layout = QtWidgets.QVBoxLayout(self) self.setLayout(layout) # Create layout for filter bar and refresh button top_layout = QtWidgets.QGridLayout() layout.addLayout(top_layout) # Filter self.filter_le = QtWidgets.QLineEdit(self) top_layout.addWidget(self.filter_le) self.filter_le.setPlaceholderText("Filter") self.filter_le.textChanged.connect(self.proxy_model.setFilterRegExp) self.refresh_button = QtWidgets.QPushButton(self) self.refresh_button.resize(26, 26) top_layout.addWidget(self.refresh_button, 0, 1) # themed icons only available by default on X11 if self.refresh_button.icon().isNull(): self.refresh_button.setIcon(QtGui.QIcon( os.path.expandvars('$PYMOL_DATA/pmg_qt/icons/refresh.svg'))) self.refresh_button.setToolTip( "Refresh the table to reflect any external changes") self.refresh_button.clicked.connect(self.refresh_populate) # Table self.table = QtWidgets.QTableView(self) self.table.setModel(self.proxy_model) layout.addWidget(self.table) self.intial_populate() self.formatTable() # Add layout for buttons button_layout = QtWidgets.QGridLayout() layout.addLayout(button_layout) # Buttons self.create_new_button = QtWidgets.QPushButton(self) button_layout.addWidget(self.create_new_button, 0, 0) self.create_new_button.setText("Create New") self.create_new_button.setToolTip( "Add a key binding that does not currently appear on the table") self.create_new_button.clicked.connect( lambda: self.create_new_form._dialog.show()) self.delete_selected_button = QtWidgets.QPushButton(self) button_layout.addWidget(self.delete_selected_button, 0, 1) self.delete_selected_button.setText("Delete Selected") self.delete_selected_button.setToolTip( "Unbind selected key bindings and remove any that have been created") self.delete_selected_button.clicked.connect(self.delete_selected) self.delete_selected_button.setEnabled(False) self.reset_selected_button = QtWidgets.QPushButton(self) button_layout.addWidget(self.reset_selected_button, 0, 2) self.reset_selected_button.setText("Reset Selected") self.reset_selected_button.setToolTip( "Restore selected key bindings to their default values") self.reset_selected_button.clicked.connect(self.reset_selected) self.reset_selected_button.setEnabled(False) self.reset_all_button = QtWidgets.QPushButton(self) button_layout.addWidget(self.reset_all_button, 0, 3) self.reset_all_button.setText("Reset All") self.reset_all_button.setToolTip( "Restore all key bindings to their default values and remove any that have been created") self.reset_all_button.clicked.connect(self.reset_all_default) self.save_button = QtWidgets.QPushButton(self) button_layout.addWidget(self.save_button, 0, 4) self.save_button.setText("Save") self.save_button.setToolTip( "Save the current key bindings to be loaded automatically when opening PyMOL") self.save_button.clicked.connect(self.shortcut_manager.save_shortcuts) # Ensuring that confirmed key and binding remain in scope self.confirm_new_key = '' self.confirm_new_binding = '' # Connect create new and confirm menus self.create_new_shortcut_menu_connect() self.confirm_menu_connect() self.model.itemChanged.connect(self.itemChanged)
def __init__(self, parent=None): super(SurfStampFrame, self).__init__(parent) self.layout = QtWidgets.QVBoxLayout() self.setLayout(self.layout) glayout1 = QtWidgets.QGridLayout() self.label_message = QtWidgets.QLabel(self) self.label_message.setText("SurfStamp PyMOL plugin") self.layout.addWidget(self.label_message) self.combo_model = QtWidgets.QComboBox() self.combo_model.addItems([]) self.layout.addWidget(self.combo_model) self.label_reso = QtWidgets.QLabel(self) self.label_reso.setText("Surface Resolution") glayout1.addWidget(self.label_reso, 1, 0) self.spin_reso = QtWidgets.QDoubleSpinBox(self) self.spin_reso.setRange(0.1, 1.0) self.spin_reso.setSingleStep(0.05) self.spin_reso.setValue(0.7) glayout1.addWidget(self.spin_reso, 1, 1) self.label_imagesize = QtWidgets.QLabel(self) self.label_imagesize.setText("Image Size") glayout1.addWidget(self.label_imagesize, 2, 0) self.spin_imagesize = QtWidgets.QSpinBox(self) self.spin_imagesize.setRange(1000, 10000) #PILLOW?は 13000 くらいが Max っぽい self.spin_imagesize.setSingleStep(100) self.spin_imagesize.setValue(4000) glayout1.addWidget(self.spin_imagesize, 2, 1) self.label_fontsize = QtWidgets.QLabel(self) self.label_fontsize.setText("Font Size") glayout1.addWidget(self.label_fontsize, 3, 0) self.spin_fontsize = QtWidgets.QSpinBox(self) self.spin_fontsize.setRange(3, 100) self.spin_fontsize.setSingleStep(1) self.spin_fontsize.setValue(20) glayout1.addWidget(self.spin_fontsize, 3, 1) glayout2 = QtWidgets.QGridLayout() self.check_outline = QtWidgets.QCheckBox('Outline') self.check_outline.setChecked(True) glayout2.addWidget(self.check_outline, 0, 0) self.check_nowater = QtWidgets.QCheckBox('Remove Waters') self.check_nowater.setChecked(True) glayout2.addWidget(self.check_nowater, 0, 1) self.check_colorall = QtWidgets.QCheckBox('Color All') self.check_colorall.setChecked(False) glayout2.addWidget(self.check_colorall, 1, 0) self.check_tile = QtWidgets.QCheckBox('Repeating Tile') self.check_tile.clicked.connect(self.checkTileOn) self.check_tile.setChecked(False) glayout2.addWidget(self.check_tile, 1, 1) self.check_oneletter = QtWidgets.QCheckBox('One Letter') glayout2.addWidget(self.check_oneletter, 2, 0) self.check_nochainname = QtWidgets.QCheckBox('No Chain Name') glayout2.addWidget(self.check_nochainname, 2, 1) self.check_ignore_occupancy = QtWidgets.QCheckBox('Ignore Occupancy') glayout2.addWidget(self.check_ignore_occupancy, 3, 0) self.check_cartoon = QtWidgets.QCheckBox('Cartoon') self.check_cartoon.clicked.connect(self.checkCartoonOn) glayout2.addWidget(self.check_cartoon, 3, 1) self.check_mmcif = QtWidgets.QCheckBox('Use MMCIF') glayout2.addWidget(self.check_mmcif, 4, 0) self.check_builtin = QtWidgets.QCheckBox('Built-in Surface Generator') glayout2.addWidget(self.check_builtin, 4, 1) self.check_builtin.clicked.connect(self.checkBuiltinOn) #MMCIF は AUTH が不完全だ! #self.check_label = QtWidgets.QCheckBox('ID Label'); #self.layout.addWidget(self.check_label); # Text field for output file glayout4 = QtWidgets.QVBoxLayout() self.label_outprefix = QtWidgets.QLabel( 'Output Prefix (Prefix+<something> will be overwritten.)') glayout4.addWidget(self.label_outprefix) glayout4b = QtWidgets.QGridLayout() self.text_outprefix = QtWidgets.QLineEdit(self) self.text_outprefix.setReadOnly(True) glayout4b.addWidget(self.text_outprefix, 0, 0) self.button_outprefix = QtWidgets.QPushButton(self) self.button_outprefix.setText("Save As") self.button_outprefix.clicked.connect(self.getFile) self.text_outprefix.setStyleSheet("background-color: lightgray;") glayout4b.addWidget(self.button_outprefix, 0, 1) glayout4.addLayout(glayout4b) glayout3 = QtWidgets.QGridLayout() self.button_ok = QtWidgets.QPushButton('Create') self.button_ok.clicked.connect(self.runSurfStamp) glayout3.addWidget(self.button_ok, 0, 0) self.button_close = QtWidgets.QPushButton('Close') self.button_close.clicked.connect(self.hide) glayout3.addWidget(self.button_close, 0, 1) self.layout.addLayout(glayout1) self.layout.addLayout(glayout2) self.layout.addLayout(glayout4) self.layout.addLayout(glayout3) screengeom = QtWidgets.qApp.desktop().screenGeometry() wwidth = 300 hheight = 200 self.setGeometry(screengeom.width() / 2 - wwidth / 2, screengeom.height() / 2 - hheight / 2, wwidth, hheight) self.setWindowTitle('SurfStamp') self.checkTileOn() self.checkBuiltinOn() self.checkCartoonOn() self.show()