def _build_ui(self): fields = self._entity.fields() fields = [ x for x in fields if x.name not in ('id', 'timestamp', 'username') ] lyt_buttons = QHBoxLayout() lyt_buttons.addWidget(self._btn_create) lyt_buttons.addWidget(self._btn_cancel) r = 0 lyt_grid = QGridLayout() for field in fields: editor = QLineEdit() if field.type == int: editor = QSpinBox() editor.setRange(-1000000, 1000000) self._wdg_map[field] = editor lyt_grid.addWidget(QLabel(field.name), r, 0) lyt_grid.addWidget(editor, r, 1) r += 1 lyt_main = QVBoxLayout() lyt_main.addLayout(lyt_grid) lyt_main.addLayout(lyt_buttons) self.setLayout(lyt_main)
def _build_ui(self): layout = QGridLayout() layout.setContentsMargins(0,0,0,0) layout.setSpacing(0) #TODO: make buttons disabled/enabled if items are selected that don't have the info self.tree = QTreeWidget() self.tree.setSelectionMode(QTreeWidget.ExtendedSelection) self.tree.setHeaderLabels(["Name", "ID", "movie", "energy", "frequencies"]) self.tree.setUniformRowHeights(True) self.tree.setColumnWidth(self.NAME_COL, 200) layout.addWidget(self.tree, 0, 0, 3, 1) restore_button = QPushButton("restore") restore_button.clicked.connect(self.restore_selected) layout.addWidget(restore_button, 0, 1) nrg_plot_button = QPushButton("energy plot") nrg_plot_button.clicked.connect(self.open_nrg_plot) layout.addWidget(nrg_plot_button, 1, 1) coordset_slider_button = QPushButton("movie slider") coordset_slider_button.clicked.connect(self.open_movie_slider) layout.addWidget(coordset_slider_button, 2, 1) self.tool_window.ui_area.setLayout(layout) self.tool_window.manage(placement="side")
def __init__(self, parent=None): QWidget.__init__(self, parent) self.setMinimumWidth(500) self.table = QTableWidget() self.table.setSelectionMode(QTableWidget.SingleSelection) self.table.itemChanged.connect(self._item_changed) self.table.currentItemChanged.connect(self._current_item_changed) self.table.horizontalHeader().hide() self.table.verticalHeader().hide() self.table.setColumnCount(3) self.table.horizontalHeader().resizeSection(0, 200) self.table.horizontalHeader().resizeSection(1, 200) self.table.horizontalHeader().resizeSection(2, 20) self.new = QPushButton('New variable') self.new.clicked.connect(self._new) self.color = Color() self.color.changed.connect(self._color_changed) layout = QGridLayout(self) layout.addWidget(self.table) layout.addWidget(self.color) layout.addWidget(self.new)
def __init__(self, settings, *args, **kwargs): super().__init__(*args, **kwargs) layout = QGridLayout(self) #layout.setContentsMargins(0, 0, 0, 0) settings_tabs = QTabWidget() layout.addWidget(settings_tabs) form = 'Gaussian' self.method = MethodOption(settings, form) settings_tabs.addTab(self.method, "Method") self.basis = BasisWidget(settings, form) settings_tabs.addTab(self.basis, "Basis Sets") #menu stuff menu = QMenuBar() self.presets_menu = menu.addMenu("Presets") menu.setNativeMenuBar(False) self._menu = menu layout.setMenuBar(menu) menu.setVisible(True) self.settings = settings self.presets = {} self.presets['Gaussian'] = loads(self.settings.gaussian_presets) self.presets['ORCA'] = loads(self.settings.orca_presets) self.presets['Psi4'] = loads(self.settings.psi4_presets) self.refresh_presets()
def __init__(self, parent=None): QWidget.__init__(self, parent) self.hue = QSlider() self.hue.setMaximum(100) self.hue.setOrientation(Qt.Horizontal) self.hue.valueChanged.connect(self._changed) self.saturation = QSlider() self.saturation.setMaximum(100) self.saturation.setOrientation(Qt.Horizontal) self.saturation.valueChanged.connect(self._changed) self.value = QSlider() self.value.setMaximum(100) self.value.setOrientation(Qt.Horizontal) self.value.valueChanged.connect(self._changed) layout = QGridLayout(self) layout.addWidget(QLabel("H")) layout.addWidget(QLabel("S")) layout.addWidget(QLabel("V")) layout.addWidget(self.hue, 0, 1) layout.addWidget(self.saturation, 1, 1) layout.addWidget(self.value, 2, 1)
def initUI(self): searchEdit = QLineEdit() grid = QGridLayout() grid.setSpacing(10) grid.addWidget(searchEdit, 1, 0) self.list = QListView() # Create an empty model for the list's data model = QStandardItemModel(self.list) for gameName, gameId in self.Games.items(): game = QStandardItem(gameName) game.setEditable(False) model.appendRow(game) self.list.doubleClicked.connect(self.OnDoubleClick) # Launch Game # Apply the model to the list view self.list.setModel(model) self.list.setCurrentIndex(self.list.model().index(0, 0)) # Show the window and run the app grid.addWidget(self.list, 2, 0) self.setLayout(grid) self.setGeometry(300, 300, 350, 300) self.setWindowTitle('pySteamLauncher') self.setWindowIcon(QIcon('logo.png')) self.show()
def __init__(self, parent=None, dataSetCallback=None, defaultValue=None, userStructClass=None, **kwds): super(InputWidgetSingle, self).__init__(parent=parent, dataSetCallback=dataSetCallback, defaultValue=defaultValue, userStructClass=userStructClass, **kwds) # from widget self.bWidgetSet = False self.gridLayout = QGridLayout(self) self.gridLayout.setSpacing(1) self.gridLayout.setContentsMargins(0, 0, 0, 0) self.gridLayout.setObjectName("gridLayout") self.horizontalLayout = QHBoxLayout() self.horizontalLayout.setObjectName("horizontalLayout") spacerItem = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) self.horizontalLayout.addItem(spacerItem) self.pbReset = QPushButton(self) self.pbReset.setMaximumSize(QtCore.QSize(25, 25)) self.pbReset.setText("") self.pbReset.setObjectName("pbReset") self.pbReset.setIcon(QtGui.QIcon(":/icons/resources/reset.png")) self.horizontalLayout.addWidget(self.pbReset) self.pbReset.clicked.connect(self.onResetValue) self.gridLayout.addLayout(self.horizontalLayout, 0, 0, 1, 1) self._index = 0
def __init__(self, name, session, nrg_fr, thermo_co, size, *args, **kwargs): super().__init__(*args, **kwargs) self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self.session = session self.nrg_fr = nrg_fr self.thermo_co = thermo_co layout = QGridLayout(self) layout.setContentsMargins(0, 0, 0, 0) layout.setRowStretch(0, 1) frame = QGroupBox(name) frame.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) frame_layout = QGridLayout(frame) frame_layout.setContentsMargins(0, 0, 0, 0) frame_layout.setRowStretch(0, 1) self.tree = QTreeWidget() self.tree.setColumnCount(3) self.tree.setHeaderLabels(["energy", "frequencies", "remove"]) self.tree.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self.tree.setColumnWidth(0, size[0]) self.tree.setColumnWidth(1, size[1]) self.tree.resizeColumnToContents(2) root_item = self.tree.invisibleRootItem() plus = QTreeWidgetItem(root_item) plus_button = QPushButton("add molecule") plus_button.setFlat(True) plus_button.clicked.connect(self.add_mol_group) plus_button2 = QPushButton("") plus_button2.setFlat(True) plus_button2.clicked.connect(self.add_mol_group) self.tree.setItemWidget(plus, 0, plus_button) self.tree.setItemWidget(plus, 1, plus_button2) self.tree.insertTopLevelItem(1, plus) self.add_mol_group() frame_layout.addWidget(self.tree) layout.addWidget(frame)
def __init__(self, *args, **kwargs): super(FileManagerViewer, self).__init__(*args, **kwargs) self._lyt_grid = QGridLayout() self._toolbar = ViewerToolbar() self._build_ui() self._build_connections() self._setup_ui()
def _build_ui(self): layout = QGridLayout() self.text = QTextBrowser() font = QFontDatabase.systemFont(QFontDatabase.FixedFont) self.text.setFont(font) layout.addWidget(self.text, 0, 0) self.ui_area.setLayout(layout) self.manage(None)
def _build_ui(self): layout = QGridLayout() self.ptable = PeriodicTable(initial_elements=[self.button.text()], select_multiple=False) self.ptable.elementSelectionChanged.connect(self.element_changed) layout.addWidget(self.ptable) self.ui_area.setLayout(layout) self.manage(None)
def _build_ui(self): layout = QGridLayout() self.lig_table = LigandTable(include_substituents=True) self.lig_table.table.itemSelectionChanged.connect(self.refresh_selection) layout.addWidget(self.lig_table) self.ui_area.setLayout(layout) self.manage(None)
def _build_ui(self): layout = QGridLayout() self.ring_table = RingTable() self.ring_table.table.itemSelectionChanged.connect(self.refresh_selection) layout.addWidget(self.ring_table) self.ui_area.setLayout(layout) self.manage(None)
def __init__(self): super().__init__() if separate_colorbars: if rescale_colorbars: self.vmins = tuple(np.min(u[0]) for u in U) self.vmaxs = tuple(np.max(u[0]) for u in U) else: self.vmins = tuple(np.min(u) for u in U) self.vmaxs = tuple(np.max(u) for u in U) else: if rescale_colorbars: self.vmins = (min(np.min(u[0]) for u in U),) * len(U) self.vmaxs = (max(np.max(u[0]) for u in U),) * len(U) else: self.vmins = (min(np.min(u) for u in U),) * len(U) self.vmaxs = (max(np.max(u) for u in U),) * len(U) layout = QHBoxLayout() plot_layout = QGridLayout() self.colorbarwidgets = [cbar_widget(self, vmin=vmin, vmax=vmax) if cbar_widget else None for vmin, vmax in zip(self.vmins, self.vmaxs)] plots = [widget(self, grid, vmin=vmin, vmax=vmax, bounding_box=bounding_box, codim=codim) for vmin, vmax in zip(self.vmins, self.vmaxs)] if legend: for i, plot, colorbar, l in zip(range(len(plots)), plots, self.colorbarwidgets, legend): subplot_layout = QVBoxLayout() caption = QLabel(l) caption.setAlignment(Qt.AlignHCenter) subplot_layout.addWidget(caption) if not separate_colorbars or backend == 'matplotlib': subplot_layout.addWidget(plot) else: hlayout = QHBoxLayout() hlayout.addWidget(plot) if colorbar: hlayout.addWidget(colorbar) subplot_layout.addLayout(hlayout) plot_layout.addLayout(subplot_layout, int(i/columns), (i % columns), 1, 1) else: for i, plot, colorbar in zip(range(len(plots)), plots, self.colorbarwidgets): if not separate_colorbars or backend == 'matplotlib': plot_layout.addWidget(plot, int(i/columns), (i % columns), 1, 1) else: hlayout = QHBoxLayout() hlayout.addWidget(plot) if colorbar: hlayout.addWidget(colorbar) plot_layout.addLayout(hlayout, int(i/columns), (i % columns), 1, 1) layout.addLayout(plot_layout) if not separate_colorbars: layout.addWidget(self.colorbarwidgets[0]) for w in self.colorbarwidgets[1:]: w.setVisible(False) self.setLayout(layout) self.plots = plots
def __init__(self, parent=None, singleSelect=False): super().__init__(parent) layout = QGridLayout(self) self.table = QTableWidget() self.table.setColumnCount(3) self.table.setHorizontalHeaderLabels( ['name', 'conformers', 'conf. angle']) self.add_subs() for i in range(0, 3): self.table.resizeColumnToContents(i) self.table.horizontalHeader().setStretchLastSection(False) self.table.horizontalHeader().setSectionResizeMode( 0, QHeaderView.Fixed) self.table.horizontalHeader().setSectionResizeMode( 1, QHeaderView.Fixed) self.table.horizontalHeader().setSectionResizeMode( 2, QHeaderView.Stretch) self.table.setSortingEnabled(True) self.table.setSelectionBehavior(QTableWidget.SelectRows) if singleSelect: self.table.setSelectionMode(QTableWidget.SingleSelection) self.table.setEditTriggers(QTableWidget.NoEditTriggers) self.filterEdit = QLineEdit() self.filterEdit.textChanged.connect(self.apply_filter) self.filterEdit.setClearButtonEnabled(True) self.filter_columns = QComboBox() self.filter_columns.addItem("name") self.filter_columns.addItem("conformers") self.filter_columns.addItem("conf. angle") self.filter_columns.currentTextChanged.connect( self.change_filter_method) self.name_regex_option = QComboBox() self.name_regex_option.addItem("case-insensitive") self.name_regex_option.addItem("case-sensitive") self.name_regex_option.currentTextChanged.connect(self.apply_filter) self.name_regex_option.setVisible( self.filter_columns.currentText() == "name") layout.addWidget(self.table, 0, 0, 1, 4) layout.addWidget(QLabel("filter based on"), 1, 0) layout.addWidget(self.filter_columns, 1, 1) layout.addWidget(self.name_regex_option, 1, 2) layout.addWidget(self.filterEdit, 1, 3) self.change_filter_method("name")
def __init__(self, settings, parent=None, description=None, pstvOnly=True): super(ConfigDialog, self).__init__(parent) self.setWindowTitle("Configure source") self.layout = QGridLayout(self) row = 0 self.widgets = {} self.settings = settings # Settings should be a dictionary for name, val in settings.items(): label = QLabel(self) label.setText(str(name)) self.layout.addWidget(label, row, 0, 1, 1) # Check the type of each setting, and create widgets accordingly if isinstance(val, str): # A string of some kind widget = QLineEdit(self) widget.setText(val) elif isinstance(val, list): # A list of alternative values, first is selected print("List: ", name) continue elif isinstance(val, bool): widget = QCheckBox(self) if val: widget.setCheckState(Qt.CheckState.Checked) else: widget.setCheckState(Qt.CheckState.Unchecked) elif isinstance(val, int): widget = QLineEdit(self) widget.setInputMask("9000000") widget.setText(str(val).strip()) elif isinstance(val, float): widget = QLineEdit(self) if pstvOnly: widget.setInputMask("0.000") widget.setText(str(val).strip()) else: print("Ignoring: " + name) continue widget.config = name self.widgets[name] = widget self.layout.addWidget(widget, row, 1, 1, 1) row += 1 # Add OK and Cancel buttons buttonbox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) buttonbox.accepted.connect(self.getValues) buttonbox.rejected.connect(self.reject) self.layout.addWidget(buttonbox, row, 1, 2, 1)
def __init__(self, auto_resize=False, single_row_select=True, context_menu_callback=None, last_column_stretch=True, has_counters=False, parent=None ): QFrame.__init__(self, parent) self._has_counters = has_counters self.model = None self.table_view = RowTableView(auto_resize, single_row_select, context_menu_callback, last_column_stretch) self.table_view.doubleClicked.connect(self._double_clicked) if has_counters: self.counters = Counters() self.counters.button_clicked.connect(self._counter_clicked) self.search_bar = QLineEdit() self.search_bar.setFixedHeight(SEARCHBAR_HEIGHT) self.search_bar.textChanged.connect(self.set_search_text) self.search_bar.setToolTip("Search bar") self.auto_size_button = QPushButton('<>') self.auto_size_button.setFixedSize(SEARCHBAR_HEIGHT, SEARCHBAR_HEIGHT) self.auto_size_button.clicked.connect(self._auto_size_clicked) self.auto_size_button.setToolTip("Auto size") self.status_label = QLabel(STATUS_LABEL_MESSAGE.format(0, 0)) self.status_label.setFixedWidth(STATUS_LABEL_WIDTH) self.progress_bar = QProgressBar() self.progress_bar.setFormat('') layout = QGridLayout() layout.addWidget(self.search_bar, 0, 0, 1, 3) layout.addWidget(self.auto_size_button, 0, 3) if has_counters: layout.addWidget(self.counters, 1, 0, 1, 2) layout.addWidget(self.table_view, 1, 2, 1, 2) else: layout.addWidget(self.table_view, 1, 0, 1, 4) layout.addWidget(self.status_label, 2, 0) layout.addWidget(self.progress_bar, 2, 1, 1, 3) layout.setColumnStretch(2, 100) self.setLayout(layout)
def __init__(self, project_name): self.project_name = project_name self._app = QApplication.instance() self._css_filepath = None self.main_window = QWidget() self.main_window.setWindowFlags(Qt.Tool) self.main_window.setWindowTitle("CSS Editor - " + self.project_name) self.variables = Variables() self.variables.changed.connect(self._variables_changed) self.variables.changed.connect(self._render_and_apply) self.template = CSSTextEdit() self.template.changed.connect(self._template_changed) self.template.changed.connect(self._render_and_apply) self.save = QPushButton('Save stylesheet to') self.save.clicked.connect(self._save_stylesheet) self.save_destination = QLineEdit() self.save_destination.textChanged.connect(self._destination_changed) self.splitter = QSplitter() self.splitter.setOrientation(Qt.Vertical) self.splitter.addWidget(self.variables) self.splitter.addWidget(self.template) layout = QGridLayout(self.main_window) layout.addWidget(self.splitter, 0, 0, 1, 2) layout.addWidget(self.save, 1, 0) layout.addWidget(self.save_destination, 1, 1) self.main_window.resize(800, 600) self._project_dir = self._ensure_project_dir() self._top_level_widgets = [ widget for widget in QApplication.topLevelWidgets() if widget.windowTitle() != self.main_window.windowTitle() ] self._variables = dict() self._template = None self._stylesheet = "" self._app.aboutToQuit.connect(self._save_editor_state) self._open() self.save_destination.setText(self.css_filepath) self.main_window.show()
def __init__(self, parent: QWidget = None): super().__init__(parent) self._in = QDataStream() self.blockSize = 0 self.currentFortune = "" self.hostLineEdit = QLineEdit("fortune") self.getFortuneButton = QPushButton(self.tr("Get Fortune")) self.statusLabel = QLabel( self.tr( "This examples requires that you run the Local Fortune Server example as well." ) ) self.socket = QLocalSocket() self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) hostLabel = QLabel(self.tr("&Server name:")) hostLabel.setBuddy(self.hostLineEdit) self.statusLabel.setWordWrap(True) self.getFortuneButton.setDefault(True) quitButton = QPushButton(self.tr("Quit")) buttonBox = QDialogButtonBox() buttonBox.addButton(self.getFortuneButton, QDialogButtonBox.ActionRole) buttonBox.addButton(quitButton, QDialogButtonBox.RejectRole) self._in.setDevice(self.socket) self._in.setVersion(QDataStream.Qt_5_10) self.hostLineEdit.textChanged.connect(self.enableGetFortuneButton) self.getFortuneButton.clicked.connect(self.requestNewFortune) quitButton.clicked.connect(self.close) self.socket.readyRead.connect(self.readFortune) self.socket.errorOccurred.connect(self.displayError) mainLayout = QGridLayout(self) mainLayout.addWidget(hostLabel, 0, 0) mainLayout.addWidget(self.hostLineEdit, 0, 1) mainLayout.addWidget(self.statusLabel, 2, 0, 1, 2) mainLayout.addWidget(buttonBox, 3, 0, 1, 2) self.setWindowTitle(QGuiApplication.applicationDisplayName()) self.hostLineEdit.setFocus()
def initPenColorButtons(self): self.colorSet = QWidget(self) self.colorLayout = QHBoxLayout() self.colorLayout.setSpacing(5) self.colorLayout.setContentsMargins(5, 0, 5, 0) self.colorSet.setLayout(self.colorLayout) self.presentColor = QPushButton(self.colorSet) self.presentColor.setFixedSize(self.iconWidth, self.iconHeight) self.presentColor.setEnabled(False) # adjust pen color self.colorPick = QWidget(self.colorSet) self.colorGrid = QGridLayout() self.colorGrid.setSpacing(0) self.colorGrid.setContentsMargins(5, 0, 5, 0) self.colorPick.setLayout(self.colorGrid) self.colorList = [('white', '#ffffff'), ('red', '#ff0000'), ('green', '#00ff00'), ('blue', '#0000ff'), ('cyan', '#00ffff'), ('magenta', '#ff00ff'), ('yellow', '#ffff00'), ('gray', '#a0a0a4'), ('black', '#000000'), ('darkRed', '#800000'), ('darkGreen', '#008000'), ('darkBlue', '#000080'), ('darkCyan', '#008080'), ('darkMagenta', '#800080'), ('darkYellow', '#808000'), ('darkGray', '#808080')] self.generateButtons() self.colorButtonGroup = QButtonGroup(self) for button in self.colorButtons: self.colorButtonGroup.addButton(button) self.colorButtonGroup.buttonClicked.connect(self.colorButtonToggled) # set the layout tmp = 0 for x in range(0, 2): for y in range(0, int(len(self.colorList) / 2)): self.colorGrid.addWidget(self.colorButtons[tmp], x, y) tmp += 1 self.colorGrid.setSpacing(0) self.colorGrid.setContentsMargins(0, 0, 0, 0) self.colorLayout.addWidget(self.presentColor) self.colorLayout.addWidget(self.colorPick)
def __init__(self, name, report, parent=None): QDialog.__init__(self, parent) icon = self.style().standardIcon(QStyle.SP_MessageBoxCritical) self.setWindowTitle('Error reporting') self.setWindowIcon(icon) try: font = QFontDatabase().systemFont(QFontDatabase.FixedFont) except AttributeError as e: font = QFont() font.setStyleHint(QFont.TypeWriter) self.text = QPlainTextEdit() self.text.setFont(font) self.text.setReadOnly(True) self.text.setLineWrapMode(QPlainTextEdit.NoWrap) self.text.setPlainText(report) TracebackHighlighter(self.text.document()) icon_label = QLabel() icon_label.setPixmap(icon.pixmap(ICON_SIZE, ICON_SIZE)) label = QLabel("{} error !".format(name)) label.setFont(QFont('default', pointSize=14)) button_copy = QPushButton('Copy to clipboard') button_copy.clicked.connect(self._copy) layout = QGridLayout(self) layout.addWidget(icon_label, 0, 0) layout.addWidget(label, 0, 1) layout.addWidget(self.text, 1, 0, 1, 2) layout.addWidget(button_copy, 2, 0, 1, 2) layout.setColumnStretch(1, 100) self.setModal(True) self.resize(600, 400)
def _build_ui(self): layout = QGridLayout() library_tabs = QTabWidget() #ligand tab ligand_tab = QWidget() ligand_layout = QFormLayout(ligand_tab) self.ligand_name = QLineEdit() self.ligand_name.setText("") self.ligand_name.setPlaceholderText("leave blank to preview") self.ligand_name.setToolTip( "name of ligand you are adding to your ligand library\nleave blank to open a new model with just the ligand" ) ligand_layout.addRow("ligand name:", self.ligand_name) ligand_key_atoms = QPushButton("set key atoms to current selection") ligand_key_atoms.clicked.connect(self.update_key_atoms) ligand_key_atoms.setToolTip( "the current selection will be the key atoms for the ligand\nleave blank to automatically determine key atoms" ) ligand_layout.addRow(ligand_key_atoms) libadd_ligand = QPushButton("add current selection to library") libadd_ligand.clicked.connect(self.libadd_ligand) ligand_layout.addRow(libadd_ligand) #substituent tab sub_tab = QWidget() sub_layout = QFormLayout(sub_tab) self.sub_name = QLineEdit() self.sub_name.setText("") self.sub_name.setPlaceholderText("leave blank to preview") self.sub_name.setToolTip( "name of substituent you are adding to your substituent library\nleave blank to open a new model with just the substituent" ) sub_layout.addRow("substituent name:", self.sub_name) self.sub_confs = QSpinBox() self.sub_confs.setMinimum(1) sub_layout.addRow("number of conformers:", self.sub_confs) self.sub_angle = QSpinBox() self.sub_angle.setRange(0, 180) self.sub_angle.setSingleStep(30) sub_layout.addRow("angle between conformers:", self.sub_angle) libadd_sub = QPushButton("add current selection to library") libadd_sub.clicked.connect(self.libadd_substituent) sub_layout.addRow(libadd_sub) #ring tab ring_tab = QWidget() ring_layout = QFormLayout(ring_tab) self.ring_name = QLineEdit() self.ring_name.setText("") self.ring_name.setPlaceholderText("leave blank to preview") self.ring_name.setToolTip( "name of ring you are adding to your ring library\nleave blank to open a new model with just the ring" ) ring_layout.addRow("ring name:", self.ring_name) libadd_ring = QPushButton("add ring with selected walk to library") libadd_ring.clicked.connect(self.libadd_ring) ring_layout.addRow(libadd_ring) library_tabs.addTab(sub_tab, "substituent") library_tabs.addTab(ring_tab, "ring") library_tabs.addTab(ligand_tab, "ligand") self.library_tabs = library_tabs layout.addWidget(library_tabs) whats_this = QLabel() whats_this.setText( "<a href=\"req\" style=\"text-decoration: none;\">what's this?</a>" ) whats_this.setTextFormat(Qt.RichText) whats_this.setTextInteractionFlags(Qt.TextBrowserInteraction) whats_this.linkActivated.connect(self.open_link) whats_this.setToolTip( "click for more information about AaronTools libraries") layout.addWidget(whats_this) self.tool_window.ui_area.setLayout(layout) self.tool_window.manage(None)
def _build_ui(self): layout = QGridLayout() tab_widget = QTabWidget() layout.addWidget(tab_widget) structure_widget = QWidget() structure_layout = QGridLayout(structure_widget) tab_widget.addTab(structure_widget, "structure") self.structure_source = QComboBox() self.structure_source.addItems( ["AARON template", "file", "coordination complexes", "SMILES"]) structure_layout.addWidget(QLabel("structure source:"), 0, 0, 1, 1, Qt.AlignLeft | Qt.AlignVCenter) structure_layout.addWidget( self.structure_source, 0, 1, 1, 1, ) open_button = QPushButton("open") open_button.clicked.connect(self.open_template) structure_layout.addWidget( open_button, 0, 2, 1, 1, ) # SMILES options self.smiles_options = QGroupBox("SMILES options") smiles_layout = QFormLayout(self.smiles_options) structure_layout.addWidget(self.smiles_options, 1, 0, 1, 3, Qt.AlignTop | Qt.AlignHCenter) self.smiles_line = QLineEdit() smiles_layout.addRow("SMILES string:", self.smiles_line) self.smiles_options.setVisible( self.structure_source.currentText() == "SMILES") self.structure_source.currentTextChanged.connect( lambda text: self.smiles_options.setVisible(text == "SMILES")) # coordination complexes options self.coord_comp_options = QGroupBox("Coordination Complex Options") coord_layout = QFormLayout(self.coord_comp_options) structure_layout.addWidget(self.coord_comp_options, 1, 0, 1, 3, Qt.AlignTop | Qt.AlignHCenter) create_coord_items(self, coord_layout, allow_minimization=False, default_ele="Pd") self.coord_comp_options.setVisible( self.structure_source.currentText() == "coordination complexes") self.structure_source.currentTextChanged.connect( lambda text: self.coord_comp_options.setVisible( text == "coordination complexes")) # aaron template options self.aaron_options = QGroupBox("AARON template structures") aaron_layout = QFormLayout(self.aaron_options) structure_layout.addWidget(self.aaron_options, 1, 0, 1, 3, Qt.AlignTop | Qt.AlignHCenter) self.aaron_options.setVisible( self.structure_source.currentText() == "AARON template") self.structure_source.currentTextChanged.connect( lambda text: self.aaron_options.setVisible(text == "AARON template" )) # file options self.file_options = QGroupBox("single file options") file_layout = QFormLayout(self.file_options) structure_layout.addWidget(self.file_options, 1, 0, 1, 3, Qt.AlignTop | Qt.AlignHCenter) file_widget = QWidget() file_browse_layout = QGridLayout(file_widget) self.template_file = QLineEdit() file_browse_layout.addWidget(self.template_file, 0, 0, 1, 1, Qt.AlignCenter) browse_button = QPushButton("browse...") # browse_button.clicked.connect(self.browse_file_template) file_browse_layout.addWidget(browse_button, 0, 1, 1, 1, Qt.AlignCenter) file_browse_layout.setColumnStretch(0, 1) file_browse_layout.setColumnStretch(1, 0) margins = file_browse_layout.contentsMargins() file_browse_layout.setContentsMargins(margins.left(), 0, margins.right(), 0) file_layout.addRow("file:", file_widget) self.file_options.setVisible( self.structure_source.currentText() == "file") self.structure_source.currentTextChanged.connect( lambda text: self.file_options.setVisible(text == "file")) self.optimize_template = QCheckBox() self.optimize_template.setCheckState(Qt.Checked) structure_layout.addWidget( QLabel("optimize template:"), 2, 0, 1, 1, Qt.AlignLeft | Qt.AlignVCenter, ) structure_layout.addWidget( self.optimize_template, 2, 1, 1, 2, Qt.AlignLeft | Qt.AlignVCenter, ) structure_layout.setColumnStretch(0, 0) structure_layout.setColumnStretch(1, 1) structure_layout.setColumnStretch(2, 0) # structure changes changes_widget = QWidget() changes_layout = QGridLayout(changes_widget) tab_widget.addTab(changes_widget, "changes") # HPC settings hpc_widget = QWidget() hpc_layout = QGridLayout(hpc_widget) tab_widget.addTab(hpc_widget, "HPC") # theory settings theory_widget = QWidget() theory_layout = QGridLayout(theory_widget) tab_widget.addTab(theory_widget, "theory") # results results_widget = QWidget() results_layout = QGridLayout(results_widget) tab_widget.addTab(results_widget, "results") self.tool_window.ui_area.setLayout(layout) self.tool_window.manage(None)
def _build_ui(self): layout = QGridLayout() tabs = QTabWidget() layout.addWidget(tabs) ts_bond_tab = QWidget() ts_options = QFormLayout(ts_bond_tab) self.tsbond_color = ColorButton(has_alpha_channel=False, max_size=(16, 16)) self.tsbond_color.set_color(self.settings.tsbond_color) ts_options.addRow("color:", self.tsbond_color) self.tsbond_transparency = QSpinBox() self.tsbond_transparency.setRange(1, 99) self.tsbond_transparency.setValue(self.settings.tsbond_transparency) self.tsbond_transparency.setSuffix("%") ts_options.addRow("transparency:", self.tsbond_transparency) self.tsbond_radius = QDoubleSpinBox() self.tsbond_radius.setRange(0.01, 1) self.tsbond_radius.setDecimals(3) self.tsbond_radius.setSingleStep(0.005) self.tsbond_radius.setSuffix(" \u212B") self.tsbond_radius.setValue(self.settings.tsbond_radius) ts_options.addRow("radius:", self.tsbond_radius) draw_tsbonds = QPushButton("draw TS bonds on selected atoms/bonds") draw_tsbonds.clicked.connect(self.run_tsbond) ts_options.addRow(draw_tsbonds) self.draw_tsbonds = draw_tsbonds erase_tsbonds = QPushButton("erase selected TS bonds") erase_tsbonds.clicked.connect(self.run_erase_tsbond) ts_options.addRow(erase_tsbonds) self.erase_tsbonds = erase_tsbonds bond_tab = QWidget() bond_options = QFormLayout(bond_tab) self.bond_halfbond = QCheckBox() self.bond_halfbond.setChecked(self.settings.bond_halfbond) self.bond_halfbond.setToolTip( "each half of the bond will be colored according to the atom's color" ) bond_options.addRow("half-bond:", self.bond_halfbond) self.bond_color = ColorButton(has_alpha_channel=True, max_size=(16, 16)) self.bond_color.set_color(self.settings.bond_color) self.bond_color.setEnabled( self.bond_halfbond.checkState() != Qt.Checked) self.bond_halfbond.stateChanged.connect( lambda state, widget=self.bond_color: self.bond_color.setEnabled( state != Qt.Checked)) bond_options.addRow("color:", self.bond_color) self.bond_radius = QDoubleSpinBox() self.bond_radius.setRange(0.01, 1) self.bond_radius.setDecimals(3) self.bond_radius.setSingleStep(0.005) self.bond_radius.setSuffix(" \u212B") self.bond_radius.setValue(self.settings.bond_radius) bond_options.addRow("radius:", self.bond_radius) draw_tsbonds = QPushButton("draw bond between selected atoms") draw_tsbonds.clicked.connect(self.run_bond) bond_options.addRow(draw_tsbonds) self.draw_tsbonds = draw_tsbonds erase_bonds = QPushButton("erase selected bonds") erase_bonds.clicked.connect( lambda *, ses=self.session: run(ses, "delete bonds sel")) bond_options.addRow(erase_bonds) self.erase_bonds = erase_bonds hbond_tab = QWidget() hbond_options = QFormLayout(hbond_tab) self.hbond_color = ColorButton(has_alpha_channel=True, max_size=(16, 16)) self.hbond_color.set_color(self.settings.hbond_color) hbond_options.addRow("color:", self.hbond_color) self.hbond_radius = QDoubleSpinBox() self.hbond_radius.setDecimals(3) self.hbond_radius.setSuffix(" \u212B") self.hbond_radius.setValue(self.settings.hbond_radius) hbond_options.addRow("radius:", self.hbond_radius) self.hbond_dashes = QSpinBox() self.hbond_dashes.setRange(0, 28) self.hbond_dashes.setSingleStep(2) self.hbond_radius.setSingleStep(0.005) self.hbond_dashes.setValue(self.settings.hbond_dashes) hbond_options.addRow("dashes:", self.hbond_dashes) draw_hbonds = QPushButton("draw H-bonds") draw_hbonds.clicked.connect(self.run_hbond) hbond_options.addRow(draw_hbonds) self.draw_hbonds = draw_hbonds erase_hbonds = QPushButton("erase all H-bonds") erase_hbonds.clicked.connect( lambda *, ses=self.session: run(ses, "~hbonds")) hbond_options.addRow(erase_hbonds) self.erase_hbonds = erase_hbonds tm_bond_tab = QWidget() tm_bond_options = QFormLayout(tm_bond_tab) self.tm_bond_color = ColorButton(has_alpha_channel=True, max_size=(16, 16)) self.tm_bond_color.set_color(self.settings.tm_bond_color) tm_bond_options.addRow("color:", self.tm_bond_color) self.tm_bond_radius = QDoubleSpinBox() self.tm_bond_radius.setDecimals(3) self.tm_bond_radius.setSuffix(" \u212B") self.tm_bond_radius.setValue(self.settings.tm_bond_radius) tm_bond_options.addRow("radius:", self.tm_bond_radius) self.tm_bond_dashes = QSpinBox() self.tm_bond_dashes.setRange(0, 28) self.tm_bond_dashes.setSingleStep(2) self.tm_bond_radius.setSingleStep(0.005) self.tm_bond_dashes.setValue(self.settings.tm_bond_dashes) tm_bond_options.addRow("dashes:", self.tm_bond_dashes) draw_tm_bonds = QPushButton("draw metal coordination bonds") draw_tm_bonds.clicked.connect(self.run_tm_bond) tm_bond_options.addRow(draw_tm_bonds) self.draw_tm_bonds = draw_tm_bonds erase_tm_bonds = QPushButton("erase all metal coordination bonds") erase_tm_bonds.clicked.connect(self.del_tm_bond) tm_bond_options.addRow(erase_tm_bonds) self.erase_tm_bonds = erase_tm_bonds bond_length_tab = QWidget() bond_length_layout = QFormLayout(bond_length_tab) self.bond_distance = QDoubleSpinBox() self.bond_distance.setRange(0.5, 10.0) self.bond_distance.setSingleStep(0.05) self.bond_distance.setValue(1.51) self.bond_distance.setSuffix(" \u212B") bond_length_layout.addRow("bond length:", self.bond_distance) self.move_fragment = QComboBox() self.move_fragment.addItems(["both", "smaller", "larger"]) bond_length_layout.addRow("move side:", self.move_fragment) bond_lookup = QGroupBox("bond length lookup:") bond_lookup_layout = QGridLayout(bond_lookup) bond_lookup_layout.addWidget( QLabel("elements:"), 0, 0, ) self.ele1 = ElementButton("C", single_state=True) self.ele1.clicked.connect( lambda *args, button=self.ele1: self.open_ptable(button)) bond_lookup_layout.addWidget(self.ele1, 0, 1, Qt.AlignRight | Qt.AlignTop) bond_lookup_layout.addWidget(QLabel("-"), 0, 2, Qt.AlignHCenter | Qt.AlignVCenter) self.ele2 = ElementButton("C", single_state=True) self.ele2.clicked.connect( lambda *args, button=self.ele2: self.open_ptable(button)) bond_lookup_layout.addWidget(self.ele2, 0, 3, Qt.AlignLeft | Qt.AlignTop) bond_lookup_layout.addWidget(QLabel("bond order:"), 1, 0) self.bond_order = BondOrderSpinBox() self.bond_order.setRange(1., 3.) self.bond_order.setValue(1) self.bond_order.setSingleStep(0.5) self.bond_order.setDecimals(1) self.bond_order.valueChanged.connect(self.check_bond_lengths) bond_lookup_layout.addWidget(self.bond_order, 1, 1, 1, 3) bond_lookup_layout.setColumnStretch(0, 0) bond_lookup_layout.setColumnStretch(1, 0) bond_lookup_layout.setColumnStretch(2, 0) bond_lookup_layout.setColumnStretch(3, 1) bond_length_layout.addRow(bond_lookup) self.status = QStatusBar() self.status.setSizeGripEnabled(False) bond_lookup_layout.addWidget(self.status, 2, 0, 1, 4) self.do_bond_change = QPushButton("change selected bond lengths") self.do_bond_change.clicked.connect(self.change_bond_length) bond_length_layout.addRow(self.do_bond_change) tabs.addTab(bond_tab, "covalent bonds") tabs.addTab(ts_bond_tab, "TS bonds") tabs.addTab(hbond_tab, "H-bonds") tabs.addTab(tm_bond_tab, "coordination bonds") tabs.addTab(bond_length_tab, "bond length") self.tool_window.ui_area.setLayout(layout) self.tool_window.manage(None)
def fill_tree(self, trigger_name=None, trigger_job=None): item_stack = [self.tree.invisibleRootItem()] self.tree.clear() jobs = self.session.seqcrow_job_manager.jobs for job in jobs: name = job.name parent = item_stack[0] item = QTreeWidgetItem(parent) item_stack.append(item) item.setData(self.NAME_COL, Qt.DisplayRole, job) item.setText(self.NAME_COL, name) if isinstance(job, LocalJob): if job.killed: item.setText(self.STATUS_COL, "killed") del_job_widget = QWidget() del_job_layout = QGridLayout(del_job_widget) del_job = QPushButton() del_job.clicked.connect( lambda *args, job=job: self.remove_job(job)) del_job.setIcon( QIcon(del_job_widget.style().standardIcon( QStyle.SP_DialogDiscardButton))) del_job.setFlat(True) del_job_layout.addWidget(del_job, 0, 0, 1, 1, Qt.AlignHCenter) del_job_layout.setColumnStretch(0, 1) del_job_layout.setContentsMargins(0, 0, 0, 0) self.tree.setItemWidget(item, self.DEL_COL, del_job_widget) elif job.isRunning(): if job in self.session.seqcrow_job_manager.unknown_status_jobs: unk_widget = QWidget() unk_layout = QGridLayout(unk_widget) unk = QPushButton() unk.setIcon( QIcon(unk_widget.style().standardIcon( QStyle.SP_MessageBoxQuestion))) unk.setFlat(True) unk.clicked.connect(lambda *args, job=job: self. show_ask_if_running(job)) unk_layout.addWidget(unk, 0, 0, 1, 1, Qt.AlignHCenter) unk_layout.setColumnStretch(0, 1) unk_layout.setContentsMargins(0, 0, 0, 0) self.tree.setItemWidget(item, self.STATUS_COL, unk_widget) else: item.setText(self.STATUS_COL, "running") kill_widget = QWidget() kill_layout = QGridLayout(kill_widget) kill = QPushButton() kill.setIcon( QIcon(kill_widget.style().standardIcon( QStyle.SP_DialogCancelButton))) kill.setFlat(True) kill.clicked.connect(lambda *args, job=job: job.kill()) kill.clicked.connect( lambda *args, session=self.session: session. seqcrow_job_manager.triggers.activate_trigger( JOB_QUEUED, "resume")) kill_layout.addWidget(kill, 0, 0, 1, 1, Qt.AlignLeft) kill_layout.setColumnStretch(0, 0) kill_layout.setContentsMargins(0, 0, 0, 0) self.tree.setItemWidget(item, self.KILL_COL, kill_widget) elif job.isFinished(): if not job.error: item.setText(self.STATUS_COL, "finished") else: error_widget = QWidget() error_layout = QGridLayout(error_widget) error = QPushButton() error.setIcon( QIcon(error_widget.style().standardIcon( QStyle.SP_MessageBoxWarning))) error.setFlat(True) error.setToolTip( "job did not finish without errors or output file cannot be found" ) error_layout.addWidget(error, 0, 0, 1, 1, Qt.AlignHCenter) error_layout.setColumnStretch(0, 1) error_layout.setContentsMargins(0, 0, 0, 0) self.tree.setItemWidget(item, self.STATUS_COL, error_widget) del_job_widget = QWidget() del_job_layout = QGridLayout(del_job_widget) del_job = QPushButton() del_job.clicked.connect( lambda *args, job=job: self.remove_job(job)) del_job.setIcon( QIcon(del_job_widget.style().standardIcon( QStyle.SP_DialogDiscardButton))) del_job.setFlat(True) del_job_layout.addWidget(del_job, 0, 0, 1, 1, Qt.AlignHCenter) del_job_layout.setColumnStretch(0, 1) del_job_layout.setContentsMargins(0, 0, 0, 0) self.tree.setItemWidget(item, self.DEL_COL, del_job_widget) else: item.setText(self.STATUS_COL, "queued") priority_widget = QWidget() priority_layout = QGridLayout(priority_widget) inc_priority = QPushButton() inc_priority.setIcon( QIcon(priority_widget.style().standardIcon( QStyle.SP_ArrowUp))) inc_priority.setFlat(True) inc_priority.clicked.connect( lambda *args, job=job: self.session.seqcrow_job_manager .increase_priotity(job)) priority_layout.addWidget(inc_priority, 0, 0, 1, 1, Qt.AlignRight) dec_priority = QPushButton() dec_priority.setIcon( QIcon(priority_widget.style().standardIcon( QStyle.SP_ArrowDown))) dec_priority.setFlat(True) dec_priority.clicked.connect( lambda *args, job=job: self.session.seqcrow_job_manager .decrease_priotity(job)) priority_layout.addWidget(dec_priority, 0, 1, 1, 1, Qt.AlignLeft) priority_layout.setColumnStretch(0, 1) priority_layout.setColumnStretch(1, 1) priority_layout.setContentsMargins(0, 0, 0, 0) self.tree.setItemWidget(item, self.CHANGE_PRIORITY, priority_widget) kill_widget = QWidget() kill_layout = QGridLayout(kill_widget) kill = QPushButton() kill.setIcon( QIcon(kill_widget.style().standardIcon( QStyle.SP_DialogCancelButton))) kill.setFlat(True) kill.clicked.connect(lambda *args, job=job: job.kill()) kill.clicked.connect( lambda *args, session=self.session: session. seqcrow_job_manager.triggers.activate_trigger( JOB_QUEUED, "resume")) kill_layout.addWidget(kill, 0, 0, 1, 1, Qt.AlignLeft) kill_layout.setColumnStretch(0, 0) kill_layout.setContentsMargins(0, 0, 0, 0) self.tree.setItemWidget(item, self.KILL_COL, kill_widget) item.setText(self.SERVER_COL, "local") if job.scratch_dir and os.path.exists(job.scratch_dir): browse_widget = QWidget() browse_layout = QGridLayout(browse_widget) browse = QPushButton() browse.clicked.connect( lambda *args, job=job: self.browse_local(job)) browse.setIcon( QIcon(browse_widget.style().standardIcon( QStyle.SP_DirOpenIcon))) browse.setFlat(True) browse_layout.addWidget(browse, 0, 0, 1, 1, Qt.AlignLeft) browse_layout.setColumnStretch(0, 1) browse_layout.setContentsMargins(0, 0, 0, 0) self.tree.setItemWidget(item, self.BROWSE_COL, browse_widget) self.tree.expandItem(item) self.tree.resizeColumnToContents(self.STATUS_COL) self.tree.resizeColumnToContents(self.SERVER_COL) self.tree.resizeColumnToContents(self.CHANGE_PRIORITY) self.tree.resizeColumnToContents(self.KILL_COL) self.tree.resizeColumnToContents(self.DEL_COL) self.tree.resizeColumnToContents(self.BROWSE_COL)
def _build_ui(self): layout = QGridLayout() layout.setContentsMargins(0, 0, 0, 0) layout.setSpacing(0) self.tree = QTreeWidget() self.tree.setSelectionMode(QTreeWidget.ExtendedSelection) self.tree.setHeaderLabels([ "name", "status", "server", "prioritize", "kill", "delete", "browse" ]) self.tree.setUniformRowHeights(True) self.tree.setColumnWidth(0, 150) layout.addWidget(self.tree, 0, 0, 6, 1, Qt.AlignTop) row = 0 pause_button = QPushButton( "pause new jobs" if not self.session.seqcrow_job_manager.paused else "resume jobs") pause_button.setCheckable(True) pause_button.clicked.connect(lambda check: pause_button.setText( "pause new jobs" if not check else "resume jobs")) pause_button.setChecked(self.session.seqcrow_job_manager.paused) pause_button.clicked.connect(self.pause_queue) layout.addWidget(pause_button, row, 1, 1, 1, Qt.AlignTop) row += 1 open_button = QPushButton("open structure") open_button.clicked.connect(self.open_jobs) layout.addWidget(open_button, row, 1, 1, 1, Qt.AlignTop) row += 1 log_button = QPushButton("log") log_button.clicked.connect(self.open_log) layout.addWidget(log_button, row, 1, 1, 1, Qt.AlignTop) row += 1 output_button = QPushButton("raw output") output_button.clicked.connect(self.open_output) layout.addWidget(output_button, row, 1, 1, 1, Qt.AlignTop) row += 1 refresh_button = QToolButton() refresh_button.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.MinimumExpanding) refresh_button.setToolButtonStyle(Qt.ToolButtonTextBesideIcon) refresh_button.setIcon( QIcon(refresh_button.style().standardIcon( QStyle.SP_BrowserReload))) refresh_button.setText('check jobs') refresh_button.clicked.connect( lambda *args: self.session.seqcrow_job_manager.triggers. activate_trigger(JOB_QUEUED, "refresh")) layout.addWidget(refresh_button, row, 1, 1, 1, Qt.AlignTop) row += 1 for i in range(0, row - 1): layout.setRowStretch(i, 0) layout.setRowStretch(row - 1, 1) layout.setColumnStretch(0, 1) layout.setColumnStretch(1, 0) self.tool_window.ui_area.setLayout(layout) self.tool_window.manage(None)
def _build_ui(self): #each group has an empty widget at the bottom so they resize the way I want while also having the #labels where I want them layout = QGridLayout() self.tab_widget = QTabWidget() layout.addWidget(self.tab_widget) #layout for absolute thermo stuff absolute_widget = QWidget() absolute_layout = QGridLayout(absolute_widget) #box for sp sp_area_widget = QGroupBox("Single-point") sp_layout = QFormLayout(sp_area_widget) self.sp_selector = FilereaderComboBox(self.session, otherItems=['energy']) self.sp_selector.currentIndexChanged.connect(self.set_sp) sp_layout.addRow(self.sp_selector) self.sp_table = QTableWidget() self.sp_table.setColumnCount(3) self.sp_table.setShowGrid(False) self.sp_table.horizontalHeader().hide() self.sp_table.verticalHeader().hide() self.sp_table.setFrameShape(QTableWidget.NoFrame) self.sp_table.setSelectionMode(QTableWidget.NoSelection) self.sp_table.insertRow(0) sp_layout.addRow(self.sp_table) #box for thermo therm_area_widget = QGroupBox("Thermal corrections") thermo_layout = QFormLayout(therm_area_widget) self.thermo_selector = FilereaderComboBox(self.session, otherItems=['frequency']) self.thermo_selector.currentIndexChanged.connect(self.set_thermo_mdl) thermo_layout.addRow(self.thermo_selector) self.temperature_line = QDoubleSpinBox() self.temperature_line.setMaximum(2**31 - 1) self.temperature_line.setValue(298.15) self.temperature_line.setSingleStep(10) self.temperature_line.setSuffix(" K") self.temperature_line.setMinimum(0) self.temperature_line.valueChanged.connect(self.set_thermo) thermo_layout.addRow("T =", self.temperature_line) self.v0_edit = QDoubleSpinBox() self.v0_edit.setMaximum(4000) self.v0_edit.setValue(self.settings.w0) self.v0_edit.setSingleStep(25) self.v0_edit.setSuffix(" cm\u207b\u00b9") self.v0_edit.valueChanged.connect(self.set_thermo) self.v0_edit.setMinimum(0) self.v0_edit.setToolTip( "frequency parameter for quasi treatments of entropy") thermo_layout.addRow("𝜔<sub>0</sub> =", self.v0_edit) self.thermo_table = QTableWidget() self.thermo_table.setColumnCount(3) self.thermo_table.setShowGrid(False) self.thermo_table.horizontalHeader().hide() self.thermo_table.verticalHeader().hide() self.thermo_table.setFrameShape(QTableWidget.NoFrame) self.thermo_table.setSelectionMode(QTableWidget.NoSelection) thermo_layout.addRow(self.thermo_table) # for for total sum_area_widget = QGroupBox("Thermochemistry") sum_layout = QFormLayout(sum_area_widget) self.sum_table = QTableWidget() self.sum_table.setColumnCount(3) self.sum_table.setShowGrid(False) self.sum_table.horizontalHeader().hide() self.sum_table.verticalHeader().hide() self.sum_table.setFrameShape(QTableWidget.NoFrame) self.sum_table.setSelectionMode(QTableWidget.NoSelection) sum_layout.addRow(self.sum_table) splitter = QSplitter(Qt.Horizontal) splitter.setChildrenCollapsible(False) splitter.addWidget(sp_area_widget) splitter.addWidget(therm_area_widget) splitter.addWidget(sum_area_widget) absolute_layout.addWidget(splitter) self.status = QStatusBar() self.status.setSizeGripEnabled(False) self.status.setStyleSheet("color: red") absolute_layout.addWidget(self.status, 1, 0, 1, 1, Qt.AlignTop) self.tab_widget.addTab(absolute_widget, "absolute") relative_widget = QWidget() relative_layout = QGridLayout(relative_widget) size = [self.settings.ref_col_1, self.settings.ref_col_2] self.ref_group = ThermoGroup("reference group", self.session, self.nrg_fr, self.thermo_co, size) self.ref_group.changes.connect(self.calc_relative_thermo) relative_layout.addWidget(self.ref_group, 0, 0, 1, 3, Qt.AlignTop) size = [self.settings.other_col_1, self.settings.other_col_2] self.other_group = ThermoGroup("other group", self.session, self.nrg_fr, self.thermo_co, size) self.other_group.changes.connect(self.calc_relative_thermo) relative_layout.addWidget(self.other_group, 0, 3, 1, 3, Qt.AlignTop) self.relative_temperature = QDoubleSpinBox() self.relative_temperature.setMaximum(2**31 - 1) self.relative_temperature.setValue(self.settings.rel_temp) self.relative_temperature.setSingleStep(10) self.relative_temperature.setSuffix(" K") self.relative_temperature.setMinimum(0) self.relative_temperature.valueChanged.connect( self.calc_relative_thermo) relative_layout.addWidget(QLabel("T ="), 1, 0, 1, 1, Qt.AlignRight | Qt.AlignVCenter) relative_layout.addWidget(self.relative_temperature, 1, 1, 1, 5, Qt.AlignLeft | Qt.AlignVCenter) self.relative_v0 = QDoubleSpinBox() self.relative_v0.setMaximum(2**31 - 1) self.relative_v0.setValue(self.settings.w0) self.relative_v0.setSingleStep(25) self.relative_v0.setSuffix(" cm\u207b\u00b9") self.relative_v0.setMinimum(0) self.relative_v0.setToolTip( "frequency parameter for quasi treatments of entropy") self.relative_v0.valueChanged.connect(self.calc_relative_thermo) relative_layout.addWidget(QLabel("𝜔<sub>0</sub> ="), 2, 0, 1, 1, Qt.AlignRight | Qt.AlignVCenter) relative_layout.addWidget(self.relative_v0, 2, 1, 1, 5, Qt.AlignLeft | Qt.AlignVCenter) relative_layout.addWidget( QLabel("Boltzmann-weighted relative energies in kcal/mol:"), 3, 0, 1, 6, Qt.AlignVCenter | Qt.AlignLeft) self.relative_table = QTextBrowser() self.relative_table.setMaximumHeight( 4 * self.relative_table.fontMetrics().boundingRect("Q").height()) relative_layout.addWidget(self.relative_table, 4, 0, 1, 6, Qt.AlignTop) relative_layout.setRowStretch(0, 1) relative_layout.setRowStretch(1, 0) relative_layout.setRowStretch(2, 0) relative_layout.setRowStretch(3, 0) relative_layout.setRowStretch(4, 0) self.tab_widget.addTab(relative_widget, "relative") #menu stuff menu = QMenuBar() export = menu.addMenu("&Export") copy = QAction("&Copy CSV to clipboard", self.tool_window.ui_area) copy.triggered.connect(self.copy_csv) shortcut = QKeySequence(Qt.CTRL + Qt.Key_C) copy.setShortcut(shortcut) export.addAction(copy) self.copy = copy save = QAction("&Save CSV...", self.tool_window.ui_area) save.triggered.connect(self.save_csv) #this shortcut interferes with main window's save shortcut #I've tried different shortcut contexts to no avail #thanks Qt... #shortcut = QKeySequence(Qt.CTRL + Qt.Key_S) #save.setShortcut(shortcut) #save.setShortcutContext(Qt.WidgetShortcut) export.addAction(save) delimiter = export.addMenu("Delimiter") comma = QAction("comma", self.tool_window.ui_area, checkable=True) comma.setChecked(self.settings.delimiter == "comma") comma.triggered.connect(lambda *args, delim="comma": self.settings. __setattr__("delimiter", delim)) delimiter.addAction(comma) tab = QAction("tab", self.tool_window.ui_area, checkable=True) tab.setChecked(self.settings.delimiter == "tab") tab.triggered.connect(lambda *args, delim="tab": self.settings. __setattr__("delimiter", delim)) delimiter.addAction(tab) space = QAction("space", self.tool_window.ui_area, checkable=True) space.setChecked(self.settings.delimiter == "space") space.triggered.connect(lambda *args, delim="space": self.settings. __setattr__("delimiter", delim)) delimiter.addAction(space) semicolon = QAction("semicolon", self.tool_window.ui_area, checkable=True) semicolon.setChecked(self.settings.delimiter == "semicolon") semicolon.triggered.connect(lambda *args, delim="semicolon": self. settings.__setattr__("delimiter", delim)) delimiter.addAction(semicolon) add_header = QAction("&Include CSV header", self.tool_window.ui_area, checkable=True) add_header.setChecked(self.settings.include_header) add_header.triggered.connect(self.header_check) export.addAction(add_header) comma.triggered.connect( lambda *args, action=tab: action.setChecked(False)) comma.triggered.connect( lambda *args, action=space: action.setChecked(False)) comma.triggered.connect( lambda *args, action=semicolon: action.setChecked(False)) tab.triggered.connect( lambda *args, action=comma: action.setChecked(False)) tab.triggered.connect( lambda *args, action=space: action.setChecked(False)) tab.triggered.connect( lambda *args, action=semicolon: action.setChecked(False)) space.triggered.connect( lambda *args, action=comma: action.setChecked(False)) space.triggered.connect( lambda *args, action=tab: action.setChecked(False)) space.triggered.connect( lambda *args, action=semicolon: action.setChecked(False)) semicolon.triggered.connect( lambda *args, action=comma: action.setChecked(False)) semicolon.triggered.connect( lambda *args, action=tab: action.setChecked(False)) semicolon.triggered.connect( lambda *args, action=space: action.setChecked(False)) menu.setNativeMenuBar(False) self._menu = menu layout.setMenuBar(menu) menu.setVisible(True) self.tool_window.ui_area.setLayout(layout) self.tool_window.manage(None)
def _build_ui(self): layout = QGridLayout() tabs = QTabWidget() calc_widget = QWidget() calc_layout = QFormLayout(calc_widget) settings_widget = QWidget() settings_layout = QFormLayout(settings_widget) steric_map_widget = QWidget() steric_layout = QFormLayout(steric_map_widget) cutout_widget = QWidget() vol_cutout_layout = QFormLayout(cutout_widget) layout.addWidget(tabs) tabs.addTab(calc_widget, "calculation") tabs.addTab(settings_widget, "settings") tabs.addTab(steric_map_widget, "steric map") tabs.addTab(cutout_widget, "volume cutout") self.radii_option = QComboBox() self.radii_option.addItems(["Bondi", "UMN"]) ndx = self.radii_option.findText(self.settings.radii, Qt.MatchExactly) self.radii_option.setCurrentIndex(ndx) settings_layout.addRow("radii:", self.radii_option) self.scale = QDoubleSpinBox() self.scale.setValue(self.settings.vdw_scale) self.scale.setSingleStep(0.01) self.scale.setRange(1., 1.5) settings_layout.addRow("VDW scale:", self.scale) set_ligand_atoms = QPushButton("set ligands to current selection") set_ligand_atoms.clicked.connect(self.set_ligand_atoms) set_ligand_atoms.setToolTip( "specify atoms to use in calculation\n" + "by default, all atoms will be used unless a single center is specified\n" + "in the case of a single center, all atoms except the center is used" ) calc_layout.addRow(set_ligand_atoms) self.set_ligand_atoms = set_ligand_atoms self.radius = QDoubleSpinBox() self.radius.setValue(self.settings.center_radius) self.radius.setSuffix(" \u212B") self.radius.setDecimals(1) self.radius.setSingleStep(0.1) self.radius.setRange(1., 15.) settings_layout.addRow("radius around center:", self.radius) self.method = QComboBox() self.method.addItems(["Lebedev", "Monte-Carlo"]) self.method.setToolTip("Lebedev: deterministic method\n" + "Monte-Carlo: non-deterministic method") ndx = self.method.findText(self.settings.method, Qt.MatchExactly) self.method.setCurrentIndex(ndx) settings_layout.addRow("integration method:", self.method) leb_widget = QWidget() leb_layout = QFormLayout(leb_widget) leb_layout.setContentsMargins(0, 0, 0, 0) self.radial_points = QComboBox() self.radial_points.addItems(["20", "32", "64", "75", "99", "127"]) self.radial_points.setToolTip( "more radial points will give more accurate results, but integration will take longer" ) ndx = self.radial_points.findText(self.settings.radial_points, Qt.MatchExactly) self.radial_points.setCurrentIndex(ndx) leb_layout.addRow("radial points:", self.radial_points) self.angular_points = QComboBox() self.angular_points.addItems([ "110", "194", "302", "590", "974", "1454", "2030", "2702", "5810" ]) self.angular_points.setToolTip( "more angular points will give more accurate results, but integration will take longer" ) ndx = self.angular_points.findText(self.settings.angular_points, Qt.MatchExactly) self.angular_points.setCurrentIndex(ndx) leb_layout.addRow("angular points:", self.angular_points) settings_layout.addRow(leb_widget) mc_widget = QWidget() mc_layout = QFormLayout(mc_widget) mc_layout.setContentsMargins(0, 0, 0, 0) self.min_iter = QSpinBox() self.min_iter.setValue(self.settings.minimum_iterations) self.min_iter.setRange(0, 10000) self.min_iter.setToolTip( "each iteration is 3000 points\n" + "iterations continue until convergence criteria are met") mc_layout.addRow("minimum interations:", self.min_iter) settings_layout.addRow(mc_widget) if self.settings.method == "Lebedev": mc_widget.setVisible(False) elif self.settings.method == "Monte-Carlo": leb_widget.setVisible(False) self.report_component = QComboBox() self.report_component.addItems(["total", "quadrants", "octants"]) ndx = self.report_component.findText(self.settings.report_component, Qt.MatchExactly) self.report_component.setCurrentIndex(ndx) settings_layout.addRow("report volume:", self.report_component) self.use_scene = QCheckBox() self.use_scene.setChecked(self.settings.use_scene) self.use_scene.setToolTip( "quadrants/octants will use the orientation the molecule is displayed in" ) settings_layout.addRow("use display orientation:", self.use_scene) self.method.currentTextChanged.connect( lambda text, widget=leb_widget: widget.setVisible(text == "Lebedev" )) self.method.currentTextChanged.connect( lambda text, widget=mc_widget: widget.setVisible(text == "Monte-Carlo")) self.use_centroid = QCheckBox() self.use_centroid.setChecked(self.settings.use_centroid) self.use_centroid.setToolTip( "place the center between selected atoms\n" + "might be useful for polydentate ligands") calc_layout.addRow("use centroid of centers:", self.use_centroid) self.steric_map = QCheckBox() self.steric_map.setChecked(self.settings.steric_map) self.steric_map.setToolTip( "produce a 2D projection of steric bulk\ncauses buried volume to be reported for individual quadrants" ) steric_layout.addRow("create steric map:", self.steric_map) self.num_pts = QSpinBox() self.num_pts.setRange(25, 250) self.num_pts.setValue(self.settings.num_pts) self.num_pts.setToolTip("number of points along x and y axes") steric_layout.addRow("number of points:", self.num_pts) self.include_vbur = QCheckBox() self.include_vbur.setChecked(self.settings.include_vbur) steric_layout.addRow("label quadrants with %V<sub>bur</sub>", self.include_vbur) self.map_shape = QComboBox() self.map_shape.addItems(["circle", "square"]) ndx = self.map_shape.findText(self.settings.map_shape, Qt.MatchExactly) self.map_shape.setCurrentIndex(ndx) steric_layout.addRow("map shape:", self.map_shape) self.auto_minmax = QCheckBox() self.auto_minmax.setChecked(self.settings.auto_minmax) steric_layout.addRow("automatic min. and max.:", self.auto_minmax) self.map_min = QDoubleSpinBox() self.map_min.setRange(-15., 0.) self.map_min.setSuffix(" \u212B") self.map_min.setSingleStep(0.1) self.map_min.setValue(self.settings.map_min) steric_layout.addRow("minimum value:", self.map_min) self.map_max = QDoubleSpinBox() self.map_max.setRange(0., 15.) self.map_max.setSuffix(" \u212B") self.map_max.setSingleStep(0.1) self.map_max.setValue(self.settings.map_max) steric_layout.addRow("maximum value:", self.map_max) self.num_pts.setEnabled(self.settings.steric_map) self.steric_map.stateChanged.connect( lambda state, widget=self.num_pts: widget.setEnabled(state == Qt. Checked)) self.include_vbur.setEnabled(self.settings.steric_map) self.steric_map.stateChanged.connect( lambda state, widget=self.include_vbur: widget.setEnabled( state == Qt.Checked)) self.map_shape.setEnabled(self.settings.steric_map) self.steric_map.stateChanged.connect( lambda state, widget=self.map_shape: widget.setEnabled(state == Qt. Checked)) self.auto_minmax.setEnabled(self.settings.steric_map) self.steric_map.stateChanged.connect( lambda state, widget=self.auto_minmax: widget.setEnabled( state == Qt.Checked)) self.map_min.setEnabled(not self.settings.auto_minmax and self.settings.steric_map) self.steric_map.stateChanged.connect( lambda state, widget=self.map_min, widget2=self.auto_minmax: widget .setEnabled(state == Qt.Checked and not widget2.isChecked())) self.auto_minmax.stateChanged.connect( lambda state, widget=self.map_min, widget2=self.steric_map: widget. setEnabled(not state == Qt.Checked and widget2.isChecked())) self.map_max.setEnabled(not self.settings.auto_minmax and self.settings.steric_map) self.steric_map.stateChanged.connect( lambda state, widget=self.map_max, widget2=self.auto_minmax: widget .setEnabled(state == Qt.Checked and not widget2.isChecked())) self.auto_minmax.stateChanged.connect( lambda state, widget=self.map_max, widget2=self.steric_map: widget. setEnabled(not state == Qt.Checked and widget2.isChecked())) self.display_cutout = QComboBox() self.display_cutout.addItems(["no", "free", "buried"]) ndx = self.display_cutout.findText(self.settings.display_cutout, Qt.MatchExactly) self.display_cutout.setCurrentIndex(ndx) self.display_cutout.setToolTip("show free or buried volume") vol_cutout_layout.addRow("display volume:", self.display_cutout) self.point_spacing = QDoubleSpinBox() self.point_spacing.setDecimals(3) self.point_spacing.setRange(0.01, 0.5) self.point_spacing.setSingleStep(0.005) self.point_spacing.setSuffix(" \u212B") self.point_spacing.setValue(self.settings.point_spacing) self.point_spacing.setToolTip( "distance between points on cutout\n" + "smaller spacing will narrow gaps, but increase time to create the cutout" ) vol_cutout_layout.addRow("point spacing:", self.point_spacing) self.intersection_scale = QDoubleSpinBox() self.intersection_scale.setDecimals(2) self.intersection_scale.setRange(1., 10.) self.intersection_scale.setSingleStep(0.5) self.intersection_scale.setSuffix("x") self.intersection_scale.setToolTip( "relative density of points where VDW radii intersect\n" + "higher density will narrow gaps, but increase time to create cutout" ) self.intersection_scale.setValue(self.settings.intersection_scale) vol_cutout_layout.addRow("intersection density:", self.intersection_scale) self.cutout_labels = QComboBox() self.cutout_labels.addItems(["none", "quadrants", "octants"]) ndx = self.cutout_labels.findText(self.settings.cutout_labels, Qt.MatchExactly) self.cutout_labels.setCurrentIndex(ndx) vol_cutout_layout.addRow("label sections:", self.cutout_labels) self.point_spacing.setEnabled(self.settings.display_cutout != "no") self.intersection_scale.setEnabled( self.settings.display_cutout != "no") self.cutout_labels.setEnabled(self.settings.display_cutout != "no") self.display_cutout.currentTextChanged.connect( lambda text, widget=self.point_spacing: widget.setEnabled(text != "no")) self.display_cutout.currentTextChanged.connect( lambda text, widget=self.intersection_scale: widget.setEnabled( text != "no")) self.display_cutout.currentTextChanged.connect( lambda text, widget=self.cutout_labels: widget.setEnabled(text != "no")) calc_vbur_button = QPushButton( "calculate % buried volume for selected centers") calc_vbur_button.clicked.connect(self.calc_vbur) calc_layout.addRow(calc_vbur_button) self.calc_vbur_button = calc_vbur_button remove_vbur_button = QPushButton( "remove % buried volume visualizations") remove_vbur_button.clicked.connect(self.del_vbur) vol_cutout_layout.addRow(remove_vbur_button) self.table = QTableWidget() self.table.setColumnCount(3) self.table.setHorizontalHeaderLabels(['model', 'center', '%Vbur']) self.table.setSelectionBehavior(QTableWidget.SelectRows) self.table.setEditTriggers(QTableWidget.NoEditTriggers) self.table.resizeColumnToContents(0) self.table.resizeColumnToContents(1) self.table.resizeColumnToContents(2) self.table.horizontalHeader().setSectionResizeMode( 0, QHeaderView.Interactive) self.table.horizontalHeader().setSectionResizeMode( 1, QHeaderView.Interactive) self.table.horizontalHeader().setSectionResizeMode( 2, QHeaderView.Stretch) calc_layout.addRow(self.table) menu = QMenuBar() export = menu.addMenu("&Export") clear = QAction("Clear data table", self.tool_window.ui_area) clear.triggered.connect(self.clear_table) export.addAction(clear) copy = QAction("&Copy CSV to clipboard", self.tool_window.ui_area) copy.triggered.connect(self.copy_csv) shortcut = QKeySequence(Qt.CTRL + Qt.Key_C) copy.setShortcut(shortcut) export.addAction(copy) self.copy = copy save = QAction("&Save CSV...", self.tool_window.ui_area) save.triggered.connect(self.save_csv) #this shortcut interferes with main window's save shortcut #I've tried different shortcut contexts to no avail #thanks Qt... #shortcut = QKeySequence(Qt.CTRL + Qt.Key_S) #save.setShortcut(shortcut) #save.setShortcutContext(Qt.WidgetShortcut) export.addAction(save) delimiter = export.addMenu("Delimiter") comma = QAction("comma", self.tool_window.ui_area, checkable=True) comma.setChecked(self.settings.delimiter == "comma") comma.triggered.connect(lambda *args, delim="comma": self.settings. __setattr__("delimiter", delim)) delimiter.addAction(comma) tab = QAction("tab", self.tool_window.ui_area, checkable=True) tab.setChecked(self.settings.delimiter == "tab") tab.triggered.connect(lambda *args, delim="tab": self.settings. __setattr__("delimiter", delim)) delimiter.addAction(tab) space = QAction("space", self.tool_window.ui_area, checkable=True) space.setChecked(self.settings.delimiter == "space") space.triggered.connect(lambda *args, delim="space": self.settings. __setattr__("delimiter", delim)) delimiter.addAction(space) semicolon = QAction("semicolon", self.tool_window.ui_area, checkable=True) semicolon.setChecked(self.settings.delimiter == "semicolon") semicolon.triggered.connect(lambda *args, delim="semicolon": self. settings.__setattr__("delimiter", delim)) delimiter.addAction(semicolon) add_header = QAction("&Include CSV header", self.tool_window.ui_area, checkable=True) add_header.setChecked(self.settings.include_header) add_header.triggered.connect(self.header_check) export.addAction(add_header) comma.triggered.connect( lambda *args, action=tab: action.setChecked(False)) comma.triggered.connect( lambda *args, action=space: action.setChecked(False)) comma.triggered.connect( lambda *args, action=semicolon: action.setChecked(False)) tab.triggered.connect( lambda *args, action=comma: action.setChecked(False)) tab.triggered.connect( lambda *args, action=space: action.setChecked(False)) tab.triggered.connect( lambda *args, action=semicolon: action.setChecked(False)) space.triggered.connect( lambda *args, action=comma: action.setChecked(False)) space.triggered.connect( lambda *args, action=tab: action.setChecked(False)) space.triggered.connect( lambda *args, action=semicolon: action.setChecked(False)) semicolon.triggered.connect( lambda *args, action=comma: action.setChecked(False)) semicolon.triggered.connect( lambda *args, action=tab: action.setChecked(False)) semicolon.triggered.connect( lambda *args, action=space: action.setChecked(False)) menu.setNativeMenuBar(False) self._menu = menu layout.setMenuBar(menu) menu.setVisible(True) self.tool_window.ui_area.setLayout(layout) self.tool_window.manage(None)
def _build_ui(self): self.layout = QGridLayout() self.ui_area.setLayout(self.layout) self.manage(None)
def _build_ui(self): layout = QGridLayout() layout.addWidget(QLabel("center of rotation:"), 0, 0, 1, 1, Qt.AlignLeft | Qt.AlignVCenter) self.cor_button = QComboBox() self.cor_button.addItems( ["automatic", "select atoms", "view's center of rotation"]) layout.addWidget(self.cor_button, 0, 1, 1, 1, Qt.AlignTop) self.set_cor_selection = QPushButton("set selection") self.cor_button.currentTextChanged.connect( lambda t, widget=self.set_cor_selection: widget.setEnabled( t == "select atoms")) self.set_cor_selection.clicked.connect(self.manual_cor) layout.addWidget(self.set_cor_selection, 0, 2, 1, 1, Qt.AlignTop) self.set_cor_selection.setEnabled(False) layout.addWidget(QLabel("rotation vector:"), 1, 0, 1, 1, Qt.AlignLeft | Qt.AlignVCenter) self.vector_option = QComboBox() self.vector_option.addItems([ "axis", "view axis", "bond", "perpendicular to plane", "centroid of atoms", "custom" ]) layout.addWidget(self.vector_option, 1, 1, 1, 1, Qt.AlignVCenter) vector = QWidget() vector.setToolTip("vector will be normalized before rotating") vector_layout = QHBoxLayout(vector) vector_layout.setContentsMargins(0, 0, 0, 0) self.vector_x = QDoubleSpinBox() self.vector_y = QDoubleSpinBox() self.vector_z = QDoubleSpinBox() self.vector_z.setValue(1.0) for c, t in zip([self.vector_x, self.vector_y, self.vector_z], [" x", " y", " z"]): c.setSingleStep(0.01) c.setRange(-100, 100) # c.setSuffix(t) c.valueChanged.connect(self.show_rot_vec) vector_layout.addWidget(c) layout.addWidget(vector, 1, 2, 1, 1, Qt.AlignTop) vector.setVisible(self.vector_option.currentText() == "custom") self.vector_option.currentTextChanged.connect( lambda text, widget=vector: widget.setVisible(text == "custom")) self.view_axis = QComboBox() self.view_axis.addItems(["z", "y", "x"]) layout.addWidget(self.view_axis, 1, 2, 1, 1, Qt.AlignTop) self.view_axis.setVisible( self.vector_option.currentText() == "view axis") self.vector_option.currentTextChanged.connect( lambda text, widget=self.view_axis: widget.setVisible(text == "view axis")) self.axis = QComboBox() self.axis.addItems(["z", "y", "x"]) layout.addWidget(self.axis, 1, 2, 1, 1, Qt.AlignTop) self.axis.setVisible(self.vector_option.currentText() == "axis") self.vector_option.currentTextChanged.connect( lambda text, widget=self.axis: widget.setVisible(text == "axis")) self.bond_button = QPushButton("set selected bond") self.bond_button.clicked.connect(self.set_bonds) layout.addWidget(self.bond_button, 1, 2, 1, 1, Qt.AlignTop) self.bond_button.setVisible(self.vector_option.currentText() == "bond") self.vector_option.currentTextChanged.connect( lambda text, widget=self.bond_button: widget.setVisible(text == "bond")) self.perp_button = QPushButton("set selected atoms") self.perp_button.clicked.connect(self.set_perpendicular) layout.addWidget(self.perp_button, 1, 2, 1, 1, Qt.AlignTop) self.perp_button.setVisible( self.vector_option.currentText() == "perpendicular to plane") self.vector_option.currentTextChanged.connect( lambda text, widget=self.perp_button: widget.setVisible( text == "perpendicular to plane")) self.group_button = QPushButton("set selected atoms") self.group_button.clicked.connect(self.set_group) layout.addWidget(self.group_button, 1, 2, 1, 1, Qt.AlignTop) self.group_button.setVisible( self.vector_option.currentText() == "centroid of atoms") self.vector_option.currentTextChanged.connect( lambda text, widget=self.group_button: widget.setVisible( text == "centroid of atoms")) layout.addWidget(QLabel("angle:"), 2, 0, 1, 1, Qt.AlignLeft | Qt.AlignVCenter) self.angle = QDoubleSpinBox() self.angle.setRange(-360, 360) self.angle.setSingleStep(5) self.angle.setSuffix("°") layout.addWidget(self.angle, 2, 1, 1, 1, Qt.AlignLeft | Qt.AlignVCenter) layout.addWidget(QLabel("preview rotation axis:"), 3, 0, 1, 1, Qt.AlignLeft | Qt.AlignVCenter) self.display_rot_vec = QCheckBox() self.display_rot_vec.setCheckState(Qt.Checked) self.display_rot_vec.stateChanged.connect(self.show_rot_vec) layout.addWidget(self.display_rot_vec, 3, 1, 1, 1, Qt.AlignLeft | Qt.AlignVCenter) rotate_button = QPushButton("rotate selected atoms") rotate_button.clicked.connect(self.do_rotate) layout.addWidget(rotate_button, 4, 0, 1, 3, Qt.AlignTop) self.rotate_button = rotate_button self.status_bar = QStatusBar() self.status_bar.setSizeGripEnabled(False) layout.addWidget(self.status_bar, 5, 0, 1, 3, Qt.AlignTop) self.vector_option.currentTextChanged.connect(self.show_auto_status) self.cor_button.currentIndexChanged.connect( lambda *args: self.show_auto_status("select atoms")) self.cor_button.currentIndexChanged.connect(self.show_rot_vec) self.set_cor_selection.clicked.connect(self.show_rot_vec) self.vector_option.currentIndexChanged.connect(self.show_rot_vec) self.axis.currentIndexChanged.connect(self.show_rot_vec) self.view_axis.currentIndexChanged.connect(self.show_rot_vec) self.bond_button.clicked.connect(self.show_rot_vec) self.perp_button.clicked.connect(self.show_rot_vec) self.group_button.clicked.connect(self.show_rot_vec) layout.setRowStretch(0, 0) layout.setRowStretch(1, 0) layout.setRowStretch(2, 0) layout.setRowStretch(3, 0) layout.setRowStretch(4, 0) layout.setRowStretch(5, 1) layout.setColumnStretch(0, 0) layout.setColumnStretch(1, 1) layout.setColumnStretch(2, 1) self.tool_window.ui_area.setLayout(layout) self.tool_window.manage(None)