Пример #1
0
 def add(self):
     self.add_widget(loginscreen.LoginScreen(name='LoginScreen'))
     self.add_widget(mainscreen.MainScreen(name='MainScreen'))
     self.add_widget(t)
     self.add_widget(pl)
     self.add_widget(a)
     self.add_widget(ac)
     self.add_widget(a2)
     self.add_widget(t2)
     self.add_widget(registerscreen.RegisterScreen(name='RegisterScreen'))
Пример #2
0
    def __init__(self, handle):
        activity.Activity.__init__(self, handle)
        self.set_title(_("Finance"))
        self.max_participants = 1

        # Initialize database.
        # data
        #   next_id
        #   transactions
        #     id, name, type, amount, date, category
        #   budgets
        #     category, period, amount, budget
        self.data = {'next_id': 0, 'transactions': [], 'budgets': {}}

        self.transaction_map = {}
        self.visible_transactions = []

        self.undo_transaction_map = []
        self.undo_id_map = []

        self.redo_id_map = []
        self.redo_transaction_map = []

        self.transaction_names = {}
        self.category_names = {}

        # Initialize view period to the first of the month.
        self.period = MONTH
        self.period_start = self.get_this_period()

        # Create screens.
        self.register = registerscreen.RegisterScreen(self)
        self.chart = chartscreen.ChartScreen(self)
        self.budget = budgetscreen.BudgetScreen(self)

        self.build_toolbox()

        self.screenbox = Gtk.VBox()

        self.headerbox = self.build_header()
        self._active_panel = None

        # Add the summary data.

        self.startlabel = Gtk.Label()
        self.startamountlabel = Gtk.Label()
        self.creditslabel = Gtk.Label()
        self.debitslabel = Gtk.Label()
        self.balancelabel = Gtk.Label()
        self.balancelabel.props.margin_left = style.DEFAULT_SPACING
        self.balancelabel.props.margin_right = style.DEFAULT_SPACING

        font_size = int(style.FONT_SIZE * 1.25)
        font = Pango.FontDescription("Sans %d" % font_size)
        for label in (self.startlabel, self.startamountlabel,
                      self.creditslabel, self.debitslabel):
            label.modify_font(font)
            label.set_hexpand(True)
            label.set_halign(Gtk.Align.START)
            label.props.margin = style.DEFAULT_PADDING

        self.balance_evbox = Gtk.EventBox()
        self.balance_evbox.add(self.balancelabel)
        summarybox = Gtk.Grid()
        summarybox.attach(self.startlabel, 0, 0, 1, 1)
        summarybox.attach(self.startamountlabel, 0, 1, 1, 1)
        summarybox.attach(self.creditslabel, 1, 0, 1, 1)
        summarybox.attach(self.debitslabel, 1, 1, 1, 1)
        summarybox.attach(self.balance_evbox, 2, 0, 1, 2)
        self.balance_evbox.set_halign(Gtk.Align.END)

        summary_evbox = Gtk.EventBox()
        summary_evbox.add(summarybox)
        summary_evbox.modify_bg(Gtk.StateType.NORMAL,
                                style.Color('#666666').get_gdk_color())
        summary_evbox.set_size_request(-1, style.GRID_CELL_SIZE)

        vbox = Gtk.VBox()

        vbox.pack_start(self.headerbox, False, False, 0)
        vbox.pack_start(self.screenbox, True, True, 0)
        vbox.pack_start(summary_evbox, False, False, 0)

        # Start with the empty screen.
        self.empty_panel = emptypanel.create_empty_panel(
            'row-insert-credit', _('Add some credit or debit to get started!'),
            _('Add credit'), self.__empty_panel_btn_cb)

        self._set_internal_panel(self.empty_panel)

        # This has to happen last, because it calls the read_file
        # method when restoring from the Journal.
        self.set_canvas(vbox)

        self.show_all()
        self.show_header_controls()

        if os.getenv('FINANCE_TEST'):
            self.create_test_data()
            self._set_internal_panel(self.register)
Пример #3
0
    def __init__(self, handle):
        Activity.__init__(self, handle)
        self.set_title(_("Finance"))
        self.max_participants = 1

        # Initialize database.
        # data
        #   next_id
        #   transactions
        #     id, name, type, amount, date, category
        #   budgets
        #     category, period, amount, budget
        self.data = {'next_id': 0, 'transactions': [], 'budgets': {}}

        self.transaction_map = {}
        self.visible_transactions = []

        self.transaction_names = {}
        self.category_names = {}

        #self.create_test_data()

        # Initialize view period to the first of the month.
        self.period = _('Month')
        self.period_start = self.get_this_period()

        # Create screens.
        self.register = registerscreen.RegisterScreen(self)
        self.chart = chartscreen.ChartScreen(self)
        self.budget = budgetscreen.BudgetScreen(self)

        self.build_toolbox()

        self.screens = []
        self.screenbox = Gtk.VBox()

        # Add the context sensitive help.
        self.helplabel = Gtk.Label()
        self.helplabel.set_padding(10, 10)
        self.helpbox = Gtk.EventBox()
        parse, color = Gdk.Color.parse('#000000')
        self.helpbox.modify_bg(Gtk.StateType.NORMAL, color)
        self.helpbox.add(self.helplabel)

        # Add the header.
        self.periodlabel = Gtk.Label()
        self.periodlabel.set_padding(10, 0)

        headerbox = Gtk.HBox()
        headerbox.pack_end(self.periodlabel, False, False, 0)

        # Add the summary data.
        self.startlabel = Gtk.Label()
        self.creditslabel = Gtk.Label()
        self.debitslabel = Gtk.Label()
        self.balancelabel = Gtk.Label()

        summarybox = Gtk.HBox()
        summarybox.pack_start(self.startlabel, True, False, 0)
        summarybox.pack_start(self.creditslabel, True, False, 0)
        summarybox.pack_start(self.debitslabel, True, False, 0)
        summarybox.pack_start(self.balancelabel, True, False, 0)

        vbox = Gtk.VBox()

        vbox.pack_start(self.helpbox, False, False, 10)
        vbox.pack_start(headerbox, False, False, 10)
        vbox.pack_start(Gtk.Separator(orientation=Gtk.Orientation.VERTICAL),
                        False, False, 0)
        vbox.pack_start(self.screenbox, True, True, 0)
        vbox.pack_start(summarybox, False, False, 10)

        # Start with the main screen.
        self.push_screen(self.register)

        # This has to happen last, because it calls the read_file
        # method when restoring from the Journal.
        self.set_canvas(vbox)

        self.show_all()