인공지능을 알아가보자
PyQt를 이용한 gui만들기 본문
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | import sys from PyQt5.QtWidgets import * class MyDialog(QDialog): def __init__(self): QDialog.__init__(self) TitleName=QLabel("Name")#팝업이름 editName = QLineEdit() btnOk=QPushButton("OK")#버튼팝업에대한 이름 layout = QVBoxLayout() layout.addWidget(TitleName) layout.addWidget(editName) layout.addWidget(btnOk) self.setLayout(layout) btnOk.clicked.connect(self.btnFunc) def btnFunc(self): select = self.msgbox.qyestion(self,'팝업','이름을 출력하겠습니까',QMessageBox.Yes,QMessageBox.No) if select == QMessage.No: self.label_1.setText("No 눌렀음") elif select == QMessageBox.Yes: self.label_1.setText(editname) app=QApplication([]) dialog=MyDialog() dialog.show()#함수 출력 app.exec_()# | cs |
btnfunc라는 함수에서 select = self.msgbox.qyestion(self,'팝업','이름을 출력하겠습니까',QMessageBox.Yes,QMessageBox.No)
는 팝업을 띄우고 "팝업"은 팝업의 제목이고 "이름을 출력하시겠습니까?"는 팝업의 글 내용이다 그리고
if select == QMessage.No:
self.label_1.setText("No 눌렀음")
elif select == QMessageBox.Yes:
self.label_1.setText(editname)
if문을 이용해서 no를 눌렀으면 "no를 눌렀음"이라고 출력을 합니다
'Emotion' 카테고리의 다른 글
tensorflow sigmoid를 이용한 경사하강법 (0) | 2018.10.02 |
---|---|
python에서 tensorflow모듈을 이용한 경사하강법 (0) | 2018.09.17 |
c언어를 이용한 갤러그 만들기 (0) | 2018.08.21 |
파이썬을 이용한 마름모 별출력 (0) | 2018.05.16 |
재귀함수를 이용한 피보나치 수열 (0) | 2018.05.02 |
Comments