示例#1
0
    def __init__(self, start_time = None):
        graphics.Scene.__init__(self)
        self.set_can_focus(False) # no interaction

        self.day_start = conf.day_start

        start_time = start_time or dt.datetime.now()

        self.view_time = start_time or dt.datetime.combine(start_time.date(), self.day_start)

        self.scope_hours = 24


        self.fact_bars = []
        self.categories = []

        self.connect("on-enter-frame", self.on_enter_frame)

        self.plot_area = graphics.Sprite(y=15)

        self.chosen_selection = Selection()
        self.plot_area.add_child(self.chosen_selection)

        self.drag_start = None
        self.current_x = None

        self.date_label = graphics.Label(color=self._style.get_color(gtk.StateFlags.NORMAL),
                                         x=5, y=16)

        self.add_child(self.plot_area, self.date_label)
示例#2
0
    def __init__(self,
                 max_bar_width=20,
                 legend_width=70,
                 value_format="%.2f",
                 interactive=True):
        graphics.Scene.__init__(self)

        self.selected_keys = []  # keys of selected bars

        self.bars = []
        self.labels = []
        self.data = None

        self.max_width = max_bar_width
        self.legend_width = legend_width
        self.value_format = value_format
        self.graph_interactive = interactive

        self.plot_area = graphics.Sprite(interactive=False)
        self.add_child(self.plot_area)

        self.bar_color, self.label_color = None, None

        self.connect("on-enter-frame", self.on_enter_frame)

        if self.graph_interactive:
            self.connect("on-mouse-over", self.on_mouse_over)
            self.connect("on-mouse-out", self.on_mouse_out)
            self.connect("on-click", self.on_click)
示例#3
0
    def __init__(self):
        graphics.Scene.__init__(self)
        self.set_size_request(200, 70)
        self.category_totals = layout.Label(color=self._style.get_color(
            gtk.StateFlags.NORMAL),
                                            overflow=pango.EllipsizeMode.END,
                                            x_align=0,
                                            expand=False)
        self.stacked_bar = StackedBar(height=25, x_align=0, expand=False)

        box = layout.VBox(padding=10, spacing=5)
        self.add_child(box)

        box.add_child(self.category_totals, self.stacked_bar)

        self.totals = {}
        self.mouse_cursor = gdk.CursorType.HAND2

        self.instructions_label = layout.Label(_("Click to see stats"),
                                               color=self._style.get_color(
                                                   gtk.StateFlags.NORMAL),
                                               padding=10,
                                               expand=False)

        box.add_child(self.instructions_label)
        self.collapsed = True

        main = layout.HBox(padding_top=10)
        box.add_child(main)

        self.stub_label = layout.Label(
            markup="<b>Here be stats,\ntune in laters!</b>",
            color="#bbb",
            size=60)

        self.activities_chart = HorizontalBarChart()
        self.categories_chart = HorizontalBarChart()
        self.tag_chart = HorizontalBarChart()

        main.add_child(self.activities_chart, self.categories_chart,
                       self.tag_chart)

        # for use in animation
        self.height_proxy = graphics.Sprite(x=0)
        self.height_proxy.height = 70
        self.add_child(self.height_proxy)

        self.connect("on-click", self.on_click)
        self.connect("enter-notify-event", self.on_mouse_enter)
        self.connect("leave-notify-event", self.on_mouse_leave)