Windows+Python使用PyQt5----简单样例(三)
自动补全
from PyQt5.QtWidgets import *
import sys
class Window(QWidget):
def __init__(self):
QWidget.__init__(self)
layout = QGridLayout()
self.setLayout(layout)
# 设置自动补全的选项
names = ["Apple", "Alps", "Berry", "Cherry" ]
# 初始化补全器
completer = QCompleter(names)
# 创建输入行控件
self.lineedit = QLineEdit()
# 将行输入控件设置补全器
self.lineedit.setCompleter(completer)
# 在布局中添加行输入控件
layout.addWidget(self.lineedit, 0, 0)
app = QApplication(sys.argv)
screen = Window()
screen.show()
sys.exit(app.exec_())
可输入的弹出框
from PyQt5.QtWidgets