本文整理汇总了Python中qtpy.QtWidgets.QLineEdit类的典型用法代码示例。如果您正苦于以下问题:Python QLineEdit类的具体用法?Python QLineEdit怎么用?Python QLineEdit使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QLineEdit类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _ask_overwrite
def _ask_overwrite(self):
msg = QDialog()
msg.setWindowTitle('Load overwrite')
layout = QGridLayout()
layout.addWidget(QLabel('Instrument %s already exists in memory. Overwrite this?'), 0, 0, 1, -1)
buttons = [QPushButton(label) for label in ['Load and overwrite', 'Cancel Load', 'Load and rename to']]
locations = [[1, 0], [1, 1], [2, 0]]
self.overwrite_flag = 1
def overwriteCB(idx):
self.overwrite_flag = idx
msg.accept()
for idx, button in enumerate(buttons):
button.clicked.connect(lambda _, idx=idx: overwriteCB(idx))
layout.addWidget(button, locations[idx][0], locations[idx][1])
newname = QLineEdit()
newname.editingFinished.connect(lambda: overwriteCB(2))
layout.addWidget(newname, 2, 1)
msg.setLayout(layout)
msg.exec_()
newname = str(newname.text())
if not newname or newname in self.instruments:
self.errormessage('Invalid instrument name. Cancelling load.')
self.overwrite_flag = 1
return self.overwrite_flag, newname
开发者ID:mantidproject,项目名称:mantid,代码行数:25,代码来源:PyChopGui.py
示例2: make_advanced_dialog
def make_advanced_dialog(ui, algorithms=None):
diag = ExToolWindow(ui)
diag.setWindowTitle("Decomposition parameters")
vbox = QtWidgets.QVBoxLayout()
if algorithms:
lbl_algo = QLabel(tr("Choose algorithm:"))
cbo_algo = QLineEdit.QComboBox()
cbo_algo.addItems(algorithms)
vbox.addWidget(lbl_algo)
vbox.addWidget(cbo_algo)
else:
lbl_comp = QLabel(tr(
"Enter a comma-separated list of component numbers to use for "
"the model:"))
txt_comp = QLineEdit()
vbox.addWidget(lbl_comp)
vbox.addWidget(txt_comp)
btns = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel,
QtCore.Qt.Horizontal)
btns.accepted.connect(diag.accept)
btns.rejected.connect(diag.reject)
vbox.addWidget(btns)
diag.setLayout(vbox)
diag.algorithm = lambda: cbo_algo.currentText()
diag.components = lambda: [int(s) for s in txt_comp.text().split(',')]
return diag
开发者ID:hyperspy,项目名称:hyperspyUI,代码行数:32,代码来源:mva.py
示例3: SearchInputWidget
class SearchInputWidget(QWidget):
"""
Input fields for specifying searches on SearchResultsModel
"""
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.search_bar = QLineEdit()
search_bar_layout = QHBoxLayout()
search_bar_layout.addWidget(QLabel('Custom Query:'))
search_bar_layout.addWidget(self.search_bar)
mongo_query_help_button = QPushButton()
mongo_query_help_button.setText('?')
search_bar_layout.addWidget(mongo_query_help_button)
mongo_query_help_button.clicked.connect(self.show_mongo_query_help)
self.since_widget = QDateTimeEdit()
self.since_widget.setCalendarPopup(True)
self.since_widget.setDisplayFormat('yyyy-MM-dd HH:mm')
since_layout = QHBoxLayout()
since_layout.addWidget(QLabel('Since:'))
since_layout.addWidget(self.since_widget)
self.until_widget = QDateTimeEdit()
self.until_widget.setCalendarPopup(True)
self.until_widget.setDisplayFormat('yyyy-MM-dd HH:mm')
until_layout = QHBoxLayout()
until_layout.addWidget(QLabel('Until:'))
until_layout.addWidget(self.until_widget)
layout = QVBoxLayout()
layout.addLayout(since_layout)
layout.addLayout(until_layout)
layout.addLayout(search_bar_layout)
self.setLayout(layout)
def mark_custom_query(self, valid):
"Indicate whether the current text is a parsable query."
if valid:
stylesheet = GOOD_TEXT_INPUT
else:
stylesheet = BAD_TEXT_INPUT
self.search_bar.setStyleSheet(stylesheet)
def show_mongo_query_help(self):
"Launch a Message Box with instructions for custom queries."
msg = QMessageBox()
msg.setIcon(QMessageBox.Information)
msg.setText("For advanced search capability, enter a valid Mongo query.")
msg.setInformativeText("""
Examples:
{'plan_name': 'scan'}
{'proposal': 1234},
{'$and': ['proposal': 1234, 'sample_name': 'Ni']}
""")
msg.setWindowTitle("Custom Mongo Query")
msg.setStandardButtons(QMessageBox.Ok)
msg.exec_()
开发者ID:CJ-Wright,项目名称:bluesky-browser,代码行数:58,代码来源:search.py
示例4: keyPressEvent
def keyPressEvent(self, event):
"""
Qt override.
"""
if event.key() in [Qt.Key_Enter, Qt.Key_Return]:
self._parent.process_text()
if self._parent.is_valid():
self._parent.keyPressEvent(event)
else:
QLineEdit.keyPressEvent(self, event)
开发者ID:ShenggaoZhu,项目名称:spyder,代码行数:10,代码来源:arraybuilder.py
示例5: _make_filter_box
def _make_filter_box(self):
"""
Make the text box to filter the plots by name
:return: A QLineEdit object with placeholder text and a
clear button
"""
text_box = QLineEdit(self)
text_box.setPlaceholderText("Filter Plots")
text_box.setClearButtonEnabled(True)
return text_box
开发者ID:mantidproject,项目名称:mantid,代码行数:10,代码来源:view.py
示例6: _init_ui
def _init_ui(self):
self.slit_type_label = QLabel('Slit Type')
self.slit_type_combo = QComboBox()
self.slit_type_combo.currentIndexChanged.connect(self.update_info)
hbl1 = QHBoxLayout()
hbl1.addWidget(self.slit_type_label)
hbl1.addWidget(self.slit_type_combo)
self.slit_width_label = QLabel('Slit Width')
self.slit_width_input = QLineEdit()
self.slit_width_combo = QComboBox()
self.slit_width_units = QLabel('arcsec')
hbl2 = QHBoxLayout()
hbl2.addWidget(self.slit_width_label)
hbl2.addWidget(self.slit_width_input)
hbl2.addWidget(self.slit_width_combo)
hbl2.addWidget(self.slit_width_units)
self.slit_length_label = QLabel('Slit Length')
self.slit_length_input = QLineEdit()
self.slit_length_combo = QComboBox()
self.slit_length_units = QLabel('arcsec')
hbl3 = QHBoxLayout()
hbl3.addWidget(self.slit_length_label)
hbl3.addWidget(self.slit_length_input)
hbl3.addWidget(self.slit_length_combo)
hbl3.addWidget(self.slit_length_units)
self.okButton = QPushButton('Apply')
self.okButton.clicked.connect(self.apply)
self.okButton.setDefault(True)
self.cancelButton = QPushButton('Cancel')
self.cancelButton.clicked.connect(self.cancel)
hbl4 = QHBoxLayout()
hbl4.addWidget(self.cancelButton)
hbl4.addWidget(self.okButton)
vbl = QVBoxLayout()
vbl.addLayout(hbl1)
vbl.addLayout(hbl2)
vbl.addLayout(hbl3)
vbl.addLayout(hbl4)
self.setLayout(vbl)
self.vbl = vbl
self._load_selections()
self._populate_combo()
self.update_info(0)
self.show()
开发者ID:spacetelescope,项目名称:mosviz,代码行数:55,代码来源:slit_selection_ui.py
示例7: keyPressEvent
def keyPressEvent(self, event):
"""Capture Backspace and ESC Keypresses."""
if event.key() == Qt.Key_Escape:
if self.parent().vim_keys.visual_mode:
self.parent().vim_keys.exit_visual_mode()
self.clear()
elif event.key() == Qt.Key_Backspace:
self.setText(self.text() + "\b")
elif event.key() == Qt.Key_Return:
self.setText(self.text() + "\r")
self.parent().on_return()
else:
QLineEdit.keyPressEvent(self, event)
开发者ID:spyder-ide,项目名称:spyder.vim,代码行数:13,代码来源:vim_widget.py
示例8: __init__
def __init__(self, parent=None, init_channel=None):
QLineEdit.__init__(self, parent)
PyDMWritableWidget.__init__(self, init_channel=init_channel)
self.app = QApplication.instance()
self._display = None
self._scale = 1
self.returnPressed.connect(self.send_value)
self.unitMenu = QMenu('Convert Units', self)
self.create_unit_options()
self._display_format_type = self.DisplayFormat.Default
self._string_encoding = "utf_8"
if utilities.is_pydm_app():
self._string_encoding = self.app.get_string_encoding()
开发者ID:slaclab,项目名称:pydm,代码行数:14,代码来源:line_edit.py
示例9: __init__
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.search_bar = QLineEdit()
search_bar_layout = QHBoxLayout()
search_bar_layout.addWidget(QLabel('Custom Query:'))
search_bar_layout.addWidget(self.search_bar)
mongo_query_help_button = QPushButton()
mongo_query_help_button.setText('?')
search_bar_layout.addWidget(mongo_query_help_button)
mongo_query_help_button.clicked.connect(self.show_mongo_query_help)
self.since_widget = QDateTimeEdit()
self.since_widget.setCalendarPopup(True)
self.since_widget.setDisplayFormat('yyyy-MM-dd HH:mm')
since_layout = QHBoxLayout()
since_layout.addWidget(QLabel('Since:'))
since_layout.addWidget(self.since_widget)
self.until_widget = QDateTimeEdit()
self.until_widget.setCalendarPopup(True)
self.until_widget.setDisplayFormat('yyyy-MM-dd HH:mm')
until_layout = QHBoxLayout()
until_layout.addWidget(QLabel('Until:'))
until_layout.addWidget(self.until_widget)
layout = QVBoxLayout()
layout.addLayout(since_layout)
layout.addLayout(until_layout)
layout.addLayout(search_bar_layout)
self.setLayout(layout)
开发者ID:CJ-Wright,项目名称:bluesky-browser,代码行数:30,代码来源:search.py
示例10: __init__
def __init__(self, color, parent=None):
QHBoxLayout.__init__(self)
assert isinstance(color, QColor)
self.lineedit = QLineEdit(color.name(), parent)
self.lineedit.textChanged.connect(self.update_color)
self.addWidget(self.lineedit)
self.colorbtn = ColorButton(parent)
self.colorbtn.color = color
self.colorbtn.colorChanged.connect(self.update_text)
self.addWidget(self.colorbtn)
开发者ID:ShenggaoZhu,项目名称:spyder,代码行数:10,代码来源:formlayout.py
示例11: __init__
def __init__(self, editor_widget):
self.editor_widget = editor_widget
QLineEdit.__init__(self, editor_widget)
# Build widget
self.commandline = VimLineEdit(self)
self.commandline.textChanged.connect(self.on_text_changed)
self.commandline.returnPressed.connect(self.on_return)
self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
hlayout = QHBoxLayout()
hlayout.addWidget(QLabel("Vim:"))
hlayout.addWidget(self.commandline)
hlayout.setContentsMargins(1, 1, 1, 1)
self.setLayout(hlayout)
# Initialize available commands
self.vim_keys = VimKeys(self)
self.vim_commands = VimCommands(self)
开发者ID:Nodd,项目名称:spyder.vim,代码行数:19,代码来源:vim_widget.py
示例12: __init__
def __init__(self, presenter, plot_number, parent=None):
super(PlotNameWidget, self).__init__(parent)
self.presenter = presenter
self.plot_number = plot_number
self.mutex = QMutex()
self.line_edit = QLineEdit(self.presenter.get_plot_name_from_number(plot_number))
self.line_edit.setReadOnly(True)
self.line_edit.setFrame(False)
self.line_edit.setStyleSheet("* { background-color: rgba(0, 0, 0, 0); }")
self.line_edit.setAttribute(Qt.WA_TransparentForMouseEvents, True)
self.line_edit.editingFinished.connect(self.rename_plot)
shown_icon = get_icon('mdi.eye')
self.hide_button = QPushButton(shown_icon, "")
self.hide_button.setToolTip('Hide')
self.hide_button.setFlat(True)
self.hide_button.setMaximumWidth(self.hide_button.iconSize().width() * 5 / 3)
self.hide_button.clicked.connect(self.toggle_visibility)
rename_icon = get_icon('mdi.square-edit-outline')
self.rename_button = QPushButton(rename_icon, "")
self.rename_button.setToolTip('Rename')
self.rename_button.setFlat(True)
self.rename_button.setMaximumWidth(self.rename_button.iconSize().width() * 5 / 3)
self.rename_button.setCheckable(True)
self.rename_button.toggled.connect(self.rename_button_toggled)
close_icon = get_icon('mdi.close')
self.close_button = QPushButton(close_icon, "")
self.close_button.setToolTip('Delete')
self.close_button.setFlat(True)
self.close_button.setMaximumWidth(self.close_button.iconSize().width() * 5 / 3)
self.close_button.clicked.connect(lambda: self.close_pressed(self.plot_number))
self.layout = QHBoxLayout()
# Get rid of the top and bottom margins - the button provides
# some natural margin anyway. Get rid of right margin and
# reduce spacing to get buttons closer together.
self.layout.setContentsMargins(5, 0, 0, 0)
self.layout.setSpacing(0)
self.layout.addWidget(self.line_edit)
self.layout.addWidget(self.hide_button)
self.layout.addWidget(self.rename_button)
self.layout.addWidget(self.close_button)
self.layout.sizeHint()
self.setLayout(self.layout)
开发者ID:mantidproject,项目名称:mantid,代码行数:52,代码来源:view.py
示例13: eventFilter
def eventFilter(self, widget, event):
"""Catch clicks outside the object and ESC key press."""
if ((event.type() == QEvent.MouseButtonPress and
not self.geometry().contains(event.globalPos())) or
(event.type() == QEvent.KeyPress and
event.key() == Qt.Key_Escape)):
# Exits editing
self.hide()
self.setFocus(False)
return True
# Event is not interessant, raise to parent
return QLineEdit.eventFilter(self, widget, event)
开发者ID:rlaverde,项目名称:spyder,代码行数:13,代码来源:tabs.py
示例14: __init__
def __init__(self, editor_widget, main):
"""Main widget constructor."""
self.editor_widget = editor_widget
self.main = main
QLineEdit.__init__(self, editor_widget)
# Build widget
self.commandline = VimLineEdit(self)
self.commandline.textChanged.connect(self.on_text_changed)
self.commandline.returnPressed.connect(self.on_return)
self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
hlayout = QHBoxLayout()
hlayout.addWidget(QLabel("Vim:"))
hlayout.addWidget(self.commandline)
hlayout.setContentsMargins(5, 0, 0, 5)
self.setLayout(hlayout)
self.selection_type = (int(time()), "char")
QApplication.clipboard().dataChanged.connect(self.on_copy)
# Initialize available commands
self.vim_keys = VimKeys(self)
self.vim_commands = VimCommands(self)
开发者ID:spyder-ide,项目名称:spyder.vim,代码行数:23,代码来源:vim_widget.py
示例15: _init_ui
def _init_ui(self):
# Widgets
validator = QIntValidator()
validator.setBottom(0)
self._txt_start_channel = QLineEdit()
self._txt_start_channel.setValidator(validator)
self._txt_start_channel.setAccessibleName('Start channel')
self._txt_end_channel = QLineEdit()
self._txt_end_channel.setValidator(validator)
self._txt_end_channel.setAccessibleName("End channel")
# Layouts
layout = _ConditionWidget._init_ui(self)
layout.addRow('<i>Start channel</i>', self._txt_start_channel)
layout.addRow('<i>End channel</i>', self._txt_end_channel)
# Signals
self._txt_start_channel.textEdited.connect(self.edited)
self._txt_end_channel.textEdited.connect(self.edited)
return layout
开发者ID:pyhmsa,项目名称:pyhmsa-gui,代码行数:23,代码来源:region.py
示例16: ColorLayout
class ColorLayout(QHBoxLayout):
"""Color-specialized QLineEdit layout"""
def __init__(self, color, parent=None):
QHBoxLayout.__init__(self)
assert isinstance(color, QColor)
self.lineedit = QLineEdit(color.name(), parent)
self.lineedit.textChanged.connect(self.update_color)
self.addWidget(self.lineedit)
self.colorbtn = ColorButton(parent)
self.colorbtn.color = color
self.colorbtn.colorChanged.connect(self.update_text)
self.addWidget(self.colorbtn)
def update_color(self, text):
color = text_to_qcolor(text)
if color.isValid():
self.colorbtn.color = color
def update_text(self, color):
self.lineedit.setText(color.name())
def text(self):
return self.lineedit.text()
开发者ID:ShenggaoZhu,项目名称:spyder,代码行数:23,代码来源:formlayout.py
示例17: __init__
def __init__(self, parent, split_char, split_index):
"""Popup on top of the tab to edit its name."""
# Variables
# Parent (main)
self.main = parent if parent is not None else self.parent()
self.split_char = split_char
self.split_index = split_index
# Track which tab is being edited
self.tab_index = None
# Widget setup
QLineEdit.__init__(self, parent=None)
# Slot to handle tab name update
self.editingFinished.connect(self.edit_finished)
# Even filter to catch clicks and ESC key
self.installEventFilter(self)
# Clean borders and no shadow to blend with tab
if PYQT5:
self.setWindowFlags(
Qt.Popup |
Qt.FramelessWindowHint |
Qt.NoDropShadowWindowHint
)
else:
self.setWindowFlags(
Qt.Popup |
Qt.FramelessWindowHint
)
self.setFrame(False)
# Align with tab name
self.setTextMargins(9, 0, 0, 0)
开发者ID:rlaverde,项目名称:spyder,代码行数:37,代码来源:tabs.py
示例18: createEditor
def createEditor(self, parent, option, index):
"""Create editor widget"""
model = index.model()
value = model.get_value(index)
if model._data.dtype.name == "bool":
value = not value
model.setData(index, to_qvariant(value))
return
elif value is not np.ma.masked:
editor = QLineEdit(parent)
editor.setFont(get_font(font_size_delta=DEFAULT_SMALL_DELTA))
editor.setAlignment(Qt.AlignCenter)
if is_number(self.dtype):
editor.setValidator(QDoubleValidator(editor))
editor.returnPressed.connect(self.commitAndCloseEditor)
return editor
开发者ID:ChunHungLiu,项目名称:spyder,代码行数:16,代码来源:arrayeditor.py
示例19: create_lineedit
def create_lineedit(self, text, option, default=NoDefault,
tip=None, alignment=Qt.Vertical, regex=None,
restart=False, word_wrap=True, placeholder=None):
label = QLabel(text)
label.setWordWrap(word_wrap)
edit = QLineEdit()
layout = QVBoxLayout() if alignment == Qt.Vertical else QHBoxLayout()
layout.addWidget(label)
layout.addWidget(edit)
layout.setContentsMargins(0, 0, 0, 0)
if tip:
edit.setToolTip(tip)
if regex:
edit.setValidator(QRegExpValidator(QRegExp(regex)))
if placeholder:
edit.setPlaceholderText(placeholder)
self.lineedits[edit] = (option, default)
widget = QWidget(self)
widget.label = label
widget.textbox = edit
widget.setLayout(layout)
edit.restart_required = restart
edit.label_text = text
return widget
开发者ID:impact27,项目名称:spyder,代码行数:24,代码来源:configdialog.py
示例20: __init__
def __init__(self, parent=None, label_name=''):
"""
:param parent:
:param label_name
"""
super(GetValueDialog, self).__init__(parent)
layout = QVBoxLayout(self)
# details information
self.info_line = QPlainTextEdit(self)
self.info_line.setEnabled(False)
layout.addWidget(self.info_line)
# input
self.label = QLabel(self)
self.value_edit = QLineEdit(self)
layout.addWidget(self.label)
layout.addWidget(self.value_edit)
# END-IF-ELSE
# nice widget for editing the date
# self.datetime = QDateTimeEdit(self)
# self.datetime.setCalendarPopup(True)
# self.datetime.setDateTime(QDateTime.currentDateTime())
# layout.addWidget(self.datetime)
# OK and Cancel buttons
buttons = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel,
QtCore.Qt.Horizontal, self)
buttons.accepted.connect(self.accept)
buttons.rejected.connect(self.reject)
layout.addWidget(buttons)
# set some values
self.setWindowTitle('Get user input')
self.label.setText(label_name)
return
开发者ID:mantidproject,项目名称:mantid,代码行数:40,代码来源:guiutility.py
注:本文中的qtpy.QtWidgets.QLineEdit类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论