コード例 #1
0
ファイル: payment_dialog.py プロジェクト: fuinha/openmolar1
    def __init__(self, parent=None):
        ExtendableDialog.__init__(self, parent)
        frame = QtGui.QFrame()
        layout = QtGui.QGridLayout(frame)

        tx_label = QtGui.QLabel(_("Treatment"))
        sundries_label = QtGui.QLabel(_("Sundries"))
        total_label = QtGui.QLabel(_("Total"))

        for label in (tx_label, sundries_label, total_label):
            label.setAlignment(QtCore.Qt.AlignCenter)

        cash_label = QtGui.QLabel(_("Cash"))
        cheque_label = QtGui.QLabel(_("Cheque"))
        card_label = QtGui.QLabel(_("Card"))

        self.cash_le = MoneyLineEdit()
        self.cheque_le = MoneyLineEdit()
        self.card_le = MoneyLineEdit()

        self.cash_but = QtGui.QPushButton("-")
        self.cheque_but = QtGui.QPushButton("-")
        self.card_but = QtGui.QPushButton("-")

        self.cash_but.setFixedWidth(30)
        self.cheque_but.setFixedWidth(30)
        self.card_but.setFixedWidth(30)

        self.cash_sundries_le = MoneyLineEdit()
        self.cheque_sundries_le = MoneyLineEdit()
        self.card_sundries_le = MoneyLineEdit()

        self.cash_tot_label = CurrencyLabel("0.00")
        self.cheque_tot_label = CurrencyLabel("0.00")
        self.card_tot_label = CurrencyLabel("0.00")

        self.tx_tot_label = CurrencyLabel("0.00")
        self.sundries_tot_label = CurrencyLabel("0.00")
        self.grand_tot_label = CurrencyLabel("0.00")

        f = QtGui.QApplication.instance().font()
        f.setBold(True)

        self.grand_tot_label.setFont(f)

        for label in (self.cash_tot_label, self.cheque_tot_label,
                      self.card_tot_label, self.tx_tot_label,
                      self.sundries_tot_label, self.grand_tot_label):
            label.setMinimumWidth(80)

        layout.addWidget(tx_label, 0, 1, 1, 2)
        layout.addWidget(sundries_label, 0, 3)
        layout.addWidget(total_label, 0, 4)

        layout.addWidget(cash_label, 1, 0)
        layout.addWidget(cheque_label, 2, 0)
        layout.addWidget(card_label, 3, 0)

        layout.addWidget(self.cash_le, 1, 1)
        layout.addWidget(self.cheque_le, 2, 1)
        layout.addWidget(self.card_le, 3, 1)

        layout.addWidget(self.cash_but, 1, 2)
        layout.addWidget(self.cheque_but, 2, 2)
        layout.addWidget(self.card_but, 3, 2)

        layout.addWidget(self.cash_sundries_le, 1, 3)
        layout.addWidget(self.cheque_sundries_le, 2, 3)
        layout.addWidget(self.card_sundries_le, 3, 3)

        layout.addWidget(self.cash_tot_label, 1, 4)
        layout.addWidget(self.cheque_tot_label, 2, 4)
        layout.addWidget(self.card_tot_label, 3, 4)

        layout.addWidget(self.tx_tot_label, 4, 1)
        layout.addWidget(self.sundries_tot_label, 4, 3)
        layout.addWidget(self.grand_tot_label, 4, 4)

        self.insertWidget(frame)

        for widg in (self.cash_le, self.cheque_le, self.card_le,
                     self.cash_sundries_le, self.cheque_sundries_le,
                     self.card_sundries_le):
            widg.textEdited.connect(self.update_totals)

        self.cash_but.clicked.connect(self.cash_but_clicked)
        self.cheque_but.clicked.connect(self.cheque_but_clicked)
        self.card_but.clicked.connect(self.card_but_clicked)

        self.misc_payment_widget = MiscPaymentWidget(self)
        self.set_advanced_but_text(_("unusual payments"))
        self.add_advanced_widget(self.misc_payment_widget)
        self.misc_payment_widget.updated.connect(self.update_totals)