No Description

label.py 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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. button1 = QPushButton("클릭", self)
  15. button1.move(20, 50)
  16. button1.clicked.connect(self.button1Clicked)
  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 button1Clicked(self):
  24. self.label.setText("버튼이 클릭되었습니다.")
  25. def button2Clicked(self):
  26. self.label.clear()
  27. if __name__ == "__main__":
  28. app = QApplication(sys.argv)
  29. window = MyWindow()
  30. window.show()
  31. sys.exit(app.exec_())