氣輕PyQt6 06 文本框(QLineEdit) 掩碼
?
掩碼有很多種,這里只介紹了一種。
?
from PyQt6.QtWidgets import *
from PyQt6.QtGui import QFont, QDoubleValidator
import sys
?
class PyQt606(QWidget):
??? def __init__(self):
??????? super().__init__()
??????? self.initUI()
??? def initUI(self):
??????? self.setWindowTitle('氣輕PyQt6')??????????????? # 設(shè)置窗口標(biāo)題
??????? self.resize(700, 300)?????????????????????????? # 設(shè)置窗口大小
??????? self.edit = QLineEdit(self)???????????????????? # 輸入框
??????? self.edit.setGeometry(10, 0,240, 40)??????????? # 設(shè)置位置和大小
??????? self.edit.setFont(QFont('Arial',20))
??????? self.edit.setInputMask("000.000.000.000;_")???? # 掩碼
?
??????? self.show()
?
if __name__ == '__main__':
??? app = QApplication(sys.argv)
??? window = PyQt606()
??? sys.exit(app.exec())
?
執(zhí)行結(jié)果
