aboutsummaryrefslogtreecommitdiff
path: root/gui/widgets/money_spinbox.py
blob: 680a432d894deb645673a46233e2b587c452be6b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
from PyQt5.QtWidgets import QDoubleSpinBox


class MoneySpinbox(QDoubleSpinBox):
    def __init__(self):
        super(QDoubleSpinBox, self).__init__()
        self.setPrefix('$')
        self.setMaximum(2**31 - 1)
        self.setMinimum(-self.maximum())

    def get_value(self, ql_type):
        return ql_type(self.value(), self.prefix())

    def on_change(self, change_event_function):
        self.valueChanged.connect(lambda: change_event_function(self))