zoukankan      html  css  js  c++  java
  • 综合实例-文本框类部件

     1 import sys
     2 from PyQt5.QtWidgets import QApplication, QLineEdit, QWidget, QFormLayout
     3 from PyQt5.QtGui import QIntValidator, QDoubleValidator, QFont
     4 from PyQt5.QtCore import Qt
     5 
     6 
     7 class lineEditDemo(QWidget):
     8 
     9     def __init__(self):
    10         super(lineEditDemo, self).__init__()
    11 
    12         e1 = QLineEdit()
    13         e1.setValidator(QIntValidator())
    14         e1.setMaxLength(4)
    15         e1.setAlignment(Qt.AlignRight)
    16         e1.setFont(QFont("Arial", 20))
    17         e2 = QLineEdit()
    18         e2.setValidator(QDoubleValidator(0.99, 99.99, 2))
    19         flo = QFormLayout()
    20         flo.addRow("integer validator", e1)
    21         flo.addRow("Double validateor", e2)
    22         e3 = QLineEdit()
    23         e3.setInputMask("+99_9999_999999")
    24         flo.addRow("Input Mask", e3)
    25         e4 = QLineEdit()
    26         e4.textChanged.connect(self.textchanged)
    27         flo.addRow("Text changed", e4)
    28         e5 = QLineEdit()
    29         e5.setEchoMode(QLineEdit.Password)
    30         flo.addRow("Password", e5)
    31         e6 = QLineEdit("Hello PyQt5")
    32         e6.setReadOnly(True)
    33         flo.addRow("Read Only", e6)
    34         e5.editingFinished.connect(self.enterPress)
    35         self.setLayout(flo)
    36         self.setWindowTitle("QLineEdit例子")
    37 
    38     def textchanged(self, text):
    39         print("输入的内容为: "+ text)
    40 
    41     def enterPress(self):
    42         print("已输入值")
    43 
    44 if __name__ == '__main__':
    45     app = QApplication(sys.argv)
    46     win = lineEditDemo()
    47     win.show()
    48     sys.exit(app.exec_())

    效果图:

  • 相关阅读:
    html的URL参数传值问题
    html背景图片拉伸至全屏
    Laravel 用户验证Auth::attempt fail的问题
    HTML中meta的应用
    ubuntu升级php版本
    Laravel 目录结构分析
    css颜色渐变在不同浏览器的设置
    谷歌浏览器(Chrome)离线包的下载方法!
    RAD Studio 10 up1欢迎页证书不可用
    MySQL
  • 原文地址:https://www.cnblogs.com/leoych/p/13413430.html
Copyright © 2011-2022 走看看