本文整理匯總了Python中PyQt5.QtWidgets.QLineEdit.setText方法的典型用法代碼示例。如果您正苦於以下問題:Python QLineEdit.setText方法的具體用法?Python QLineEdit.setText怎麽用?Python QLineEdit.setText使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PyQt5.QtWidgets.QLineEdit
的用法示例。
在下文中一共展示了QLineEdit.setText方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setText [as 別名]
def __init__(self, settings):
super(QWidget, self).__init__()
self._layout = QBoxLayout(QBoxLayout.TopToBottom)
self.setLayout(self._layout)
self.settings = settings
# eq directory
widget = QWidget()
layout = QBoxLayout(QBoxLayout.LeftToRight)
widget.setLayout(layout)
label = QLabel("Everquest Directory: ")
layout.addWidget(label)
text = QLineEdit()
text.setText(self.settings.get_value("general", "eq_directory"))
text.setToolTip(self.settings.get_value("general", "eq_directory"))
text.setDisabled(True)
self._text_eq_directory = text
layout.addWidget(text, 1)
button = QPushButton("Browse...")
button.clicked.connect(self._get_eq_directory)
layout.addWidget(button)
self._layout.addWidget(widget, 0, Qt.AlignTop)
# eq directory info
frame = QFrame()
frame.setFrameShadow(QFrame.Sunken)
frame.setFrameShape(QFrame.Box)
frame_layout = QBoxLayout(QBoxLayout.LeftToRight)
frame.setLayout(frame_layout)
widget = QWidget()
layout = QBoxLayout(QBoxLayout.LeftToRight)
widget.setLayout(layout)
self._label_eq_directory = QLabel()
layout.addWidget(self._label_eq_directory, 1)
frame_layout.addWidget(widget, 1, Qt.AlignCenter)
self._layout.addWidget(frame, 1)
# parse interval
widget = QWidget()
layout = QBoxLayout(QBoxLayout.LeftToRight)
widget.setLayout(layout)
label = QLabel("Seconds between parse checks: ")
layout.addWidget(label, 0, Qt.AlignLeft)
text = QLineEdit()
text.setText(str(self.settings.get_value("general", "parse_interval")))
text.editingFinished.connect(self._parse_interval_editing_finished)
text.setMaxLength(3)
self._text_parse_interval = text
metrics = QFontMetrics(QApplication.font())
text.setFixedWidth(metrics.width("888888"))
layout.addWidget(text, 0, Qt.AlignLeft)
self._layout.addWidget(widget, 0, Qt.AlignTop | Qt.AlignLeft)
# spacing at bottom of window
widget = QWidget()
self._layout.addWidget(widget, 1)
# setup
if settings.get_value("general", "eq_directory") is not None:
self._check_directory_stats()
示例2: GalleryListEdit
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setText [as 別名]
class GalleryListEdit(misc.BasePopup):
def __init__(self, gallery_list, item, parent):
super().__init__(parent, blur=False)
self.gallery_list = gallery_list
self.item = item
main_layout = QFormLayout(self.main_widget)
self.name_edit = QLineEdit(gallery_list.name, self)
main_layout.addRow("Name:", self.name_edit)
self.filter_edit = QLineEdit(self)
if gallery_list.filter:
self.filter_edit.setText(gallery_list.filter)
what_is_filter = misc.ClickedLabel("What is filter? (Hover)")
what_is_filter.setToolTip(app_constants.WHAT_IS_FILTER)
what_is_filter.setToolTipDuration(9999999999)
main_layout.addRow(what_is_filter)
main_layout.addRow("Filter", self.filter_edit)
main_layout.addRow(self.buttons_layout)
self.add_buttons("Close")[0].clicked.connect(self.close)
self.add_buttons("Apply")[0].clicked.connect(self.accept)
self.adjustSize()
def accept(self):
name = self.name_edit.text()
self.item.setText(name)
self.gallery_list.name = name
self.gallery_list.filter = self.filter_edit.text()
gallerydb.add_method_queue(gallerydb.ListDB.modify_list, True, self.gallery_list, True, True)
gallerydb.add_method_queue(self.gallery_list.scan, True)
self.close()
示例3: MyMainWindow
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setText [as 別名]
class MyMainWindow(QMainWindow):
def __init__(self):
super(QMainWindow, self).__init__()
self.title = 'PyQt5 textbox example'
self.left = 100
self.top = 100
self.width = 640
self.height = 480
self.init_ui()
def init_ui(self):
self.setWindowTitle(self.title)
self.setGeometry(self.left, self.top, self.width, self.height)
self.textbox = QLineEdit(self)
self.textbox.move(20, 20)
self.textbox.resize(280, 30)
button = QPushButton('Show Text', self)
button.move(20, 80)
button.clicked.connect(self.on_button_click)
def on_button_click(self):
text = self.textbox.text()
if text:
QMessageBox.information(self, 'Message - textbox example', 'You typed: ' + text, QMessageBox.Ok, QMessageBox.Ok)
else:
QMessageBox.warning(self, 'Message - textbox example', 'You have not typed anything!', QMessageBox.Ok, QMessageBox.Ok)
self.textbox.setText('')
示例4: Example
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setText [as 別名]
class Example(QWidget):
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
self.btn = QPushButton('Click First', self)
self.btn.move(20, 20)
self.btn.clicked.connect(self.showDialog)
self.le = QLineEdit(self)
self.leSecond = QLineEdit(self)
# I guess its okay to use .extensions in variables in order
# to identify its use, i.e. .le for LineEdit
self.le.move(130, 22)
self.leSecond.move(130, 52)
self.setGeometry(300, 300, 290, 150)
self.setWindowTitle('Input dialog')
self.show()
def showDialog(self):
text, ok = QInputDialog.getText(self, 'Input Dialog', 'Enter your name:')
if ok:
self.le.setText(str(text))
today = date.today()
self.leSecond.setText(today.strftime("%m/%d/%y"))
示例5: widgets
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setText [as 別名]
def widgets(std_prm: Parameter) -> List[QWidget]:
"""
- This method generates all needed for input to the std_prm
- A QLineEdit for the std_prm name
- An input widget for the std_prm (by activating the "build_method" attribute of the parameters)
Args:
std_prm : (Parameter) - The parameter to be presented
"""
widgets = []
# The name widget
textEdit = QLineEdit()
textEdit.setText(std_prm["name"])
widgets.append(textEdit)
# The input widget
inputWidget = std_prm["build method"](std_prm["build method prms"], std_prm["slot"])
widgets.append(inputWidget)
# Add the input widget to the parameter
# this field will be used to identify the parameter
# in the slot
std_prm["name widget"] = textEdit
std_prm["widget"] = inputWidget
return widgets
示例6: initUI0
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setText [as 別名]
def initUI0(self):
self.f = open('names.txt')
self.lines = [line.rstrip('\n') for line in self.f]
self.j =0
self.i = 1
self.c = Communicate()
self.c.updateBW.connect(self.updateUi)
self.lbl = QLabel(self)
le = QLineEdit(self)
le.move(130, 22)
text, ok = QInputDialog.getText(self, 'Input Dialog',
'Enter your name:')
if ok:
le.setText(str(text))
self.myfile = """/home/an/pyqt/%(data)s.txt"""%{'data':text}
self.file = open(self.myfile, 'a')
self.file.write('\n')
d = datetime.today()
self.file.write(str(d.strftime('%y-%m-%d %H:%M:%S')))
self.file.write('\n')
le.close()
示例7: Example
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setText [as 別名]
class Example(QWidget):
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
self.btn = QPushButton('Dialog', self)
self.btn.move(20, 20)
self.btn.clicked.connect(self.showDialog)
self.le = QLineEdit(self)
self.le.move(130, 22)
self.setGeometry(300, 300, 290, 150)
self.setWindowTitle('Input dialog')
self.show()
def showDialog(self):
# QInputDialog提供了一個簡單便利的對話框用於從用戶哪兒獲得一個值,輸入可以是字符串,數字,或者一個列表中的列表項
# 顯示一個輸入對話框。第一個字符串參數是對話框的標題,二是對話框內的消息文本,對話框返回輸入的文本值和一個布爾值
text, ok = QInputDialog.getText(self, 'Input Dialog',
'Enter your name:')
if ok:
# 把從對話框接受到的文本設置到單行編輯框組件上顯示
self.le.setText(str(text))
示例8: GestionEleve
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setText [as 別名]
class GestionEleve(QWidget):
def __init__(self,parent=None):
super(GestionEleve,self).__init__(parent)
#charge la classe en cour
self.initClass()
palette = QPalette()
palette.setColor(QPalette.Text,QColor(128,128,128))
self.leNom = QLineEdit(self)
self.leNom.setText("NOM..")
self.leNom.setPalette(palette)
self.lePrenom = QLineEdit(self)
self.lePrenom.setText("PRENOM..")
self.lePrenom.setPalette(palette)
self.comboSex = QComboBox(self)
self.comboSex.addItem("sexe..")
self.comboSex.addItem("M")
self.comboSex.addItem("F")
self.comboClasse = self.initComboClasse(["CE1","CE2"])
self.buttonSave = QPushButton("Save")
self.buttonSave.clicked.connect(self.saveEleve)
layout = QHBoxLayout()
layout.addStretch()
layout.addWidget(self.leNom)
layout.addWidget(self.lePrenom)
layout.addWidget(self.comboSex)
layout.addWidget(self.comboClasse)
layout.addWidget(self.buttonSave)
layout.addStretch()
self.setLayout(layout)
def initComboClasse(self,list):
res = QComboBox()
res.addItem("classe..")
for elt in list:
res.addItem(elt)
return res
def saveEleve(self):
if (self.leNom.text == "NOM.."
or self.lePrenom.text == "PRENOM.."
or str(self.comboSex.currentText()) == "sexe.."
or str(self.comboClasse.currentText()) == "classe.."
):
pass
#on enregistre pas
else :
pass
#on enregistre
def initClass(self):
pass
示例9: Example
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setText [as 別名]
class Example(QWidget):
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
self.btn = QPushButton('Dialog', self)
self.btn.move(20, 20)
self.btn.clicked.connect(self.showDialog)
self.le = QLineEdit(self)
self.le.move(130, 22)
self.setGeometry(300, 300, 290, 150)
self.setWindowTitle('Input dialog')
self.show()
def showDialog(self):
""" ボタンが押されるとダイアログを出す """
# input dialogを出す
text, ok = QInputDialog.getText(self, 'Input Dialog',
'Enter your name:')
if ok:
# QLineEditのオブジェクトにテキストをセット
self.le.setText(str(text))
示例10: initUI
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setText [as 別名]
def initUI(self):
self.c = Communicate()
self.wid = BurningWidget()
self.c.updateBW.connect(self.wid.setValue)
le = QLineEdit(self)
le.move(130, 22)
text, ok = QInputDialog.getText(self, 'Input Dialog',
'Enter your name:')
if ok:
le.setText(str(text))
self.file = open("""/home/an/%(data)s.txt"""%{'data':text}, 'a')
print (text)
hbox = QHBoxLayout()
hbox.addWidget(self.wid)
vbox = QVBoxLayout()
vbox.addStretch(1)
vbox.addLayout(hbox)
self.setLayout(vbox)
self.setGeometry(0, 0, 1800, 1000)
self.setWindowTitle('Burning widget')
self.show()
示例11: FolderSelector
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setText [as 別名]
class FolderSelector(QWidget):
def __init__(self):
super(self.__class__, self).__init__()
self.folder = None
self.line_edit = QLineEdit()
self.button = QPushButton()
self.button.setText("Browse...")
self.button.clicked.connect(self.on_clicked)
gbox = QGroupBox(self)
gbox.setTitle("Select a folder to sync:")
gbox_layout = QHBoxLayout(gbox)
gbox_layout.addItem(QSpacerItem(100, 0, QSizePolicy.Preferred, 0))
gbox_layout.addWidget(self.line_edit)
gbox_layout.addWidget(self.button)
gbox_layout.addItem(QSpacerItem(100, 0, QSizePolicy.Preferred, 0))
hbox = QHBoxLayout(self)
hbox.addWidget(gbox)
#hbox.addItem(QSpacerItem(100, 0, QSizePolicy.Preferred, 0))
#hbox.addWidget(self.line_edit)
#hbox.addWidget(self.button)
#hbox.addItem(QSpacerItem(100, 0, QSizePolicy.Preferred, 0))
def on_clicked(self):
selected_folder = QFileDialog.getExistingDirectory(
self, "Select a folder to sync")
if selected_folder:
self.line_edit.setText(selected_folder)
self.folder = selected_folder
示例12: addStatControl
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setText [as 別名]
def addStatControl(self,i,label=None):
statbox = QHBoxLayout()
statbox.addSpacing(1)
statbox.setSpacing(0)
statbox.setAlignment(Qt.AlignCenter)
statlabel = QLabel(self.stats[i] if label is None else label)
statlabel.setContentsMargins(0,0,0,0)
statlabel.setAlignment(Qt.AlignCenter)
statlabel.setFixedWidth(20)
statbox.addWidget(statlabel)
statcontrol = QLineEdit()
statcontrol.setAlignment(Qt.AlignCenter)
statcontrol.setFixedWidth(40)
statcontrol.setText(str(self.skill.multipliers[i]))
v = QDoubleValidator(0,99,3,statcontrol)
v.setNotation(QDoubleValidator.StandardNotation)
#v.setRange(0,100,decimals=3)
statcontrol.setValidator(v)
#print(v.top())
def statFuncMaker(j):
def statFunc(newValue):
self.skill.multipliers[j] = float(newValue)
self.skillsChanged.emit()
return statFunc
statcontrol.textChanged[str].connect(statFuncMaker(i))
statbox.addWidget(statcontrol)
statbox.addSpacing(1)
self.layout.addLayout(statbox)
示例13: createEditor
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setText [as 別名]
def createEditor(self, parent, option, index):
""" Return a QLineEdit for arbitrary representation of a date value in any format.
"""
editor = QLineEdit(parent)
date = index.model().data(index, Qt.DisplayRole)
editor.setText(date.strftime(self.format))
return editor
示例14: __init__
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setText [as 別名]
def __init__(self, vcards, keys, parent):
self.vcards, self.keys = vcards, keys
super().__init__(parent)
done = QPushButton("Done", self)
done.clicked.connect(self.merge_done)
self.edits = {}
layout = QGridLayout()
layout.addWidget(done, 0, 1)
i = 1
for key in self.keys:
if key not in ['REV', 'UID', 'VERSION', 'PRODID']:
items = set()
for v in self.vcards.values():
if key in v.dict and v.dict[key]:
for item in v.dict[key]:
items.add(item)
if items:
edit = QLineEdit(self)
edit.setText('|'.join(items))
layout.addWidget(QLabel(key), i, 0)
layout.addWidget(edit, i, 1)
self.edits[key] = edit
i += 1
self.setLayout(layout)
示例15: App
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setText [as 別名]
class App(QMainWindow):
def __init__(self):
super().__init__()
self.title = 'PyQt5 textbox'
self.left = 10
self.top = 10
self.width = 400
self.height = 140
self.initUI()
def initUI(self):
self.setWindowTitle(self.title)
self.setGeometry(self.left, self.top, self.width, self.height)
# Create textbox
self.textbox = QLineEdit(self)
self.textbox.move(20, 20)
self.textbox.resize(280, 40)
# Create button in the window
self.button = QPushButton('Show text', self)
self.button.move(20, 80)
# Connect button on function on click
self.button.clicked.connect(self.on_click)
self.show()
@pyqtSlot()
def on_click(self):
textboxValue = self.textbox.text()
QMessageBox.question(self, 'Message - python.org', 'You Typed: ' + textboxValue, QMessageBox.Ok, QMessageBox.Ok)
self.textbox.setText("")