[python] pyQt updated_at: 2024-12-14 15:45

pyQt

import sys
from PyQt5.QtWidgets import *

class MyWindow(QMainWindow):
  def __init__(self):
    super().__init__()
    self.setWindowTitle("PyStock")
    self.setGeometry(300, 300, 300, 400)

if __name__ == "__main__":
  app = QApplication(sys.argv)
  mywindow = MyWindow()
  mywindow.show()
  app.exec_()
  • setWindowTitle윈도우 타이틀
  • setGeometry윈도우 크기

클릭 버튼 추가 및 이벤트

class MyWindow(QMainWindow):
  def __init__(self):
    super().__init__()
    self.setWindowTitle("PyStock")
    self.setGeometry(300, 300, 300, 400)

    btn1 = QPushButton("Click me", self)
    btn1.move(20, 20)
    btn1.clicked.connect(self.btn1_clicked)

    def btn1_clicked(self):
      QMessageBox.about(self, "message", "clicked")"

QLabel("Hello PyQt")
QPushButton("Click me", self)
QPushButton("Quit")
QMessageBox.about(self, "message", "clicked")
btn1 = QPushButton("Click me", self)
btn1.move(20, 20)
btn1.clicked.connect(self.btn1_clicked)

Table of contents 목차

평점을 남겨주세요
평점 : 5.0
총 투표수 : 1

질문 및 답글