주문 시스템 만들기

Untitled

Untitled

Untitled

import sys
from PyQt5.QtWidgets import *
from PyQt5 import uic

form_class = uic.loadUiType('./UI/menu.ui')[0]

class WindowClass(QMainWindow, form_class):
    def __init__(self):
        super().__init__()
        self.setupUi(self)
        self.pushButton.clicked.connect(self.order)

    def order(self):
        a_lst =[]; b_lst = []; total_price = 0
        if self.chkBox_A0.isChecked():
            a_lst.append( self.chkBox_A0.text() )
            total_price += self.get_price(self.lbl_A0.text())
        if self.chkBox_A1.isChecked():
            a_lst.append( self.chkBox_A1.text() )
            total_price += self.get_price( self.lbl_A1.text() )
        if self.chkBox_B0.isChecked():
            b_lst.append( self.chkBox_B0.text() )
            total_price += self.get_price( self.lbl_B0.text() )
        if self.chkBox_B1.isChecked():
            b_lst.append( self.chkBox_B1.text() )
            total_price += self.get_price( self.lbl_B1.text() )
        if self.chkBox_B2.isChecked():
            b_lst.append( self.chkBox_B2.text() )
            total_price += self.get_price( self.lbl_B2.text() )
        
        QMessageBox.information(self, 'Info', f'총 금액은 {total_price}원입니다')
        print('식사 :', a_lst,' 요리 :', b_lst, '를 주문합니다')

    def get_price(self, str_price):
        return int( str_price.replace('원', '').replace(',','') )
    
if __name__ == '__main__':
    app = QApplication(sys.argv)
    myWIndow = WindowClass()
    myWIndow.show()
    app.exec_()

Untitled

Untitled

Untitled

Untitled

Untitled

import sys
from PyQt5.QtWidgets import *
from PyQt5 import uic

form_class = uic.loadUiType('./ui/comboBoxTest.ui')[0]

class WindowClass(QMainWindow, form_class):
    def __init__(self):
        super().__init__()
        self.setupUi(self)
        self.comboBox.currentIndexChanged.connect(self.comboBoxFtn)

    def comboBoxFtn(self):
        self.label.setText( self.comboBox.currentText() )
        print( self.comboBox.currentText(), end='\\t')
        print( self.comboBox.currentIndex() )

if __name__ == '__main__':
    app = QApplication(sys.argv)
    myWIndow = WindowClass()
    myWIndow.show()
    app.exec_()

Untitled

Clear Item click

Clear Item click

Add Item click

Add Item click

Print Item click

Print Item click