About 배우고 익히는법/Python
[Python] PyQt5 - 기본 창 띄우기
투명잉크
2019. 1. 4. 13:52
[Python] PyQt5 - 기본 창 띄우기
import sys
from PyQt5. QtWidgets import QApplication, QWidget
class basic_window(QWidget):
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
self.setGeometry(300, 300, 250, 150)
# ↑ 창의 위치를 모니터 좌상단으로부터 가로 300px, 세로 300px, 창의 크기는 가로 250px, 세로 150px.
self.setWindowTitle('기본 창') # 이 창의 이름을 '기본 창'으로 한다.
self.show()
if __name__ == '__main__':
app = QApplication(sys.argv)
basic_window = basic_window()
sys.exit(app.exec_())
import sys
from PyQt5.QtWidgets import QApplication, QWidget
if __name__ == '__main__':
app = QApplication(sys.argv)
w = QWidget() # Qwidget의 기본 항목을 표시한다. 상위 항목(parent)이 없는데, 이를 '창(window)'이라 한다.
w.resize(250, 150) # 창의 크기를 가로 250px, 세로 150px 로 한다.
w.move(300, 300) # 창의 위치를 왼쪽으로부터 300px, 위로부터 300px 로 한다.
w.setWindowTitle('Simple') # 이 창의 이름을 'Simple'로 한다.
w.show() # 창을 띄운다.
sys.exit(app.exec_())
[출처] 「Python」 PyQt5 - 기본 창 띄우기|작성자 스마일군