本文整理匯總了Python中PyQt5.QtWidgets.QLineEdit.setPlaceholderText方法的典型用法代碼示例。如果您正苦於以下問題:Python QLineEdit.setPlaceholderText方法的具體用法?Python QLineEdit.setPlaceholderText怎麽用?Python QLineEdit.setPlaceholderText使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PyQt5.QtWidgets.QLineEdit
的用法示例。
在下文中一共展示了QLineEdit.setPlaceholderText方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: Window
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setPlaceholderText [as 別名]
class Window(QWidget):
def __init__(self):
super().__init__()
# Make widgets #################
self.edit = QLineEdit()
self.btn = QPushButton("Print")
self.edit.setPlaceholderText("Type something here and press the 'Print' button")
# Set button slot ##############
self.btn.clicked.connect(self.printText)
# Set the layout ###############
vbox = QVBoxLayout()
vbox.addWidget(self.edit)
vbox.addWidget(self.btn)
self.setLayout(vbox)
def printText(self):
print(self.edit.text())
示例2: init_tray
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setPlaceholderText [as 別名]
def init_tray(self):
"""
Initializes the systray menu
"""
traymenu = QMenu("Menu")
self.tray.setContextMenu(traymenu)
self.tray.show()
self.tray.activated.connect(self.tray_click)
self.tray.setToolTip("Pomodori: "+str(self.pom.pomodori))
set_timer_tray = QLineEdit()
set_timer_tray.setPlaceholderText("Set timer")
set_timer_tray.textChanged.connect(lambda:
self.update_timer_text(set_timer_tray.text()))
traywidget = QWidgetAction(set_timer_tray)
traywidget.setDefaultWidget(set_timer_tray)
traymenu.addAction(traywidget)
start_timer_action = QAction("&Start Timer", self)
start_timer_action.triggered.connect(self.start_timer_click)
traymenu.addAction(start_timer_action)
exit_action = QAction("&Exit", self)
exit_action.triggered.connect(QCoreApplication.instance().quit)
traymenu.addAction(exit_action)
示例3: FindInFilesActions
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setPlaceholderText [as 別名]
class FindInFilesActions(QWidget):
searchRequested = pyqtSignal('QString', bool, bool, bool)
def __init__(self, parent=None):
super().__init__(parent)
self.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Ignored)
self._scope = QComboBox()
self._scope.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
self.ninjaide = IDE.get_service('ide')
self.ninjaide.filesAndProjectsLoaded.connect(
self._update_combo_projects)
main_layout = QVBoxLayout(self)
hbox = QHBoxLayout()
hbox.addWidget(QLabel(translations.TR_SEARCH_SCOPE))
hbox.addWidget(self._scope)
main_layout.addLayout(hbox)
widgets_layout = QGridLayout()
widgets_layout.setContentsMargins(0, 0, 0, 0)
self._line_search = QLineEdit()
self._line_search.setPlaceholderText(translations.TR_SEARCH_FOR)
main_layout.addWidget(self._line_search)
# TODO: replace
self._check_cs = QCheckBox(translations.TR_SEARCH_CASE_SENSITIVE)
self._check_cs.setChecked(True)
widgets_layout.addWidget(self._check_cs, 2, 0)
self._check_wo = QCheckBox(translations.TR_SEARCH_WHOLE_WORDS)
widgets_layout.addWidget(self._check_wo, 2, 1)
self._check_re = QCheckBox(translations.TR_SEARCH_REGEX)
widgets_layout.addWidget(self._check_re, 3, 0)
self._check_recursive = QCheckBox('Recursive')
widgets_layout.addWidget(self._check_recursive, 3, 1)
main_layout.addLayout(widgets_layout)
main_layout.addStretch(1)
# Connections
self._line_search.returnPressed.connect(self.search_requested)
def _update_combo_projects(self):
projects = self.ninjaide.get_projects()
for nproject in projects.values():
self._scope.addItem(nproject.name, nproject.path)
@property
def current_project_path(self):
"""Returns NProject.path of current project"""
return self._scope.itemData(self._scope.currentIndex())
def search_requested(self):
text = self._line_search.text()
if not text.strip():
return
has_search = self._line_search.text()
cs = self._check_cs.isChecked()
regex = self._check_re.isChecked()
wo = self._check_wo.isChecked()
self.searchRequested.emit(has_search, cs, regex, wo)
示例4: NetworkToolbar
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setPlaceholderText [as 別名]
class NetworkToolbar(QToolBar):
reset_hexacopter_parameters = pyqtSignal()
def __init__(self, network_handler):
super().__init__("Network")
self._nh = network_handler
self._connected = False
ping_timer = QtCore.QTimer(self)
ping_timer.timeout.connect(self._send_ping)
ping_timer.start(500)
host_text = QLabel("Connect to hexapi:")
self._host_edit = QLineEdit()
self._host_edit.setMinimumWidth(100)
self._host_edit.setMaximumWidth(140)
self._host_edit.setAlignment(QtCore.Qt.AlignRight)
self._host_edit.setPlaceholderText("192.169.1.2")
self.addWidget(host_text)
self.addWidget(self._host_edit)
self.addAction("Set host", self._connect)
self.addAction("Land", self._land)
self.addAction("Kill!", self._kill)
@QtCore.pyqtSlot()
def _connect(self):
logging.info("MA: Setting host")
self._connected = True
host_and_port = self._host_edit.text().split(":")
if len(host_and_port) == 2:
port = int(host_and_port[1])
else:
port = 4092
self._nh.set_host(host_and_port[0], port)
@QtCore.pyqtSlot()
def _send_ping(self):
if self._connected:
self._nh.send_command("PING")
@QtCore.pyqtSlot()
def _land(self):
self._nh.send_command("LAND")
self.reset_hexacopter_parameters.emit()
@QtCore.pyqtSlot()
def _kill(self):
self._nh.send_command("KILL")
self.reset_hexacopter_parameters.emit()
示例5: _create_text_edit
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setPlaceholderText [as 別名]
def _create_text_edit(placeholder_text):
edit = QLineEdit()
edit.setMinimumWidth(80)
edit.setMaximumWidth(100)
edit.setAlignment(QtCore.Qt.AlignRight)
edit.setPlaceholderText(placeholder_text)
return edit
示例6: CreateUserDialog
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setPlaceholderText [as 別名]
class CreateUserDialog(OkCancelDialog):
"""
Dialog with input fields to create a new user.
"""
accepted = pyqtSignal(dict, name="accepted")
def __init__(self, existing_names, existing_dbs, *args, **kwargs):
"""
Create the dialog controls.
:param existing_names: List with the existing user names.
:param existing_dbs: List with the existing database filenames.
"""
layout = QFormLayout()
super().__init__("Create new user", layout, *args, **kwargs)
self.existing_names = existing_names
self.existing_dbs = existing_dbs
self._data = {} # the dict that is filled with the user input
# Add the name input.
self.input_name = QLineEdit()
self.input_name.setPlaceholderText("Firstname Lastname")
layout.addRow("Name:", self.input_name)
@staticmethod
def _user_id(name):
"""
Convert the given name to the corresponding user id. Currently the user id equals the name.
:param name: The name.
:return: Returns the user id..
"""
return name
def accept(self):
"""
Accept the dialog if the name is non-empty and not already chosen.
"""
# Fill the data dict with the user input.
name = self.input_name.text()
self._data["display_name"] = name
self._data["database_user_name"] = self._user_id(name)
self._data["database_location"] = os.path.join(global_settings.database_dir, global_settings.default_database)
# Check that name and database filename are not in use already.
if len(name) == 0:
self.show_error("Name must not be empty.")
elif name in self.existing_names:
self.show_error("The chosen name already exists.")
else:
self.accepted.emit(self._data)
self.close()
示例7: createEditor
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setPlaceholderText [as 別名]
def createEditor(self, parent, option, index):
self.updateRects(option, index)
bgColor = self.bgColors.get(index, "white")
if self.mainLineRect.contains(self.lastPos):
# One line summary
self.editing = Outline.summarySentence
edt = QLineEdit(parent)
edt.setFocusPolicy(Qt.StrongFocus)
edt.setFrame(False)
f = QFont(option.font)
if self.newStyle():
f.setBold(True)
else:
f.setItalic(True)
edt.setAlignment(Qt.AlignCenter)
edt.setPlaceholderText(self.tr("One line summary"))
edt.setFont(f)
edt.setStyleSheet("background: {}; color: black;".format(bgColor))
return edt
elif self.titleRect.contains(self.lastPos):
# Title
self.editing = Outline.title
edt = QLineEdit(parent)
edt.setFocusPolicy(Qt.StrongFocus)
edt.setFrame(False)
f = QFont(option.font)
if self.newStyle():
f.setPointSize(f.pointSize() + 4)
else:
edt.setAlignment(Qt.AlignCenter)
f.setBold(True)
edt.setFont(f)
edt.setStyleSheet("background: {}; color: black;".format(bgColor))
# edt.setGeometry(self.titleRect)
return edt
else: # self.mainTextRect.contains(self.lastPos):
# Summary
self.editing = Outline.summaryFull
edt = QPlainTextEdit(parent)
edt.setFocusPolicy(Qt.StrongFocus)
edt.setFrameShape(QFrame.NoFrame)
try:
# QPlainTextEdit.setPlaceholderText was introduced in Qt 5.3
edt.setPlaceholderText(self.tr("Full summary"))
except AttributeError:
pass
edt.setStyleSheet("background: {}; color: black;".format(bgColor))
return edt
示例8: __init__
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setPlaceholderText [as 別名]
def __init__(self, parent, bank_name, required_input):
DialogContainer.__init__(self, parent)
self.required_input = required_input
uic.loadUi(get_ui_file_path('iom_input_dialog.ui'), self.dialog_widget)
self.dialog_widget.cancel_button.clicked.connect(lambda: self.button_clicked.emit(0))
self.dialog_widget.confirm_button.clicked.connect(lambda: self.button_clicked.emit(1))
if 'error_text' in required_input:
self.dialog_widget.error_text_label.setText(required_input['error_text'])
else:
self.dialog_widget.error_text_label.hide()
if 'image' in required_input['additional_data']:
qimg = QImage()
qimg.loadFromData(b64decode(required_input['additional_data']['image']))
image = QPixmap.fromImage(qimg)
scene = QGraphicsScene(self.dialog_widget.img_graphics_view)
scene.addPixmap(image)
self.dialog_widget.img_graphics_view.setScene(scene)
else:
self.dialog_widget.img_graphics_view.hide()
self.dialog_widget.iom_input_title_label.setText(bank_name)
vlayout = QVBoxLayout()
self.dialog_widget.user_input_container.setLayout(vlayout)
self.input_widgets = {}
for specific_input in self.required_input['required_fields']:
label_widget = QLabel(self.dialog_widget.user_input_container)
label_widget.setText(specific_input['text'] + ":")
label_widget.show()
vlayout.addWidget(label_widget)
input_widget = QLineEdit(self.dialog_widget.user_input_container)
input_widget.setPlaceholderText(specific_input['placeholder'])
if specific_input['type'] == 'password':
input_widget.setEchoMode(QLineEdit.Password)
input_widget.show()
vlayout.addWidget(input_widget)
self.input_widgets[specific_input['name']] = input_widget
self.dialog_widget.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Expanding)
self.dialog_widget.adjustSize()
self.on_main_window_resize()
示例9: Example
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setPlaceholderText [as 別名]
class Example(QWidget):
def __init__(self):
super().__init__()
self.resize(640, 320)
self.setWindowTitle('PyQt-5 WebEngine')
page = "https://www.google.com"
self.url = QLineEdit(page)
self.url.setPlaceholderText(page)
self.go = QPushButton("Ir")
self.go.clicked.connect(self.btnIrClicked)
self.nav_bar = QHBoxLayout()
self.nav_bar.addWidget(self.url)
self.nav_bar.addWidget(self.go)
self.progress = QProgressBar()
self.progress.setValue(0)
html = """
<!DOCTYPE HTML>
<html>
<head>
<title>Example Local HTML</title>
</head>
<body>
<p>Este es un archivo <code>HTML</code> local.</p>
<p>Si deseas acceder página indica su <code>URL</code> y presiona <b>Ir</b></p>
</body>
</html>
"""
self.web_view = QWebEngineView()
self.web_view.loadProgress.connect(self.webLoading)
self.web_view.setHtml(html)
root = QVBoxLayout()
root.addLayout(self.nav_bar)
root.addWidget(self.web_view)
root.addWidget(self.progress)
self.setLayout(root)
def btnIrClicked(self, event):
url = QUrl(self.url.text())
self.web_view.page().load(url)
def webLoading(self, event):
self.progress.setValue(event)
示例10: _initUi
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setPlaceholderText [as 別名]
def _initUi(self):
self.resize(250, 150)
self.move(300, 300)
self.setWindowTitle("Simple")
layout = QVBoxLayout()
headWidget = QWidget()
headLayout = QHBoxLayout()
headWidget.setLayout(headLayout)
layout.addWidget(headWidget)
edit_icon = QWidget(self)
edit_icon.resize(30,30)
edit_icon.setStyleSheet("background: url(:/images/edit-icon);")
edit_icon.move(20,15)
label = QLabel("Login Form", self)
label.resize(label.sizeHint())
label.move(60,20)
edit = QLineEdit()
edit.setObjectName("username")
edit.setPlaceholderText("username")
layout.addWidget(edit)
edit = QLineEdit()
edit.setObjectName("password")
edit.setPlaceholderText("password")
layout.addWidget(edit)
widget = QWidget()
layout.addWidget(widget)
loginLayout = QHBoxLayout()
loginLayout.setContentsMargins(0,-10,0,0)
loginLayout.setSpacing(30)
widget.setLayout(loginLayout)
# widget.setStyleSheet("background-color:blue")
btn = QPushButton("登錄")
loginLayout.addWidget(btn)
btn.clicked.connect(self.login)
btn.setStyleSheet("margin:0;padding:5 0;border:0px;background-color: #26b9a5;color:white;")
btn.setAutoDefault(False)
btn = QPushButton("取消")
loginLayout.addWidget(btn)
btn.clicked.connect(self.close)
btn.setStyleSheet("padding:5px 0;border:0px;background-color: #26b9a5;color:white;")
btn.setAutoDefault(False)
# layout.setContentsMargins(11,11,11,11)
self.setLayout(layout)
示例11: __init__
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setPlaceholderText [as 別名]
def __init__(self, parent=None):
super(lineEditDemo, self).__init__(parent)
self.setWindowTitle("QLineEdit例子")
flo = QFormLayout()
pNormalLineEdit = QLineEdit( )
pNoEchoLineEdit = QLineEdit()
pPasswordLineEdit = QLineEdit( )
pPasswordEchoOnEditLineEdit = QLineEdit( )
flo.addRow("Normal", pNormalLineEdit)
flo.addRow("NoEcho", pNoEchoLineEdit)
flo.addRow("Password", pPasswordLineEdit)
flo.addRow("PasswordEchoOnEdit", pPasswordEchoOnEditLineEdit)
pNormalLineEdit.setPlaceholderText("Normal")
pNoEchoLineEdit.setPlaceholderText("NoEcho")
pPasswordLineEdit.setPlaceholderText("Password")
pPasswordEchoOnEditLineEdit.setPlaceholderText("PasswordEchoOnEdit")
# 設置顯示效果
pNormalLineEdit.setEchoMode(QLineEdit.Normal)
pNoEchoLineEdit.setEchoMode(QLineEdit.NoEcho)
pPasswordLineEdit.setEchoMode(QLineEdit.Password)
pPasswordEchoOnEditLineEdit.setEchoMode(QLineEdit.PasswordEchoOnEdit)
self.setLayout(flo)
示例12: ComputeWidget
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setPlaceholderText [as 別名]
class ComputeWidget(QWidget):
def __init__(self, parent):
super(ComputeWidget, self).__init__(parent)
self.input = QueryInput(self)
self.exec = QPushButton(self)
self.grid = QGridLayout(self)
self.target = QLineEdit(self)
self.ui()
self.properties()
self.exec.clicked.connect(self.execute)
def execute(self):
query = Query(select=self.input.toPlainText())
query.execute()
if query.error == Query.NoError:
var_name = self.target.text().strip()
column = None
new_column = False
if var_name:
logger.debug("var_name={}".format(var_name))
column = Column.get_by_name(var_name)
if not column:
column = Column(Column.count(), name=var_name)
new_column = True
logger.debug("new_column={}".format(new_column))
for row, data in query.result.items():
if new_column:
Cell(row, column.id, data=data)
else:
cell = Cell.get(row, column.id)
cell.data = data
def properties(self):
self.input.setPlaceholderText("Query")
self.exec.setText("Execute")
self.target.setPlaceholderText("Target Variable")
def ui(self):
self.grid.addWidget(self.input, 1, 0, 1, 10)
self.grid.addWidget(self.exec, 2, 5, 1, 5)
self.grid.addWidget(self.target, 0, 0, 1, 10)
def events(self):
self.exec.clicked.connect(self.execute)
示例13: MyPopup
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setPlaceholderText [as 別名]
class MyPopup(QWidget):
def __init__(self):
global text_
global fig, chartFig
QWidget.__init__(self)
self.setWindowTitle('Add new Speaker')
self.main_widget = QtWidgets.QWidget(self)
self.speakerID = QLineEdit(self)
self.Ok = QPushButton("Ok", self)
#self.show()
# Draw new Speaker window
#----------------------
def paintEvent(self, e):
self.speakerID.setPlaceholderText('Speaker...')
self.speakerID.setMinimumWidth(100)
self.speakerID.setEnabled(True)
self.speakerID.move(90, 15)
self.Ok.move(115, 60)
self.speakerID.textChanged.connect(self.speakerLabel)
self.Ok.clicked.connect(self.closeSpeaker)
self.Ok.show()
self.speakerID.show()
def speakerLabel(self,text):
global text_
text_ = 'Speech::' + text
# Close and save new Speaker ID
#----------------------
def closeSpeaker(self):
global text_
global fig, chartFig
if text_ != 'Add New Speaker':
text_ = 'Speech::' + self.speakerID.text()
self.Ok.clicked.disconnect()
self.close()
fig.saveAnnotation()
fig.draw()
chartFig.axes.clear()
chartFig.drawChart()
chartFig.draw()
示例14: RecodeWidget
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setPlaceholderText [as 別名]
class RecodeWidget(QWidget):
def __init__(self, parent):
super(RecodeWidget, self).__init__(parent)
self.old_var = QLineEdit(self)
self.new_var = QLineEdit(self)
self.recode = QPushButton(self)
self.same = QCheckBox(self)
self.old_new_values = QPushButton(self)
self.grid = QGridLayout(self)
self.ui()
self.properties()
self.recode.clicked.connect(self.execute)
self.same.toggled.connect(self.same_toggled)
def same_toggled(self, event):
self.new_var.setEnabled(not event)
def execute(self):
if self.old_var.text().strip():
old_column = Column.get_by_name(self.old_var.text().strip())
new_column = None
if self.same.isChecked():
new_column = Column.get_by_name(self.new_var.text().strip())
recode = Recode(old_column, new_column)
recode.execute()
def properties(self):
self.old_var.setPlaceholderText("Old Variable")
self.new_var.setPlaceholderText("New Variable")
self.same.setText("Recode into same variable")
self.recode.setText("Recode")
self.old_new_values.setText("Old New Values")
self.new_var.setEnabled(False)
self.same.setChecked(True)
def ui(self):
self.grid.addWidget(self.old_var, 0, 0, 1, 10)
self.grid.addWidget(self.same, 1, 0, 1, 10)
self.grid.addWidget(self.new_var, 2, 0, 1, 10)
self.grid.addWidget(self.recode, 3, 9, 1, 1, Qt.AlignBottom)
self.grid.addWidget(self.old_new_values, 3, 8, 1, 1, Qt.AlignBottom)
示例15: LoginWidget
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setPlaceholderText [as 別名]
class LoginWidget(QWidget):
def __init__(self):
super().__init__()
lay = QHBoxLayout(self) # сразу подключаем лэйаут к виджету w
self.loginEdit = QLineEdit(self)
self.loginEdit.setPlaceholderText('Имя')
self.loginEdit.installEventFilter(self) # делаем текущий виджет наблюдателем событий виджета loginWidget
self.passwordEdit = QLineEdit(self)
self.passwordEdit.setPlaceholderText('Пароль')
self.passwordEdit.setEchoMode(QLineEdit.Password)
self.passwordEdit.installEventFilter(self) # делаем текущий виджет наблюдателем событий виджета passwordEdit
self.loginButton = QPushButton(self)
self.loginButton.setText('Войти')
self.loginButton.clicked.connect(self.login) # подсоединяем 'слот' к 'сигналу'
lay.addWidget(self.loginEdit)
lay.addWidget(self.passwordEdit)
lay.addWidget(self.loginButton)
def login(self, *args):
global w
name = w.loginEdit.text()
password = w.passwordEdit.text()
if User.login(name, password):
w = Table()
w.show()
def eventFilter(self, watched, event):
#print('eventFilter: {} - {}'.format(watched, event))
return super().eventFilter(watched, event)
def keyPressEvent(self, event):
if event.key() in (
PyQt5.QtCore.Qt.Key_Enter,
PyQt5.QtCore.Qt.Key_Return): # FIXME найти тип
print('-- ENTER --')
self.login()