暂无描述

lineedit.py 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import sys
  2. from PyQt5.QtWidgets import *
  3. from PyQt5.QtCore import *
  4. class MyWindow(QMainWindow):
  5. def __init__(self):
  6. super().__init__()
  7. self.initUI()
  8. def initUI(self):
  9. self.setWindowTitle('SWH Academy Window.')
  10. self.setGeometry(200, 200, 360, 100)
  11. self.label = QLabel("", self)
  12. self.label.move(120, 20)
  13. self.label.resize(150, 30)
  14. self.lineEdit = QLineEdit("", self)
  15. self.lineEdit.move(20, 50)
  16. self.lineEdit.textChanged.connect(self.lineEditChanged)
  17. button2 = QPushButton("지우기", self)
  18. button2.move(130, 50)
  19. button2.clicked.connect(self.button2Clicked)
  20. button3 = QPushButton("종료", self)
  21. button3.move(240, 50)
  22. button3.clicked.connect(QCoreApplication.instance().quit)
  23. def lineEditChanged(self):
  24. self.label.setText(self.lineEdit.text())
  25. def button2Clicked(self):
  26. self.label.clear()
  27. self.lineEdit.clear()
  28. if __name__ == "__main__":
  29. app = QApplication(sys.argv)
  30. window = MyWindow()
  31. window.show()
  32. sys.exit(app.exec_())