파이썬 창을 만들어 버튼을 눌러 실행하고 설정값을 받고 할수있다
PyQt5 라이브러리를 사용한다.
#창띄우고 종료버튼 만들기
import sys
from PyQt5.QtWidgets import QApplication, QPushButton, QMainWindow
from PyQt5.QtCore import QCoreApplication
from PyQt5.QtGui import QIcon
class MyApp(QMainWindow):
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
#아이콘 설정
self.setWindowTitle('Icon')
self.setWindowIcon(QIcon('./image/icon.png'))
#창사이즈
self.setGeometry(300, 300, 300, 200)
self.statusBar().showMessage('Ready')
#버트생성
btn = QPushButton('Quit', self)
btn.move(50, 50)
btn.setToolTip('This is a <b>QPushButton</b> widget')
btn.resize(btn.sizeHint())
btn.clicked.connect(QCoreApplication.instance().quit)
self.show()
if __name__ == '__main__':
app = QApplication(sys.argv)
ex = MyApp()
sys.exit(app.exec_())
참고문헌
더보기
https://pypi.org/project/PyQt5
https://wikidocs.net/book/2165
https://www.riverbankcomputing.com/static/Docs/PyQt5/
728x90
반응형