Exemple #1
0
    def main(self):
        overview_window = silica.get_window("overview")
        examples_window = silica.get_window("examples")
        hint = self.category_menu.selected_item.hint
        examples_window.draw((0, 0), hint.center(examples_window.screen.width))
        examples_window.visible = not self.example_text_timer.is_expired()

        key = silica.get_keypress()
        self.parse_keypress(key)

        # Draw different border on overview window if on current week
        start_time = datetime_tools.get_start_of_week(self.time_pointer)
        end_time = datetime_tools.get_end_of_week(self.time_pointer)

        if start_time <= datetime_tools.now() <= end_time:
            overview_window.set_theme("double")
        else:
            overview_window.set_theme("normal")

        self.overview_table.render_to_window(overview_window)
        self.draw_category_menu()
        self.draw_selected_week()
        self.draw_text_buffer()
        self.draw_subtotals()

        silica.process()
Exemple #2
0
    def main(self):
        key_pressed = silica.get_keypress()
        if key_pressed == "Q":
            quit()
        elif key_pressed == Key.UP:
            self.sidebar_menu.previous()
        elif key_pressed == Key.DOWN:
            self.sidebar_menu.next()
        elif key_pressed == Key.BACKSPACE:
            self.textbuffer.backspace()
        elif key_pressed == Key.SPACE:
            self.sidebar_menu.toggle_selected_item_checked()

        self.textbuffer.add_keycode(key_pressed)

        main_window = silica.get_window("main_window")
        sidebar = silica.get_window("sidebar")
        overlay = silica.get_window("overlay")

        main_window.draw(
            (1, 1),
            "Press up and down to interact with the menu on the left.",
            colour="white")
        main_window.draw((1, 2),
                         "Type to enter text below:",
                         colour="lightpurple")
        main_window.draw((1, 3), ">> " + self.textbuffer.get())

        screen = Screen(26, 5)
        screen.draw((0, 0), "Blue text", colour="blue")
        screen.draw((0, 1), "Flashing red text")
        screen.draw((0, 2),
                    "Yellow underlined text",
                    underline=True,
                    colour="yellow")
        screen.draw((0, 3), "Reversed flashing red text", reverse=True)
        screen.draw((0, 4),
                    "Cyan underlined bold text",
                    bold=True,
                    underline=True,
                    colour="cyan")

        time_toggle = time.time() * 2 // 1 % 2 == 1
        if time_toggle:
            main_window.draw((2, -6), screen)
        else:
            main_window.draw((2, -6), screen, colour="red")
        overlay.draw((0, 1),
                     str(time.time()).ljust(18).center(overlay.screen.width))

        sidebar_screen = self.sidebar_menu.render(sidebar.width,
                                                  sidebar.height)
        sidebar.draw((1, 1), sidebar_screen)

        silica.process()
Exemple #3
0
    def draw_subtotals(self):
        food_spending = 0
        total_spending = 0

        selected_purchases = self.get_purchases_in_selected_week()
        for purchase in selected_purchases.purchases:
            if purchase.category_name.startswith("Food: "):
                food_spending += float(purchase.cost)
            total_spending += float(purchase.cost)
        overview_window = silica.get_window("overview")
        overview_window.draw((-12, -2), f" Food: ${food_spending:.0f}")
        overview_window.draw((-12, -1), f"Total: ${total_spending:.0f}")
Exemple #4
0
 def draw_selected_week(self):
     time_window = silica.get_window("time")
     date_string_1 = datetime_tools.get_human_readable_string(self.time_pointer)
     date_string_2 = datetime_tools.get_human_readable_string(datetime_tools.get_end_of_week(self.time_pointer))
     date_string = date_string_1 + " - " + date_string_2
     time_window.draw((0, 0), date_string.center(time_window.screen.width))
Exemple #5
0
 def draw_text_buffer(self):
     cat_screen = silica.get_window("cost")
     cat_screen.draw((1, 0), "$ " + self.textbuffer.get())
Exemple #6
0
 def draw_category_menu(self):
     cat_window = silica.get_window("categories")
     width = cat_window.screen.width
     height = cat_window.screen.height
     cat_screen = self.category_menu.render(width, height)
     cat_window.draw((0, 0), cat_screen)