Python qtpy.QtWidgets.QLineEdit() Examples
The following are 8
code examples of qtpy.QtWidgets.QLineEdit().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
qtpy.QtWidgets
, or try the search function
.
Example #1
Source File: qt_dims.py From napari with BSD 3-Clause "New" or "Revised" License | 6 votes |
def _resize_axis_labels(self): """When any of the labels get updated, this method updates all label widths to the width of the longest label. This keeps the sliders left-aligned and allows the full label to be visible at all times, with minimal space, without setting stretch on the layout. """ fm = QFontMetrics(QFont("", 0)) labels = self.findChildren(QLineEdit, 'axis_label') newwidth = max([fm.boundingRect(lab.text()).width() for lab in labels]) if any(self._displayed_sliders): # set maximum width to no more than 20% of slider width maxwidth = self.slider_widgets[0].width() * 0.2 newwidth = min([newwidth, maxwidth]) for labl in labels: labl.setFixedWidth(newwidth + 10)
Example #2
Source File: QLinkableWidgets.py From pylustrator with GNU General Public License v3.0 | 5 votes |
def __init__(self): """ Like a QSpinBox for number import, but without min or max range or a fixed resolution. Especially important for the limits of logarithmic plots. Attributes: send_signal : Whether to currently emit the valueChanged signal or not (to prevent the signal from being emitted when the value is set by script. valueChanged : a signal that is emitted when the value is changed by the user """ QtWidgets.QLineEdit.__init__(self) self.textChanged.connect(self.emitValueChanged)
Example #3
Source File: QLinkableWidgets.py From pylustrator with GNU General Public License v3.0 | 5 votes |
def __init__(self, layout: QtWidgets.QLayout, text: str, multiline: bool = False, horizontal: bool = True): """ a text input widget with a label. Args: layout: the layout to which to add the widget text: the label text multiline: whether the text input should be a single line or not horizontal: whether the layout should be left or above the input """ QtWidgets.QWidget.__init__(self) layout.addWidget(self) if horizontal: self.layout = QtWidgets.QHBoxLayout(self) else: self.layout = QtWidgets.QVBoxLayout(self) self.label = QtWidgets.QLabel(text) self.layout.addWidget(self.label) self.layout.setContentsMargins(0, 0, 0, 0) self.multiline = multiline if multiline: self.input1 = QtWidgets.QTextEdit() self.input1.textChanged.connect(self.valueChangeEvent) self.input1.text = self.input1.toPlainText else: self.input1 = QtWidgets.QLineEdit() self.input1.editingFinished.connect(self.valueChangeEvent) self.layout.addWidget(self.input1)
Example #4
Source File: FileRevisionWindow.py From P4VFX with MIT License | 5 votes |
def setRevisionTableColumn(self, row, column, value, icon=None, isLongText=False): value = str(value) widget = QtWidgets.QWidget() layout = QtWidgets.QHBoxLayout() layout.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignHCenter) # Use a QLineEdit to allow the text to be copied if the data is large if isLongText: textLabel = QtWidgets.QLineEdit() textLabel.setText(value) textLabel.setCursorPosition(0) textLabel.setReadOnly(True) textLabel.setStyleSheet("QLineEdit { border: none }") else: textLabel = QtWidgets.QLabel(value) textLabel.setStyleSheet("QLabel { border: none } ") # layout.setContentsMargins(4, 0, 4, 0) if icon: iconPic = QtGui.QPixmap(icon) iconPic = iconPic.scaled(16, 16) iconLabel = QtWidgets.QLabel() iconLabel.setPixmap(iconPic) layout.addWidget(iconLabel) layout.addWidget(textLabel) widget.setLayout(layout) self.tableWidget.setCellWidget(row, column, widget)
Example #5
Source File: FileRevisionWindow.py From P4VFX with MIT License | 5 votes |
def setRevisionTableColumn(self, row, column, value, icon=None, isLongText=False): value = str(value) widget = QtWidgets.QWidget() layout = QtWidgets.QHBoxLayout() layout.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignHCenter) # Use a QLineEdit to allow the text to be copied if the data is large if isLongText: textLabel = QtWidgets.QLineEdit() textLabel.setText(value) textLabel.setCursorPosition(0) textLabel.setReadOnly(True) textLabel.setStyleSheet("QLineEdit { border: none }") else: textLabel = QtWidgets.QLabel(value) textLabel.setStyleSheet("QLabel { border: none } ") # layout.setContentsMargins(4, 0, 4, 0) if icon: iconPic = QtGui.QPixmap(icon) iconPic = iconPic.scaled(16, 16) iconLabel = QtWidgets.QLabel() iconLabel.setPixmap(iconPic) layout.addWidget(iconLabel) layout.addWidget(textLabel) widget.setLayout(layout) self.tableWidget.setCellWidget(row, column, widget)
Example #6
Source File: spinbox.py From pyrpl with GNU General Public License v3.0 | 5 votes |
def make_layout(self): self.lay = QtWidgets.QHBoxLayout() self.lay.setContentsMargins(0,0,0,0) self.lay.setSpacing(0) self.setLayout(self.lay) if self.labeltext is not None: self.label = QtWidgets.QLabel(self.labeltext) self.lay.addWidget(self.label) if self.log_increment: self.up = QtWidgets.QPushButton('*') self.down = QtWidgets.QPushButton('/') else: self.up = QtWidgets.QPushButton('+') self.down = QtWidgets.QPushButton('-') self.line = QtWidgets.QLineEdit() self.line.setStyleSheet("QLineEdit { qproperty-cursorPosition: 0; }") # align text on the left # http://stackoverflow.com/questions/18662157/qt-qlineedit-widget-to-get-long-text-left-aligned self.lay.addWidget(self.down) self.lay.addWidget(self.line) self.lay.addWidget(self.up) self.up.setMaximumWidth(15) self.down.setMaximumWidth(15) self.up.pressed.connect(self.first_step) self.down.pressed.connect(self.first_step) self.up.released.connect(self.finish_step) self.down.released.connect(self.finish_step) self.line.editingFinished.connect(self.validate) self._button_up_down = False self._button_down_down = False # keyboard interface
Example #7
Source File: attribute_widgets.py From pyrpl with GNU General Public License v3.0 | 5 votes |
def _make_widget(self): self.widget = QtWidgets.QLineEdit() self.widget.setMaximumWidth(200) self.widget.textChanged.connect(self.write_widget_value_to_attribute)
Example #8
Source File: lockbox_widget.py From pyrpl with GNU General Public License v3.0 | 4 votes |
def __init__(self, parent): super(AnalogTfDialog, self).__init__(parent) self.parent = parent self.module = self.parent.module self.setWindowTitle("Analog transfer function for output %s" % self.module.name) self.lay_v = QtWidgets.QVBoxLayout(self) self.lay_h = QtWidgets.QHBoxLayout() self.ok = QtWidgets.QPushButton('Ok') self.lay_h.addWidget(self.ok) self.ok.clicked.connect(self.validate) self.cancel = QtWidgets.QPushButton('Cancel') self.lay_h.addWidget(self.cancel) self.group = QtWidgets.QButtonGroup() self.flat = QtWidgets.QRadioButton("Flat response") self.filter = QtWidgets.QRadioButton('Analog low-pass filter (as in "Pid control/assisted design/actuator cut-off")') self.curve = QtWidgets.QRadioButton("User-defined curve") self.group.addButton(self.flat) self.group.addButton(self.filter) self.group.addButton(self.curve) self.lay_v.addWidget(self.flat) self.lay_v.addWidget(self.filter) self.lay_v.addWidget(self.curve) self.label = QtWidgets.QLabel("Curve #") self.line = QtWidgets.QLineEdit("coucou") self.lay_line = QtWidgets.QHBoxLayout() self.lay_v.addLayout(self.lay_line) self.lay_v.addWidget(self.line) self.lay_line.addStretch(1) self.lay_line.addWidget(self.label) self.lay_line.addWidget(self.line, stretch=10) self.lay_v.addSpacing(20) self.lay_v.addLayout(self.lay_h) self.curve.toggled.connect(self.change_visibility) {'flat':self.flat, 'filter':self.filter, 'curve':self.curve}[self.module.tf_type].setChecked(True) self.line.setText(str(self.module.tf_curve)) self.line.textEdited.connect(lambda: self.line.setStyleSheet("")) self.cancel.clicked.connect(self.reject) self.curve_id = None self.res = None