def __init__(self): super().__init__() self.signal.connect(self.slot) self.create_variable_thread = None main_layout = QVBoxLayout() main_layout.addWidget(QLabel("Choose your tokenizer: ")) self.tokenizer = QComboBox() self.tokenizer.addItems([ "word_tokenize", "TweetTokenizer (preferred)" ]) main_layout.addWidget(self.tokenizer) self.keep_only_alphabets = QCheckBox("Remove non-alphabetic words (e.g Punctuation and symbols)") self.remove_stopwords = QCheckBox("Remove Stopwords") self.remove_user_data = QCheckBox("Remove Username and Hyper-Links") main_layout.addWidget(self.keep_only_alphabets) main_layout.addWidget(self.remove_stopwords) main_layout.addWidget(self.remove_user_data) main_layout.addWidget(QLabel("Choose your stemmer:")) self.stemmer = QComboBox() self.stemmer.addItems([ "Porter Stemmer" ]) main_layout.addWidget(self.stemmer) variable_layout = QHBoxLayout() variable_layout.addWidget(QLabel("Name for your pre-processor: ")) self.variable_name = QLineEdit() variable_layout.addWidget(self.variable_name) main_layout.addLayout(variable_layout) create_variable = QPushButton("CREATE VARIABLE") create_variable.clicked.connect(self.create_variable_clicked) main_layout.addWidget(create_variable) main_layout.addSpacerItem(QSpacerItem(40, 20, QSizePolicy.Minimum, QSizePolicy.Expanding)) self.setLayout(main_layout)
class RSAKeygen(BaseKeygen): def __init__(self, parent: QWidget = None): super().__init__(parent) self.setup_ui() def setup_ui(self): self.p_value = EditWithButton('p value', 'Randomize') self.q_value = EditWithButton('q value', 'Randomize') self.spacer = QSpacerItem(10, 10, QSizePolicy.Expanding, QSizePolicy.Expanding) self.layout = QVBoxLayout() self.layout.addWidget(self.p_value) self.layout.addWidget(self.q_value) self.layout.addSpacerItem(self.spacer) self.setLayout(self.layout) self.p_value.btn_random.clicked.connect( lambda: self.randomize(is_p=True)) self.q_value.btn_random.clicked.connect( lambda: self.randomize(is_p=False)) def randomize(self, is_p: bool): random_number = generate_prime_number(9) if is_p: self.p_value.line_edit.setText(str(random_number)) else: self.q_value.line_edit.setText(str(random_number)) def build_params(self): p = int(self.p_value.line_edit.text()) q = int(self.q_value.line_edit.text()) return [p, q]
def initUI(self): # Place username and password widget hbox = QHBoxLayout() vbox = QVBoxLayout() self.setLayout(hbox) hbox.addItem(QSpacerItem(4, 4, QSizePolicy.Expanding)) hbox.addLayout(vbox) hbox.addItem(QSpacerItem(4, 4, QSizePolicy.Expanding)) space1 = QSpacerItem(4, 4, QSizePolicy.Minimum, QSizePolicy.Expanding) vbox.addSpacerItem(space1) vbox.setContentsMargins(0, 0, 40, 0) grid = QGridLayout() grid.addWidget(QLabel('Username:'******'Password:'******'Login') # Connect login clicked event #self.loginBtn.clicked.connect(self.loginClicked) vbox.addWidget(self.loginBtn) self.logerrorlabel = QLabel() vbox.addWidget(self.logerrorlabel) space2 = QSpacerItem(2, 2, QSizePolicy.Minimum, QSizePolicy.Expanding) vbox.addSpacerItem(space2) self.show()
def initLayout(self): txt1 = QHBoxLayout() txt1.addWidget(self.lbl1) txt1.addWidget(self.starting) txt2 = QHBoxLayout() txt2.addWidget(self.lbl2) txt2.addWidget(self.destination) txtbox = QVBoxLayout() txtbox.addLayout(txt1) txtbox.addLayout(txt2) searchbox = QHBoxLayout() searchbox.addLayout(txtbox) searchbox.addWidget(self.resetBtn) vbox = QVBoxLayout() vbox.addLayout(searchbox) vbox.addWidget(self.trabletimeLbl) vbox.addWidget(self.mruView) vbox.addSpacerItem(self.space) # vbox.addSpacing(300) hbox = QHBoxLayout() hbox.addWidget(self.engine) hbox.addLayout(vbox) self.setLayout(hbox)
def __init__(self): super().__init__() self.signal.connect(self.missing_value_slot) self.create_imputer_thread = None main_layout = QVBoxLayout() imputer_init_layout = QHBoxLayout() imputer_init_layout.addWidget( QLabel("Variable Name for storing \"Imputer\" object:")) self.imputer_variable = QLineEdit() imputer_init_layout.addWidget(self.imputer_variable) main_layout.addLayout(imputer_init_layout) main_layout.addWidget(QLabel("Properties:")) imputer_properties = QGridLayout() imputer_properties.addWidget(QLabel("Missing Value:"), 0, 0) self.missing_value = QLineEdit("NaN") imputer_properties.addWidget(self.missing_value, 0, 1) imputer_properties.addWidget(QLabel("Strategy:"), 1, 0) self.strategy = QLineEdit("mean") imputer_properties.addWidget(self.strategy, 1, 1) imputer_properties.addWidget(QLabel("Axis:"), 2, 0) self.axis = QComboBox() self.axis.addItems(["0 - column wise", "1 - row wise"]) imputer_properties.addWidget(self.axis, 2, 1) main_layout.addLayout(imputer_properties) create_imputer = QPushButton("CREATE IMPUTER") create_imputer.clicked.connect(self.create_imputer_clicked) main_layout.addWidget(create_imputer) main_layout.addSpacerItem( QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding)) self.setLayout(main_layout)
def initAppletDrawerUi(self): training_controls = EdgeTrainingGui.createDrawerControls(self) training_controls.layout().setContentsMargins(5, 0, 5, 0) training_layout = QVBoxLayout() training_layout.addWidget(training_controls) training_layout.setContentsMargins(0, 15, 0, 0) training_box = QGroupBox("Training", parent=self) training_box.setLayout(training_layout) training_box.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) multicut_controls = MulticutGuiMixin.createDrawerControls(self) multicut_controls.layout().setContentsMargins(5, 0, 5, 0) multicut_layout = QVBoxLayout() multicut_layout.addWidget(multicut_controls) multicut_layout.setContentsMargins(0, 15, 0, 0) multicut_box = QGroupBox("Multicut", parent=self) multicut_box.setLayout(multicut_layout) multicut_box.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) multicut_box.setEnabled(False) op = self.topLevelOperatorView multicut_required_slots = (op.Superpixels, op.Rag, op.EdgeProbabilities, op.EdgeProbabilitiesDict) self.__cleanup_fns.append(guiutil.enable_when_ready(multicut_box, multicut_required_slots)) drawer_layout = QVBoxLayout() drawer_layout.addWidget(training_box) drawer_layout.addWidget(multicut_box) drawer_layout.setSpacing(2) drawer_layout.setContentsMargins(5, 5, 5, 5) drawer_layout.addSpacerItem(QSpacerItem(0, 10, QSizePolicy.Minimum, QSizePolicy.Expanding)) self._drawer = QWidget(parent=self) self._drawer.setLayout(drawer_layout)
def __init__(self, parent=None): super().__init__(parent) self._rounding = 22 self._textPadding = 4 self._currentIndex = 0 self._tabs = [] # QList<FancyTab> self._triggerTimer = QTimer() self.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Expanding) # setStyle(new QWindowsStyle) self.setMinimumWidth(max(2 * self._rounding, 40)) self.setAttribute(Qt.WA_Hover, True) self.setFocusPolicy(Qt.NoFocus) self.setMouseTracking(True) # Needed for hover events self._triggerTimer.setSingleShot(True) layout = QVBoxLayout() layout.addSpacerItem( QSpacerItem(0, 0, QSizePolicy.Fixed, QSizePolicy.Expanding)) layout.setSpacing(0) layout.setContentsMargins(0, 0, 0, 0) self.setLayout(layout) # We use a zerotimer to keep the sidebar responsing self._triggerTimer.timeout.connect(self.emitCurrentIndex)
class TabPreferences(QWidget): """ Tab where user can change several app parameters """ def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) # ---- UI ---- self.setWindowTitle(self.tr("Preferences")) # ---- Content ---- self.layout = QVBoxLayout() self.layout.setSpacing(120) # Language self.language_select = LanguageSelect() self.layout.addWidget(self.language_select) # Currency self.currency_select = CurrencySelect() self.layout.addWidget(self.currency_select) # Spacer self.layout.addSpacerItem( QSpacerItem(0, 0, QSizePolicy.Minimum, QSizePolicy.Expanding)) # Save Button self.save = SaveButton() self.layout.addLayout(self.save) self.setLayout(self.layout) # ---- Functionality ---- self.save.bttn.clicked.connect(self.handleSave) def handleSave(self): confighandler.set_language(self.language_select.get_current_language()) confighandler.set_fiat_currency( self.currency_select.get_current_currency()) mssg = SavedMessage(self) mssg.exec()
class LabelledComboBox(QWidget): currentIndexChanged = pyqtSignal(int) def __init__(self, align_flag=Qt.AlignLeft, label=None, spacer=None): QWidget.__init__(self) self.layout = QVBoxLayout() if label is not None: self.label = QLabel(label) self.label.setWordWrap(True) self.label.setStyleSheet("font: 8px") self.label.setContentsMargins(0, 0, 0, 0) self.label.setAlignment(align_flag) self.layout.addWidget(self.label) self.box = QComboBox() self.box.currentIndexChanged.connect(lambda x: self.currentIndexChanged.emit(x)) self.layout.addWidget(self.box) if spacer == "lower": self.layout.addSpacerItem(QSpacerItem(0, 0, QSizePolicy.Minimum, QSizePolicy.Expanding)) if spacer == "upper": self.layout.insertSpacerItem(0, QSpacerItem(0, 0, QSizePolicy.Minimum, QSizePolicy.Expanding)) self.layout.setContentsMargins(0, 0, 0, 0) self.setLayout(self.layout) def currentIndex(self): return self.box.currentIndex() def currentText(self): return self.box.currentText() def setCurrentIndex(self, index): self.box.setCurrentIndex(index) def addItem(self, item): self.box.addItem(item)
def _draw_profile(self, profile, is_selected, layout): profile_widget = QFrame() profile_widget.setMinimumSize(400, 55) profile_widget.setMaximumSize(400, 55) if is_selected: profile_widget.setStyleSheet("QFrame {background-color: rgb(200,200,255);}") else: profile_widget.setStyleSheet("QFrame {background-color: rgb(200,200,200);}") profile_insides = QHBoxLayout() profile_widget.setLayout(profile_insides) title_and_description_layout = QVBoxLayout() title = QLabel(cutoff_string(profile.name, 30)) title.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignTop) title.setMaximumSize(200, 20) title.setMinimumSize(200, 20) title_and_description_layout.addWidget(title) desc = QLabel(cutoff_string(profile.description, 50)) desc.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignBottom) desc.setMaximumSize(350, 20) desc.setMinimumSize(350, 20) title_and_description_layout.addWidget(desc) title_and_description_layout.addSpacerItem(QSpacerItem(40, 40, QSizePolicy.MinimumExpanding)) profile_insides.addLayout(title_and_description_layout) layout.addWidget(profile_widget) return profile_widget
def initAppletDrawerUi(self): training_controls = EdgeTrainingGui.createDrawerControls(self) training_controls.layout().setContentsMargins(5,0,5,0) training_layout = QVBoxLayout() training_layout.addWidget( training_controls ) training_layout.setContentsMargins(0,15,0,0) training_box = QGroupBox( "Training", parent=self ) training_box.setLayout(training_layout) training_box.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) multicut_controls = MulticutGuiMixin.createDrawerControls(self) multicut_controls.layout().setContentsMargins(5,0,5,0) multicut_layout = QVBoxLayout() multicut_layout.addWidget( multicut_controls ) multicut_layout.setContentsMargins(0,15,0,0) multicut_box = QGroupBox( "Multicut", parent=self ) multicut_box.setLayout(multicut_layout) multicut_box.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) drawer_layout = QVBoxLayout() drawer_layout.addWidget(training_box) drawer_layout.addWidget(multicut_box) drawer_layout.setSpacing(2) drawer_layout.setContentsMargins(5,5,5,5) drawer_layout.addSpacerItem( QSpacerItem(0, 10, QSizePolicy.Minimum, QSizePolicy.Expanding) ) self._drawer = QWidget(parent=self) self._drawer.setLayout(drawer_layout)
def show_pulsantiera(self): # Layout interni utilizzati per l'allineamento dei due pulsanti layout_pulsanti1 = QVBoxLayout() layout_pulsanti2 = QHBoxLayout() # Configurazione del pulsante Indietro pulsante_indietro = QPushButton("Indietro") pulsante_indietro.setStyleSheet( 'QPushButton {background-color: orange; color: black;}') pulsante_indietro.setFont(QFont('Times New Roman', 30, 100, True)) pulsante_indietro.setFixedSize(300, 100) pulsante_indietro.clicked.connect(self.indietro) # Configurazione del pulsante Prenota pulsante_modifica = QPushButton("Elimina") pulsante_modifica.setStyleSheet( 'QPushButton {background-color: orange; color: black;}') pulsante_modifica.setFont(QFont('Times New Roman', 30, 100, True)) pulsante_modifica.setFixedSize(300, 100) pulsante_modifica.clicked.connect(self.elimina) # Inserimento dei due pulsanti dei layout interni layout_pulsanti1.addWidget(pulsante_modifica) layout_pulsanti1.addSpacerItem(QSpacerItem(0, 100)) layout_pulsanti1.addWidget(pulsante_indietro) layout_pulsanti2.addLayout(layout_pulsanti1) # Inserimento dei due pulsanti del layout globale self.layout_verticale2.addLayout(layout_pulsanti2)
def __init__(self, parent): super().__init__() self._preferences = parent vbox = QVBoxLayout(self) # Groups group_box_start = QGroupBox(translations.TR_PREFERENCES_GENERAL_START) group_box_workspace = QGroupBox( translations.TR_PREFERENCES_GENERAL_WORKSPACE) # Group start box_start = QVBoxLayout(group_box_start) self._check_last_session = QCheckBox( translations.TR_PREFERENCES_GENERAL_LOAD_LAST_SESSION) self._check_notify_updates = QCheckBox( translations.TR_PREFERENCES_GENERAL_NOTIFY_UPDATES) box_start.addWidget(self._check_last_session) box_start.addWidget(self._check_notify_updates) # Workspace and Project grid_workspace = QGridLayout(group_box_workspace) self._text_workspace = ui_tools.LineEditButton( QIcon(self.style().standardPixmap(self.style().SP_TrashIcon))) self._text_workspace.buttonClicked.connect(self._text_workspace.clear) self._text_workspace.setReadOnly(True) grid_workspace.addWidget( QLabel(translations.TR_PREFERENCES_GENERAL_WORKSPACE), 0, 0) grid_workspace.addWidget(self._text_workspace, 0, 1) # Add groups to main layout vbox.addWidget(group_box_start) vbox.addWidget(group_box_workspace) vbox.addSpacerItem( QSpacerItem(0, 0, QSizePolicy.Expanding, QSizePolicy.Expanding))
def initAppletDrawerUi(self): localDir = os.path.split(__file__)[0] self._drawer = self._cropControlUi data_has_z_axis = True if self.topLevelOperatorView.InputImage.ready(): tShape = self.topLevelOperatorView.InputImage.meta.getTaggedShape() if not 'z' in tShape or tShape['z']==1: data_has_z_axis = False self._cropControlUi._minSliderZ.setVisible(data_has_z_axis) self._cropControlUi._minSliderZ.setVisible(data_has_z_axis) self._cropControlUi._maxSliderZ.setVisible(data_has_z_axis) self._cropControlUi._minSpinZ.setVisible(data_has_z_axis) self._cropControlUi._maxSpinZ.setVisible(data_has_z_axis) self._cropControlUi.labelMinZ.setVisible(data_has_z_axis) self._cropControlUi.labelMaxZ.setVisible(data_has_z_axis) self._cropControlUi.AddCropButton.clicked.connect( bind (self.newCrop) ) self._cropControlUi.SetCropButton.setVisible(False) self.editor.cropModel.mouseRelease.connect(bind(self.setCrop)) self.topLevelOperatorView.MinValueT.notifyDirty(self.apply_operator_settings_to_gui) self.topLevelOperatorView.MaxValueT.notifyDirty(self.apply_operator_settings_to_gui) self.topLevelOperatorView.MinValueX.notifyDirty(self.apply_operator_settings_to_gui) self.topLevelOperatorView.MaxValueX.notifyDirty(self.apply_operator_settings_to_gui) self.topLevelOperatorView.MinValueY.notifyDirty(self.apply_operator_settings_to_gui) self.topLevelOperatorView.MaxValueY.notifyDirty(self.apply_operator_settings_to_gui) self.topLevelOperatorView.MinValueZ.notifyDirty(self.apply_operator_settings_to_gui) self.topLevelOperatorView.MaxValueZ.notifyDirty(self.apply_operator_settings_to_gui) self.topLevelOperatorView.InputImage.notifyDirty(self.setDefaultValues) self.topLevelOperatorView.PredictionImage.notifyDirty(self.setDefaultValues) layout = QVBoxLayout() layout.setSpacing(0) layout.addWidget( self._cropControlUi ) layout.addSpacerItem( QSpacerItem(0,0,vPolicy=QSizePolicy.Expanding) ) self.setDefaultValues() self.apply_operator_settings_to_gui() self.editor.showCropLines(True) self.editor.cropModel.setEditable (True) self.editor.cropModel.changed.connect(self.onCropModelChanged) self.editor.posModel.timeChanged.connect(self.updateTime) self._cropControlUi._minSliderT.valueChanged.connect(self._onMinSliderTMoved) self._cropControlUi._maxSliderT.valueChanged.connect(self._onMaxSliderTMoved) self._cropControlUi._minSliderX.valueChanged.connect(self._onMinSliderXMoved) self._cropControlUi._maxSliderX.valueChanged.connect(self._onMaxSliderXMoved) self._cropControlUi._minSliderY.valueChanged.connect(self._onMinSliderYMoved) self._cropControlUi._maxSliderY.valueChanged.connect(self._onMaxSliderYMoved) self._cropControlUi._minSliderZ.valueChanged.connect(self._onMinSliderZMoved) self._cropControlUi._maxSliderZ.valueChanged.connect(self._onMaxSliderZMoved) self._cropControlUi.cropListView.deleteCrop.connect(self.onDeleteCrop) self._cropControlUi.cropListView.colorsChanged.connect(self.onColorsChanged) self._initCropListView()
def createDrawerControls(self): op = self.topLevelOperatorView def configure_update_handlers( qt_signal, op_slot ): qt_signal.connect( self.configure_operator_from_gui ) cleanup_fn = op_slot.notifyDirty( self.configure_gui_from_operator, defer=True ) self.__cleanup_fns.append( cleanup_fn ) # Controls feature_selection_button = QPushButton(text="Select Features", icon=QIcon(ilastikIcons.AddSel), toolTip="Select edge/superpixel features to use for classification.", clicked=self._open_feature_selection_dlg) self.train_from_gt_button = QPushButton(text="Auto-label", icon=QIcon(ilastikIcons.Segment), toolTip="Automatically label all edges according to your pre-loaded groundtruth volume.", clicked=self._handle_label_from_gt_clicked) self.clear_labels_button = QPushButton(text="Clear Labels", icon=QIcon(ilastikIcons.Clear), toolTip="Remove all edge labels. (Start over on this image.)", clicked=self._handle_clear_labels_clicked) self.live_update_button = QPushButton(text="Live Predict", checkable=True, icon=QIcon(ilastikIcons.Play), toolTip="Update the edge classifier predictions", clicked=self._handle_live_update_clicked) configure_update_handlers( self.live_update_button.toggled, op.FreezeCache ) # Layout label_layout = QHBoxLayout() label_layout.addWidget(self.clear_labels_button) label_layout.addWidget(self.train_from_gt_button) label_layout.setSpacing(1) layout = QVBoxLayout() layout.addWidget(feature_selection_button) layout.setSpacing(1) layout.addLayout(label_layout) layout.addWidget(self.live_update_button) layout.addSpacerItem( QSpacerItem(0, 10, QSizePolicy.Minimum, QSizePolicy.Expanding) ) # Finally, the whole drawer widget drawer = QWidget(parent=self) drawer.setLayout(layout) # Widget Shortcuts mgr = ShortcutManager() ActionInfo = ShortcutManager.ActionInfo shortcut_group = "Edge Training" mgr.register( "l", ActionInfo( shortcut_group, "Live Predict", "Toggle live edge classifier update mode", self.live_update_button.toggle, self.live_update_button, self.live_update_button ) ) return drawer
class VistaInformazioniDipendente(QWidget): def __init__(self, dipendente, rimuovi, salva_dati, aggiorna): super(VistaInformazioniDipendente, self).__init__() # Funzione utile per l'aggiornamento della vista precedente dopo la modifica self.aggiorna = aggiorna # Funzione per la rimozione del dipendente self.rimuovi = rimuovi # Funzione ultile per il salvataggio dei dipendenti modificati self.salva_dati = salva_dati # Oggetto selezionato dalla vista precedente self.dipendente = dipendente # Controller del dipendente utile per le varie operazioni da effettuare self.controller_dipendente = ControllerDipendente(self.dipendente) # Layout usati per la visualizzazione e l'allineamento della vista self.layout_verticale = QVBoxLayout() self.layout_orizzontale = QHBoxLayout() # Configurazione della dimensione della finestra self.setFixedSize(400, 300) # Allineamento e settaggio della Label che descrive le principali inforazioni del dipendente label = QLabel( self.controller_dipendente.get_dipendente_str_x_elenco()) label.setFont(QFont('Times New Roman', 20)) label.setAlignment(Qt.AlignCenter) self.layout_verticale.addWidget(label) self.layout_verticale.addSpacerItem(QSpacerItem(150, 0)) # Creazione e configurazione del bottone "Chiudi" bottone_chiudi = QPushButton("Chiudi") bottone_chiudi.clicked.connect(self.call_chiudi) self.layout_orizzontale.addWidget(bottone_chiudi) # Creazione e configurazione del bottone "Elimina" bottone_elimina = QPushButton("Elimina") bottone_elimina.clicked.connect(self.call_elimina) self.layout_orizzontale.addWidget(bottone_elimina) # Impostazione e allineamento del layout totale self.layout_verticale.addLayout(self.layout_orizzontale) self.setLayout(self.layout_verticale) self.setWindowTitle('Informazioni dipendente') # Metodo per chiudere la finestra corrente def call_chiudi(self): self.close() # Metodo per eliminare un dipendente def call_elimina(self): self.rimuovi(self.dipendente) self.aggiorna() self.salva_dati() self.close()
def initAppletDrawerUi(self): self.train_edge_clf_box = QCheckBox( text="Train edge classifier", toolTip= "Manually select features and train a random forest classifier on them, to predict boundary probabilities. If left unchecked, training will be skiped, and probabilities will be calculated based on the mean probability along edges. This produces good results for clear boundaries.", checked=False, ) training_controls = EdgeTrainingMixin.createDrawerControls(self) training_controls.layout().setContentsMargins(5, 0, 5, 0) training_layout = QVBoxLayout() training_layout.addWidget(training_controls) training_layout.setContentsMargins(0, 15, 0, 0) training_box = QGroupBox("Training", parent=self) training_box.setLayout(training_layout) training_box.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) training_box.setEnabled(self.train_edge_clf_box.isChecked()) multicut_controls = MulticutGuiMixin.createDrawerControls(self) multicut_controls.layout().setContentsMargins(5, 0, 5, 0) multicut_layout = QVBoxLayout() multicut_layout.addWidget(multicut_controls) multicut_layout.setContentsMargins(0, 15, 0, 0) multicut_box = QGroupBox("Multicut", parent=self) multicut_box.setLayout(multicut_layout) multicut_box.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) multicut_box.setEnabled(True) op = self.topLevelOperatorView multicut_required_slots = (op.Superpixels, op.Rag, op.EdgeProbabilities, op.EdgeProbabilitiesDict) self.__cleanup_fns.append( guiutil.enable_when_ready(multicut_box, multicut_required_slots)) def _handle_train_edge_clf_box_clicked(): training_box.setEnabled(self.train_edge_clf_box.isChecked()) op.TrainRandomForest.setValue(self.train_edge_clf_box.isChecked()) self.train_edge_clf_box.toggled.connect( _handle_train_edge_clf_box_clicked) drawer_layout = QVBoxLayout() drawer_layout.addWidget(self.train_edge_clf_box) drawer_layout.addWidget(training_box) drawer_layout.addWidget(multicut_box) drawer_layout.setSpacing(2) drawer_layout.setContentsMargins(5, 5, 5, 5) drawer_layout.addSpacerItem( QSpacerItem(0, 10, QSizePolicy.Minimum, QSizePolicy.Expanding)) self._drawer = QWidget(parent=self) self._drawer.setLayout(drawer_layout)
def __init__(self, parent): super(FindInFilesWidget, self).__init__(parent) self._main_container = IDE.get_service('main_container') self._explorer_container = IDE.get_service('explorer') self._result_widget = FindInFilesResult() self._open_find_button = QPushButton(translations.TR_FIND + "!") self._stop_button = QPushButton(translations.TR_STOP + "!") self._clear_button = QPushButton(translations.TR_CLEAR + "!") self._replace_button = QPushButton(translations.TR_REPLACE) self._find_widget = FindInFilesDialog(self._result_widget, self) self._error_label = QLabel(translations.TR_NO_RESULTS) self._error_label.setVisible(False) #Replace Area self.replace_widget = QWidget() hbox_replace = QHBoxLayout(self.replace_widget) hbox_replace.setContentsMargins(0, 0, 0, 0) self.lbl_replace = QLabel(translations.TR_REPLACE_RESULTS_WITH) self.lbl_replace.setTextFormat(Qt.PlainText) self.replace_edit = QLineEdit() hbox_replace.addWidget(self.lbl_replace) hbox_replace.addWidget(self.replace_edit) self.replace_widget.setVisible(False) #Main Layout main_hbox = QHBoxLayout(self) #Result Layout tree_vbox = QVBoxLayout() tree_vbox.addWidget(self._result_widget) tree_vbox.addWidget(self._error_label) tree_vbox.addWidget(self.replace_widget) main_hbox.addLayout(tree_vbox) #Buttons Layout vbox = QVBoxLayout() vbox.addWidget(self._open_find_button) vbox.addWidget(self._stop_button) vbox.addWidget(self._clear_button) vbox.addSpacerItem( QSpacerItem(0, 50, QSizePolicy.Fixed, QSizePolicy.Expanding)) vbox.addWidget(self._replace_button) main_hbox.addLayout(vbox) self._open_find_button.setFocus() #signals self._open_find_button.clicked['bool'].connect(self.open) self._stop_button.clicked['bool'].connect(self._find_stop) self._clear_button.clicked['bool'].connect(self._clear_results) self._result_widget.itemActivated['QTreeWidgetItem*', int].connect(self._go_to) self._result_widget.itemClicked['QTreeWidgetItem*', int].connect(self._go_to) self._find_widget.finished.connect(self._find_finished) self._find_widget.findStarted.connect(self._find_started) self._replace_button.clicked['bool'].connect(self._replace_results)
def __setLayout(self, bwDialog, variables): # self.variables = variables verticalLayout = QVBoxLayout() for var in variables: verticalLayout.addLayout( self.__addLineWithBandwidthParameters(var)) self.calculateButton = self.__makeCalculateButton() self.statusBar = QStatusBar() verticalLayout.addSpacerItem( QSpacerItem(20, 50, QSizePolicy.Expanding, QSizePolicy.Expanding)) verticalLayout.addWidget(self.calculateButton) verticalLayout.addWidget(self.statusBar) bwDialog.setLayout(verticalLayout)
def __init__(self, pixmap: QPixmap): QWidget.__init__(self) self.pixmap = pixmap layout = QVBoxLayout() self.icon = QLabel() layout.addSpacerItem( QSpacerItem(20, 20, QSizePolicy.Minimum, QSizePolicy.Expanding)) layout.addWidget(self.icon) layout.addSpacerItem( QSpacerItem(20, 20, QSizePolicy.Minimum, QSizePolicy.Expanding)) p = self.pixmap.scaledToHeight(250) self.icon.setPixmap(p) self.setLayout(layout)
def __init__(self, parent): super(FindInFilesWidget, self).__init__(parent) self._main_container = IDE.get_service('main_container') self._explorer_container = IDE.get_service('explorer') self._result_widget = FindInFilesResult() self._open_find_button = QPushButton(translations.TR_FIND + "!") self._stop_button = QPushButton(translations.TR_STOP + "!") self._clear_button = QPushButton(translations.TR_CLEAR + "!") self._replace_button = QPushButton(translations.TR_REPLACE) self._find_widget = FindInFilesDialog(self._result_widget, self) self._error_label = QLabel(translations.TR_NO_RESULTS) self._error_label.setVisible(False) #Replace Area self.replace_widget = QWidget() hbox_replace = QHBoxLayout(self.replace_widget) hbox_replace.setContentsMargins(0, 0, 0, 0) self.lbl_replace = QLabel(translations.TR_REPLACE_RESULTS_WITH) self.lbl_replace.setTextFormat(Qt.PlainText) self.replace_edit = QLineEdit() hbox_replace.addWidget(self.lbl_replace) hbox_replace.addWidget(self.replace_edit) self.replace_widget.setVisible(False) #Main Layout main_hbox = QHBoxLayout(self) #Result Layout tree_vbox = QVBoxLayout() tree_vbox.addWidget(self._result_widget) tree_vbox.addWidget(self._error_label) tree_vbox.addWidget(self.replace_widget) main_hbox.addLayout(tree_vbox) #Buttons Layout vbox = QVBoxLayout() vbox.addWidget(self._open_find_button) vbox.addWidget(self._stop_button) vbox.addWidget(self._clear_button) vbox.addSpacerItem(QSpacerItem(0, 50, QSizePolicy.Fixed, QSizePolicy.Expanding)) vbox.addWidget(self._replace_button) main_hbox.addLayout(vbox) self._open_find_button.setFocus() #signals self._open_find_button.clicked['bool'].connect(self.open) self._stop_button.clicked['bool'].connect(self._find_stop) self._clear_button.clicked['bool'].connect(self._clear_results) self._result_widget.itemActivated['QTreeWidgetItem*', int].connect(self._go_to) self._result_widget.itemClicked['QTreeWidgetItem*', int].connect(self._go_to) self._find_widget.finished.connect(self._find_finished) self._find_widget.findStarted.connect(self._find_started) self._replace_button.clicked['bool'].connect(self._replace_results)
class VistaManutenzione(QWidget): def __init__(self, manutenzione, salva_dati, aggiorna): super(VistaManutenzione, self).__init__() # Attributi self.salva_dati = salva_dati self.aggiorna_lista = aggiorna self.controller_manutenzione = ControllerManutenzione(manutenzione) self.layout_orizzontale = QHBoxLayout() self.layout_verticale = QVBoxLayout() self.setFixedSize(550, 280) # Visualizzazione manutenzione self.label = QLabel(self.controller_manutenzione.visualizza_manutenzione()) label = self.aggiorna() # Creazione bottoni bottone = QPushButton("Chiudi") bottone.clicked.connect(self.call_chiudi) bottone1 = QPushButton("Effettua manutenzione") bottone1.clicked.connect(self.call_effettua) # Settaggio layout self.layout_verticale.addWidget(label) self.layout_verticale.addSpacerItem(QSpacerItem(150, 0, QSizePolicy.Fixed, QSizePolicy.Fixed)) self.layout_orizzontale.addWidget(bottone) self.layout_orizzontale.addWidget(bottone1) self.layout_verticale.addLayout(self.layout_orizzontale) # Layout totale self.setLayout(self.layout_verticale) self.setWindowTitle("Informazioni manutenzione") # Metodo per chiudere la finestra corrente def call_chiudi(self): self.close() # Metodo che aggiorna la finestra def aggiorna(self): self.label.setFont(QFont('Times New Roman', 20)) self.label.setAlignment(Qt.AlignCenter) return self.label # Metodo che permette di effettuare una manutenzione, aggiorna la lista e salva i dati def call_effettua(self): self.controller_manutenzione.effettua_manutenzione() self.aggiorna() self.aggiorna_lista() self.salva_dati() self.close()
def initAppletDrawerUi(self): self._drawer = QWidget(parent=self) serverLabel = QLabel("Server:") self.serverTextField = QLineEdit() self.serverTextField.setMaximumSize(QSize(250, 30)) self.serverTextField.setText(self.DEFAULT_SERVER) portLabel = QLabel("Port:") self.portTextField = QLineEdit() self.portTextField.setMaximumSize(QSize(50, 30)) self.portTextField.setText(self.DEFAULT_PORT) usernameLabel = QLabel("Username:"******"") passwordLabel = QLabel("Password:"******"") self.connectionStatus = QLabel("Status: No connection") self.okButton = QPushButton("Connect") self.okButton.clicked.connect(self.accept) self.okButton.setMaximumSize(QSize(100, 30)) # Add widget to a layout layout = QVBoxLayout() layout.setSpacing(0) layout.addWidget(serverLabel) layout.addWidget(self.serverTextField) layout.addWidget(portLabel) layout.addWidget(self.portTextField) layout.addWidget(usernameLabel) layout.addWidget(self.usernameTextField) layout.addWidget(passwordLabel) layout.addWidget(self.passwordTextField) # layout.addWidget(self.okButton, 0, Qt.AlignCenter) layout.addWidget(self.okButton) layout.addSpacing(10) layout.addWidget(self.connectionStatus) layout.addSpacerItem(QSpacerItem(0, 0, vPolicy=QSizePolicy.Expanding)) # Apply layout to the drawer self._drawer.setLayout(layout)
def show_pulsantiera(self): # Layout interni utilizzati per l'allineamento dei tre pulsanti layout_pulsanti = QVBoxLayout() # Configurazione del pulsante Apri pulsante_apri = self.pulsante("Apri", self.manutenzione_selezionata) layout_pulsanti.addWidget(pulsante_apri) # Configurazione del pulsante Indietro pulsante_indietro = self.pulsante("Indietro", self.indietro) layout_pulsanti.addWidget(pulsante_indietro) # Inserimento e allineamento dei tre pulsanti del layout globale layout_pulsanti.addSpacerItem(QSpacerItem(0, 50)) self.layout_orizzontale.addLayout(layout_pulsanti)
def __init__(self): super().__init__() self.signal.connect(self.slot) self.create_variable_thread = None main_layout = QVBoxLayout() main_layout.addWidget(QLabel("Label encoder will encode the label to numbers")) variable_layout = QHBoxLayout() variable_layout.addWidget(QLabel("Object name for label encoder: ")) self.variable_name = QLineEdit() variable_layout.addWidget(self.variable_name) main_layout.addLayout(variable_layout) create_variable = QPushButton("CREATE VARIABLE") create_variable.clicked.connect(self.create_variable_clicked) main_layout.addWidget(create_variable) main_layout.addSpacerItem(QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding)) self.setLayout(main_layout)
class SettingsPage(QWidget): """Settings page for Autosave plugi""" def __init__(self, parent): QWidget.__init__(self, parent) text = """ <h2>Autosave</h2> <p> The Autosave plugin saves your files, if Enki looses focus.</p> <p></p>""" self._label = QLabel(text, self) self.checkbox = QCheckBox('Enable Autosave') self._layout = QVBoxLayout(self) self._layout.addWidget(self._label) self._layout.addWidget(self.checkbox) self._layout.addSpacerItem( QSpacerItem(0, 0, QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding))
def createGUI(): from PyQt5.QtWidgets import QApplication \ , QWidget \ , QPushButton \ , QVBoxLayout \ , QSpacerItem app = QApplication([]) app.setApplicationName("GUI for the DllVersionChecker") window = QWidget() layout = QVBoxLayout() layout.addWidget(QPushButton("Select directory to check")) spacer = QSpacerItem(400, 1) # else it shrinks to minimum width layout.addSpacerItem(spacer) window.setLayout(layout) window.show() app.exec()
def show_pulsantiera(self): # Layout interni utilizzati per l'allineamento dei tre pulsanti layout_pulsanti = QVBoxLayout() # Configurazione del pulsante Apri layout_pulsanti.addWidget(self.pulsante("Apri", self.dipendente_selezionato)) layout_pulsanti.addSpacerItem(QSpacerItem(0, 50)) # Configurazione del pulsante Aggiungi Dipendente layout_pulsanti.addWidget(self.pulsante("Aggiungi\nDipendente", self.call_aggiungi_dipendente)) layout_pulsanti.addSpacerItem(QSpacerItem(0, 50)) # Configurazione del pulsante Indietro layout_pulsanti.addWidget(self.pulsante("Indietro", self.indietro)) # Inserimento dei tre pulsanti del layout globale self.layout_orizzontale.addLayout(layout_pulsanti)
class SettingsPage(QWidget): """Settings page for OpenTerm plugin """ def __init__(self, parent, autodetectedCommand): QWidget.__init__(self, parent) text = "<html>Terminal emulator command.<br/>" + \ "Leave empty to autodetect.<br/>" + \ "Autodetected value is <i>{}</i></html>".format(autodetectedCommand) self._label = QLabel(text, self) self.edit = QLineEdit(self) self._vLayout = QVBoxLayout(self) self._vLayout.addWidget(self._label) self._vLayout.addWidget(self.edit) self._vLayout.addSpacerItem(QSpacerItem(0, 0, QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding))
class ElgamalKeygen(BaseKeygen): def __init__(self, parent: QWidget = None): super().__init__(parent) self.setup_ui() def setup_ui(self): self.p_value = EditWithButton('p value', 'Randomize') self.g_value = EditWithButton('g value', 'Randomize') self.x_value = EditWithButton('x value', 'Randomize') self.spacer = QSpacerItem(10, 10, QSizePolicy.Expanding, QSizePolicy.Expanding) self.layout = QVBoxLayout() self.layout.addWidget(self.p_value) self.layout.addWidget(self.g_value) self.layout.addWidget(self.x_value) self.layout.addSpacerItem(self.spacer) self.setLayout(self.layout) self.p_value.btn_random.clicked.connect(self.randomize_prime) self.g_value.btn_random.clicked.connect(lambda: self.randomize_number(is_g=True)) self.x_value.btn_random.clicked.connect(lambda: self.randomize_number(is_g=False)) def randomize_prime(self): random_prime = generate_prime_number(12) self.p_value.line_edit.setText(str(random_prime)) def randomize_number(self, is_g: bool): try: p = int(self.p_value.line_edit.text()) if is_prime(p): random_number = generate_random_number(1, p - 1) if is_g: self.g_value.line_edit.setText(str(random_number)) else: self.x_value.line_edit.setText(str(random_number)) except: DialogWindow('Invalid', 'p value must be a prime number').exec_() def build_params(self): p = int(self.p_value.line_edit.text()) g = int(self.g_value.line_edit.text()) x = int(self.x_value.line_edit.text()) return [p, g, x]
class VistaRichiestaGiorni(QWidget): def __init__(self, controller_parcheggi, aggiorna): super(VistaRichiestaGiorni, self).__init__() # Controller della gestione parcheggi importante per effettuare le varie funzioni self.controller_parcheggi = controller_parcheggi # Funzione di aggiornamento della vista precedente self.aggiorna = aggiorna # Layout usato per visualizzare e allineare l'intera vista self.layout_verticale = QVBoxLayout() self.setFixedSize(400, 300) # Descrizione della finestra per scegliere per quanti giorni prenotare label = QLabel("NUMERO GIORNI DA PRENOTARE:") label.setFont(QFont('Times New Roman', 10)) label.setSizePolicy(300, 300) # Configurazione della SpinBox self.giorni = QSpinBox(self) self.giorni.setFont(QFont('Times New Roman', 20)) self.giorni.setAlignment(Qt.AlignCenter) self.giorni.setFixedSize(100, 50) self.giorni.lineEdit().setReadOnly(True) self.giorni.setRange(1, 5) # Creazione e configurazione del bottone prenota bottone = QPushButton("Prenota") bottone.clicked.connect(self.call_prenota) # Configurazione finale del layout totale self.layout_verticale.addWidget(label) self.layout_verticale.addSpacerItem( QSpacerItem(150, 0, QSizePolicy.Fixed, QSizePolicy.Fixed)) self.layout_verticale.addWidget(self.giorni) self.layout_verticale.addWidget(bottone) self.setLayout(self.layout_verticale) self.setWindowTitle('Giorni') # Metodo per effettuare la prenotazione def call_prenota(self): val = self.giorni.value() risultato = self.controller_parcheggi.prenota_parcheggio(val) QMessageBox.information(self, "Esito", risultato, QMessageBox.Ok, QMessageBox.Ok) self.aggiorna() self.close()
def _draw_article(self, layout, article: Article) -> QWidget: article_widget = QFrame() article_widget.setMinimumSize(400, 55) article_widget.setMaximumSize(400, 55) article_widget.setStyleSheet( "QFrame {background-color: rgb(200,200,200);}") article_insides = QHBoxLayout() article_widget.setLayout(article_insides) title_and_url_layout = QVBoxLayout() title = QLabel(cutoff_string(article.name, 50)) title.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignTop) title.setMaximumSize(270, 20) title.setMinimumSize(270, 20) title_and_url_layout.addWidget(title) url = QLabel(cutoff_string(article.url, 50)) url.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignBottom) url.setMaximumSize(270, 20) url.setMinimumSize(270, 20) title_and_url_layout.addWidget(url) title_and_url_layout.addSpacerItem( QSpacerItem(40, 40, QSizePolicy.MinimumExpanding)) reading_time_layout = QVBoxLayout() add_spacer(reading_time_layout) read_time = QLabel("{} minutes".format(article.reading_time)) read_time.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTop) read_time.setMaximumSize(100, 15) read_time.setMinimumSize(100, 15) reading_time_layout.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTop) reading_time_layout.addWidget(read_time) reading_time_layout.addSpacerItem( QSpacerItem(1, 40, QSizePolicy.MinimumExpanding)) article_insides.addLayout(title_and_url_layout) article_insides.addLayout(reading_time_layout) layout.addWidget(article_widget) return article_widget
def initAppletDrawerUi(self): # Load the ui file (find it in our own directory) localDir = os.path.split(__file__)[0] self._drawer = uic.loadUi(localDir+"/drawer.ui") # Init threshold widget self.thresholdWidget = ThresholdingWidget(self) self.thresholdWidget.valueChanged.connect( self.apply_gui_settings_to_operator ) # Add widget to a layout layout = QVBoxLayout() layout.setSpacing(0) layout.addWidget( self.thresholdWidget ) layout.addSpacerItem( QSpacerItem(0,0,vPolicy=QSizePolicy.Expanding) ) # Apply layout to the drawer self._drawer.setLayout( layout ) # Initialize the gui with the operator's current values self.apply_operator_settings_to_gui()
def initAppletDrawerUi(self): training_controls = EdgeTrainingGui.createDrawerControls(self) training_controls.layout().setContentsMargins(5,0,5,0) training_layout = QVBoxLayout() training_layout.addWidget( training_controls ) training_layout.setContentsMargins(0,15,0,0) training_box = QGroupBox( "Training", parent=self ) training_box.setLayout(training_layout) training_box.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) multicut_controls = MulticutGuiMixin.createDrawerControls(self) multicut_controls.layout().setContentsMargins(5,0,5,0) multicut_layout = QVBoxLayout() multicut_layout.addWidget( multicut_controls ) multicut_layout.setContentsMargins(0,15,0,0) multicut_box = QGroupBox( "Multicut", parent=self ) multicut_box.setLayout(multicut_layout) multicut_box.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) multicut_box.setEnabled(False) op = self.topLevelOperatorView multicut_required_slots = ( op.Superpixels, op.Rag, op.EdgeProbabilities, op.EdgeProbabilitiesDict, ) self.__cleanup_fns.append(guiutil.enable_when_ready(multicut_box, multicut_required_slots)) drawer_layout = QVBoxLayout() drawer_layout.addWidget(training_box) drawer_layout.addWidget(multicut_box) drawer_layout.setSpacing(2) drawer_layout.setContentsMargins(5,5,5,5) drawer_layout.addSpacerItem( QSpacerItem(0, 10, QSizePolicy.Minimum, QSizePolicy.Expanding) ) self._drawer = QWidget(parent=self) self._drawer.setLayout(drawer_layout)
def __init__(self, parent): super(ManualInstallWidget, self).__init__() self._parent = parent vbox = QVBoxLayout(self) form = QFormLayout() self._txtName = QLineEdit() self._txtName.setPlaceholderText('my_plugin') self._txtVersion = QLineEdit() self._txtVersion.setPlaceholderText('0.1') form.addRow(translations.TR_PROJECT_NAME, self._txtName) form.addRow(translations.TR_VERSION, self._txtVersion) vbox.addLayout(form) hPath = QHBoxLayout() self._txtFilePath = QLineEdit() self._txtFilePath.setPlaceholderText(os.path.join( os.path.expanduser('~'), 'full', 'path', 'to', 'plugin.zip')) self._btnFilePath = QPushButton(QIcon(":img/open"), '') self.completer, self.dirs = QCompleter(self), QDirModel(self) self.dirs.setFilter(QDir.AllEntries | QDir.NoDotAndDotDot) self.completer.setModel(self.dirs) self._txtFilePath.setCompleter(self.completer) hPath.addWidget(QLabel(translations.TR_FILENAME)) hPath.addWidget(self._txtFilePath) hPath.addWidget(self._btnFilePath) vbox.addLayout(hPath) vbox.addSpacerItem(QSpacerItem(0, 1, QSizePolicy.Expanding, QSizePolicy.Expanding)) hbox = QHBoxLayout() hbox.addSpacerItem(QSpacerItem(1, 0, QSizePolicy.Expanding)) self._btnInstall = QPushButton(translations.TR_INSTALL) hbox.addWidget(self._btnInstall) vbox.addLayout(hbox) #Signals self._btnFilePath.clicked['bool'].connect(self._load_plugin_path) self._btnInstall.clicked['bool'].connect(self.install_plugin)
def display_content(self): # layout_main = QVBoxLayout() layout_main.setAlignment(Qt.AlignCenter) self.setLayout(layout_main) self.layouts.append(layout_main) # fonts = QFontDatabase() fonts.addApplicationFont('Fonts/Raleway/Raleway-ExtraLight.ttf') fonts.addApplicationFont('Fonts/OpenSans/OpenSans-Light.ttf') # title = QLabel("Eight Puzzle") title.setStyleSheet('font-size: 52px; color: #CECFD4;') title.setFont(QFont('Raleway')) layout_main.addWidget(title) layout_main.addSpacerItem(QSpacerItem(0, 12)) # layout_tiles = QGridLayout() layout_tiles.setAlignment(Qt.AlignCenter) layout_main.addLayout(layout_tiles) for index in range(9): tile = QPushButton(str(self.puzzle.state[index])) tile.setStyleSheet('background-color: #879AA4;' 'color: #CECFD4; font-size: 32px;') tile.setFont(QFont('Open Sans')) tile.setFixedSize(75, 75) tile.setEnabled(False) tile.setFocusPolicy(Qt.NoFocus) layout_tiles.addWidget(tile, index / 3, index % 3) if self.puzzle.state[index] is '0': tile.setVisible(False) self.tiles.append(tile) self.layouts.append(layout_tiles) layout_main.addSpacerItem(QSpacerItem(0, 25)) # layout_buttons = QGridLayout() layout_buttons.setAlignment(Qt.AlignCenter) layout_main.addLayout(layout_buttons) for index in range(3): button = QPushButton(['Shuffle', 'Solve', 'Quit'][index]) button.setStyleSheet('background-color: #CECFD4;' 'color: #363B57; font-size: 18px;') button.setFont(QFont('Raleway')) button.setFixedSize(90, 40) button.setFocusPolicy(Qt.NoFocus) layout_buttons.addWidget(button, 0, index) self.buttons.append(button) self.layouts.append(layout_buttons) layout_main.addSpacerItem(QSpacerItem(0, 10))
def initAppletDrawerUi(self): """ Overridden from base class (LayerViewerGui) """ op = self.topLevelOperatorView def configure_update_handlers( qt_signal, op_slot ): qt_signal.connect( self.configure_operator_from_gui ) op_slot.notifyDirty( self.configure_gui_from_operator ) self.__cleanup_fns.append( partial( op_slot.unregisterDirty, self.configure_gui_from_operator ) ) def control_layout( label_text, widget ): row_layout = QHBoxLayout() row_layout.addWidget( QLabel(label_text) ) row_layout.addSpacerItem( QSpacerItem(10, 0, QSizePolicy.Expanding) ) row_layout.addWidget(widget) return row_layout drawer_layout = QVBoxLayout() channel_button = QPushButton() self.channel_menu = QMenu(self) # Must retain menus (in self) or else they get deleted. channel_button.setMenu(self.channel_menu) channel_button.clicked.connect(channel_button.showMenu) def populate_channel_menu(*args): if sip.isdeleted(channel_button): return self.channel_menu.clear() self.channel_actions = [] for ch in range(op.Input.meta.getTaggedShape()['c']): action = QAction("Channel {}".format(ch), self.channel_menu) action.setCheckable(True) self.channel_menu.addAction(action) self.channel_actions.append(action) configure_update_handlers( action.toggled, op.ChannelSelections ) populate_channel_menu() op.Input.notifyMetaChanged( populate_channel_menu ) self.__cleanup_fns.append( partial( op.Input.unregisterMetaChanged, populate_channel_menu ) ) channel_button.setToolTip("Boundary channel index in the probability map") drawer_layout.addLayout( control_layout( "Input Channel", channel_button ) ) self.channel_button = channel_button threshold_box = QDoubleSpinBox() threshold_box.setDecimals(2) threshold_box.setMinimum(0.00) threshold_box.setMaximum(1.0) threshold_box.setSingleStep(0.1) configure_update_handlers( threshold_box.valueChanged, op.Pmin ) threshold_box.setToolTip("Boundary probability threshold") drawer_layout.addLayout( control_layout( "Threshold", threshold_box ) ) self.threshold_box = threshold_box membrane_size_box = QSpinBox() membrane_size_box.setMinimum(0) membrane_size_box.setMaximum(1000000) configure_update_handlers( membrane_size_box.valueChanged, op.MinMembraneSize ) membrane_size_box.setToolTip("Size filter for boundary pieces, in pixels") drawer_layout.addLayout( control_layout( "Min Boundary Size", membrane_size_box ) ) self.membrane_size_box = membrane_size_box seed_presmoothing_box = QDoubleSpinBox() seed_presmoothing_box.setDecimals(1) seed_presmoothing_box.setMinimum(0.0) seed_presmoothing_box.setMaximum(10.0) seed_presmoothing_box.setSingleStep(0.1) configure_update_handlers( seed_presmoothing_box.valueChanged, op.SigmaMinima ) seed_presmoothing_box.setToolTip("Smooth the distance transform map with this sigma") drawer_layout.addLayout( control_layout( "Presmooth before Seeds", seed_presmoothing_box ) ) self.seed_presmoothing_box = seed_presmoothing_box seed_method_combo = QComboBox() seed_method_combo.addItem("Connected") seed_method_combo.addItem("Clustered") configure_update_handlers( seed_method_combo.currentIndexChanged, op.GroupSeeds ) seed_method_combo.setToolTip("Connected: combine directly adjacent pixels into seeds (more superpixels). Clustered: group pixels into seeds by distance heuristic (less superpixels)") drawer_layout.addLayout( control_layout( "Seed Labeling", seed_method_combo ) ) self.seed_method_combo = seed_method_combo superpixel_size_box = QSpinBox() superpixel_size_box.setMinimum(0) superpixel_size_box.setMaximum(1000000) configure_update_handlers( superpixel_size_box.valueChanged, op.MinSegmentSize ) superpixel_size_box.setToolTip("Minimal size of a superpixel") drawer_layout.addLayout( control_layout( "Min Superpixel Size", superpixel_size_box ) ) self.superpixel_size_box = superpixel_size_box preserve_pmaps_box = QCheckBox() configure_update_handlers( preserve_pmaps_box.toggled, op.PreserveMembranePmaps ) preserve_pmaps_box.setToolTip("Preserve thin structures. Use that option when some of your foreground objects have long and thin parts") drawer_layout.addLayout( control_layout( "Preserve Thin Structures", preserve_pmaps_box ) ) self.preserve_pmaps_box = preserve_pmaps_box enable_debug_box = QCheckBox() configure_update_handlers( enable_debug_box.toggled, op.EnableDebugOutputs ) drawer_layout.addLayout( control_layout( "Show Debug Layers", enable_debug_box ) ) self.enable_debug_box = enable_debug_box op.Superpixels.notifyReady(self.configure_gui_from_operator) op.Superpixels.notifyUnready(self.configure_gui_from_operator) self.__cleanup_fns.append( partial( op.Superpixels.unregisterReady, self.configure_gui_from_operator ) ) self.__cleanup_fns.append( partial( op.Superpixels.unregisterUnready, self.configure_gui_from_operator ) ) self.update_ws_button = QPushButton("Update Watershed", clicked=self.onUpdateWatershedsButton) drawer_layout.addWidget( self.update_ws_button ) drawer_layout.setSpacing(0) drawer_layout.addSpacerItem( QSpacerItem(0, 10, QSizePolicy.Minimum, QSizePolicy.Expanding) ) # Finally, the whole drawer widget drawer = QWidget(parent=self) drawer.setLayout(drawer_layout) # Save these members for later use self._drawer = drawer # Initialize everything with the operator's initial values self.configure_gui_from_operator()
def createDrawerControls(self): """ This is a separate function from initAppletDrawer() so that it can be called and used within another applet (this class is a mixin). """ op = self.__topLevelOperatorView def configure_update_handlers( qt_signal, op_slot ): qt_signal.connect( self.configure_operator_from_gui ) op_slot.notifyDirty( self.configure_gui_from_operator ) self.__cleanup_fns.append( partial( op_slot.unregisterDirty, self.configure_gui_from_operator ) ) def control_layout( label_text, widget ): row_layout = QHBoxLayout() row_layout.addWidget( QLabel(label_text) ) row_layout.addSpacerItem( QSpacerItem(10, 0, QSizePolicy.Expanding) ) row_layout.addWidget(widget) return row_layout drawer_layout = QVBoxLayout() drawer_layout.setSpacing(1) # Beta beta_box = QDoubleSpinBox(decimals=2, minimum=0.01, maximum=0.99, singleStep=0.1, toolTip="Bias parameter for the multicut optimization.") configure_update_handlers( beta_box.valueChanged, op.Beta ) beta_layout = control_layout("Beta", beta_box) drawer_layout.addLayout(beta_layout) self.beta_box = beta_box # Solver solver_name_combo = QComboBox( toolTip="Multicut optimization technique. Available solvers depend on which optimizer library you have installed.") for solver_name in AVAILABLE_SOLVER_NAMES: solver_name_combo.addItem(solver_name) configure_update_handlers( solver_name_combo.currentIndexChanged, op.SolverName ) drawer_layout.addLayout( control_layout( "Solver", solver_name_combo ) ) self.solver_name_combo = solver_name_combo button_layout = QHBoxLayout() # Live Multicut Button live_multicut_button = QPushButton(text="Live Multicut", checkable=True, icon=QIcon(ilastikIcons.Play)) configure_update_handlers( live_multicut_button.toggled, op.FreezeCache ) # Extra: Auto-show the multicut edges if necessary. def auto_show_multicut_layer(checked): if checked: self.getLayerByName("Multicut Edges").visible = True live_multicut_button.toggled.connect( auto_show_multicut_layer ) button_layout.addWidget(live_multicut_button) self.live_multicut_button = live_multicut_button # Update Button update_button = QPushButton(text="Update Now", icon=QIcon(ilastikIcons.Play), clicked=self._handle_mulicut_update_clicked) button_layout.addWidget(update_button) self.update_button = update_button drawer_layout.addLayout(button_layout) # Layout drawer_layout.addSpacerItem( QSpacerItem(0, 10, QSizePolicy.Minimum, QSizePolicy.Expanding) ) # Finally, the whole drawer widget drawer = QWidget(parent=self) drawer.setLayout(drawer_layout) # Widget Shortcuts mgr = ShortcutManager() ActionInfo = ShortcutManager.ActionInfo shortcut_group = "Multicut" mgr.register( "u", ActionInfo( shortcut_group, "UpdateMulticut", "Run the multicut optimization using the current edge probabilities", update_button.click, update_button, update_button ) ) return drawer