티스토리 뷰

QMessageBox

예제

import sys


from PyQt5 import QtWidgets

from PyQt5.QtCore import pyqtSignal

from PyQt5.QtWidgets import QMessageBox

from PyQt5.QtWidgets import QPushButton

from PyQt5.QtWidgets import QWidget


################################################################################

class ValvePopup(QWidget):

    # Signal 선언부

    send_valve_popup_signal = pyqtSignal(bool, name='sendValvePopupSignal')


    # ==========================================================================

    def __init__(self, parent=None):

        QWidget.__init__(self, parent)

        self.accept_button = QPushButton()

        self.cancel_button = QPushButton()

        self.init_ui()


    # ==========================================================================

    def init_ui(self):

        pass


    # ==========================================================================

    def show_popup_ok_cancel(self, title: str, content: str):

        msg = QMessageBox()

        msg.setWindowTitle(title)

        msg.setText(content)

        msg.setStandardButtons(QMessageBox.Cancel | QMessageBox.Ok)

        result = msg.exec_()

        if result == QMessageBox.Cancel:

            self.send_valve_popup_signal.emit(False)

        elif result == QMessageBox.Ok:

            self.send_valve_popup_signal.emit(True)


    # ==========================================================================

    def show_popup_ok(self, title: str, content: str):

        msg = QMessageBox()

        msg.setWindowTitle(title)

        msg.setText(content)

        msg.setStandardButtons(QMessageBox.Ok)

        result = msg.exec_()

        if result == QMessageBox.Ok:

            self.send_valve_popup_signal.emit(True)



if __name__ == '__main__':

    app = QtWidgets.QApplication(sys.argv)

    w = ValvePopup()

    w.show()

    sys.exit(app.exec())

'Develop > Python' 카테고리의 다른 글

[Python] 변수에 메서드 할당하기  (0) 2018.06.10
라즈베리파이 우분투에 Python 설치하기  (2) 2018.05.20
[PyQt] 설치 및 .ui 사용하는 법  (0) 2018.04.08
[Python] 전역 변수  (0) 2018.04.01
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2024/05   »
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 30 31