def createLineEdit(self, variable_name, variable_value, variable_type): spinner = QLineEdit() spinner.setMinimumWidth(250) if variable_value == "None": spinner.setText("") else: spinner.setText(variable_value) spinner.editingFinished.connect( partial(self.valueChanged, variable_name, variable_type, spinner)) return spinner
def __init__(self, title="Title", description="Description", unique_names=None, choose_from_list=False): QDialog.__init__(self) self.setModal(True) self.setWindowTitle(title) # self.setMinimumWidth(250) # self.setMinimumHeight(150) if unique_names is None: unique_names = [] self.unique_names = unique_names self.choose_from_list = choose_from_list self.layout = QFormLayout() self.layout.setSizeConstraint(QLayout.SetFixedSize) label = QLabel(description) label.setAlignment(Qt.AlignHCenter) self.layout.addRow(self.createSpace(5)) self.layout.addRow(label) self.layout.addRow(self.createSpace(10)) buttons = QDialogButtonBox( QDialogButtonBox.Ok | QDialogButtonBox.Cancel, Qt.Horizontal, self) self.ok_button = buttons.button(QDialogButtonBox.Ok) self.ok_button.setEnabled(False) if choose_from_list: self.param_name_combo = QComboBox() self.param_name.currentIndexChanged.connect(self.validateChoice) for item in unique_names: self.param_name_combo.addItem(item) self.layout.addRow("Job:", self.param_name_combo) else: self.param_name = QLineEdit(self) self.param_name.setFocus() self.param_name.textChanged.connect(self.validateName) self.validColor = self.param_name.palette().color( self.param_name.backgroundRole()) self.layout.addRow("Name:", self.param_name) self.layout.addRow(self.createSpace(10)) self.layout.addRow(buttons) buttons.accepted.connect(self.accept) buttons.rejected.connect(self.reject) self.setLayout(self.layout)
def __init__(self, model, help_link=""): """ :type model: ert_gui.ertwidgets.models.path_model.PathModel :param help_link: str """ QWidget.__init__(self) addHelpToWidget(self, help_link) self._validation_support = ValidationSupport(self) self._editing = True layout = QHBoxLayout() layout.setContentsMargins(0, 0, 0, 0) self._path_line = QLineEdit() self._path_line.setMinimumWidth(250) layout.addWidget(self._path_line) dialog_button = QToolButton(self) dialog_button.setIcon(resourceIcon("ide/small/folder")) dialog_button.setIconSize(QSize(16, 16)) dialog_button.clicked.connect(self.selectPath) layout.addWidget(dialog_button) self.valid_color = self._path_line.palette().color( self._path_line.backgroundRole()) self._path_line.setText(os.getcwd()) self._editing = False self._model = model self._model.valueChanged.connect(self.getPathFromModel) self._path_line.editingFinished.connect(self.validatePath) self._path_line.editingFinished.connect(self.contentsChanged) self._path_line.textChanged.connect(self.validatePath) self.setLayout(layout) self.getPathFromModel()