本文整理汇总了Python中qtpy.QtWidgets.QLineEdit方法的典型用法代码示例。如果您正苦于以下问题:Python QtWidgets.QLineEdit方法的具体用法?Python QtWidgets.QLineEdit怎么用?Python QtWidgets.QLineEdit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qtpy.QtWidgets
的用法示例。
在下文中一共展示了QtWidgets.QLineEdit方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _resize_axis_labels
# 需要导入模块: from qtpy import QtWidgets [as 别名]
# 或者: from qtpy.QtWidgets import QLineEdit [as 别名]
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)
示例2: __init__
# 需要导入模块: from qtpy import QtWidgets [as 别名]
# 或者: from qtpy.QtWidgets import QLineEdit [as 别名]
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)
示例3: setRevisionTableColumn
# 需要导入模块: from qtpy import QtWidgets [as 别名]
# 或者: from qtpy.QtWidgets import QLineEdit [as 别名]
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)
示例4: make_layout
# 需要导入模块: from qtpy import QtWidgets [as 别名]
# 或者: from qtpy.QtWidgets import QLineEdit [as 别名]
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
示例5: _make_widget
# 需要导入模块: from qtpy import QtWidgets [as 别名]
# 或者: from qtpy.QtWidgets import QLineEdit [as 别名]
def _make_widget(self):
self.widget = QtWidgets.QLineEdit()
self.widget.setMaximumWidth(200)
self.widget.textChanged.connect(self.write_widget_value_to_attribute)
示例6: __init__
# 需要导入模块: from qtpy import QtWidgets [as 别名]
# 或者: from qtpy.QtWidgets import QLineEdit [as 别名]
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