示例#1
0
    def __init__(self):
        graphics.Scene.__init__(self)

        self.boxes = []

        classes = Easing()
        for i, easing_class in enumerate(dir(Easing)):
            if easing_class.startswith("__") == False:
                the_class = classes.__getattribute__(easing_class)

                label = graphics.Label(easing_class,
                                       color="#333",
                                       x=10,
                                       y=i * 49 + 40)
                self.add_child(label)

                box = EasingBox(easing_class, 90, i * 49 + 30, the_class)
                self.add_child(box)
                self.boxes.append(box)

                label = graphics.Label(easing_class,
                                       color="#333",
                                       x=350,
                                       y=i * 49 + 40)
                self.add_child(label)

        self.connect("on-click", self.on_click)
示例#2
0
    def __init__(self, progress):
        graphics.Scene.__init__(self, scale=True, keep_aspect=True)
        self.progress = progress

        self.wheel = graphics.Circle(200,
                                     200,
                                     "#aaa",
                                     x=20,
                                     y=20,
                                     interactive=True,
                                     pivot_x=100,
                                     pivot_y=100)
        self.add_child(self.wheel)
        self.add_child(
            graphics.Circle(50, 50, "#fafafa", x=95, y=95, interactive=True))

        self.ticker = graphics.Label("*tick*",
                                     size=24,
                                     color="#000",
                                     x=5,
                                     y=220,
                                     opacity=0)
        self.ticker.last_degrees = 0
        self.add_child(self.ticker)

        self.connect("on-mouse-move", self.on_mouse_move)
        self.connect("on-mouse-down", self.on_mouse_down)
        self.connect("on-mouse-up", self.on_mouse_up)

        self.drag_point = None
        self.start_rotation = None
示例#3
0
 def __init__(self):
     graphics.Scene.__init__(self)
     self.text = ""
     self.label = graphics.Label(self.text, 10)
     self.label.wrap = pango.WRAP_WORD
     self.add_child(self.label)
     self.connect("on-enter-frame", self.on_enter_frame)
示例#4
0
文件: ut.py 项目: skeptycal/ut-lab
    def __init__(self, text, icon=None, **kwargs):
        graphics.Sprite.__init__(self, interactive=True, **kwargs)

        self._style = gtk.MenuItem().rc_get_style()

        self.font_desc = pango.FontDescription(
            gtk.Style().font_desc.to_string())
        self.font_desc.set_size(12 * pango.SCALE)

        self.fill = self._style.bg[gtk.STATE_NORMAL]
        self.over = self._style.bg[gtk.STATE_SELECTED]
        self.out = self._style.bg[gtk.STATE_NORMAL]
        self.text_color = self._style.text[gtk.STATE_NORMAL]
        self.width = 120
        self.height = 24

        self.icon_sprite = graphics.Icon(icon)
        self.add_child(self.icon_sprite)

        self.label_sprite = graphics.Label(text, color=self.text_color, x=26)
        self.add_child(self.label_sprite)
        self._over = False
        self._clicked = False

        self.connect("on-mouse-over", self.on_mouse_over)
        self.connect("on-mouse-out", self.on_mouse_out)
        self.connect('on-click', self.on_button_press_event)
        self.connect("on-render", self.on_render)
示例#5
0
    def __init__(self):
        graphics.Scene.__init__(self)

        self.add_child(graphics.Label("Red is old, blue is new.", 12, "#666", x=5, y=5))

        y = 50
        x = 90
        for func in Easing.__dict__:
            if func.startswith("_") == False:
                self.add_child(graphics.Label(func, 12, "#666", x = x - 80, y = y + 25))
                self.add_child(OldTweenGraph(EasingOld.__dict__[func], y = y, x = x))
                self.add_child(TweenGraph(Easing.__dict__[func], y = y, x = x, opacity=0.5))

                y += 90

                if y > 500:
                    x += 450
                    y = 50
    def __init__(self):
        graphics.Scene.__init__(self)

        storage = hamster.client.Storage()

        self.day_counts = {}
        categories = defaultdict(int)

        self.colors = ("#20b6de", "#fff", "#333", "#ff0", "#0ff")

        self.container = graphics.Sprite()
        self.add_child(self.container)

        self.start_date_label = graphics.Label(color = "#000")
        self.add_child(self.start_date_label)


        facts = storage.get_facts(dt.date(2006,1,1), dt.datetime.now())
        facts_per_category = defaultdict(list)
        categories = defaultdict(int)

        #facts = [fact for fact in facts if fact.category in ('work', 'hacking')]

        for category, facts in itertools.groupby(sorted(facts, key=lambda fact:fact.category), lambda fact:fact.category):
            for day, day_facts in itertools.groupby(sorted(facts, key=lambda fact:fact.date), lambda fact:fact.date):
                delta = dt.timedelta()
                for fact in day_facts:
                    delta += fact.delta
                delta = delta.seconds / 60 / 60 + delta.days * 24

                facts_per_category[category].append((day, delta))

            categories[category] += 1


        self.categories = categories.keys()


        self.spirals = []
        self.start_date = dt.date(2006, 1, 1)

        for i, category in enumerate(categories):
            ring = TimeRing(facts_per_category[category],
                            self.start_date,
                            self.colors[i + 1])
            ring.min_radius = i * 20 + 0
            ring.width = len(self.categories) * 30

            #self.animate(ring, 3, width = len(self.categories) * 30, easing = pytweener.Easing.Expo.ease_out)
            self.container.add_child(ring)
            self.spirals.append(ring)

        self.connect("on-enter-frame", self.on_enter_frame)
        self.connect("on-mouse-move", self.on_mouse_move)
        self.connect("on-scroll", self.on_scroll)
    def __init__(self):
        graphics.Scene.__init__(self)

        self.add_child(graphics.Label("Move mouse to change the size of the ellipse", 10, "#666", x = 5, y = 5))

        self.ellipse = Ellipse(50, 50, 100, 200)
        self.ellipse.pivot_x, self.ellipse.pivot_y = 50, 100 #center
        self.add_child(self.ellipse)


        self.connect("on-enter-frame", self.on_enter_frame)
        self.connect("on-mouse-move", self.on_mouse_move)
    def __init__(self):
        graphics.Sprite.__init__(self, draggable=True)

        #self.graphics.circle(25, 25, 15)
        label = graphics.Label("Drag me around!", 24, "#fff")
        self.add_child(label)

        self.graphics.rectangle(0, 0, label.width, label.height)
        self.graphics.new_path()

        #self.graphics.fill_area(5, 5, 80, 80, "#fff")

        self.connect("on-render", self.on_render)
示例#9
0
    def __init__(self):
        graphics.Scene.__init__(self)


        # letter display
        letter_display = graphics.Sprite(x=100)
        self.letter = graphics.Label(x=30, y = 40, text="F", size=200, color="#333")
        letter_display.add_child(self.letter)

        self.add_child(letter_display)


        # cell board
        cellboard = graphics.Sprite(x=450)
        self.letter_cell = BrailCell("f", x = 50, y=50, width = 200, interactive = True)
        cellboard.add_child(self.letter_cell)

        for i in range(2):
            for j in range(3):
                cellboard.add_child(graphics.Label(str(j + 1 + i * 3),
                                                   size = 50,
                                                   color = "#333",
                                                   x = i * 230 + 20,
                                                   y = j * 90 + 60))

        self.add_child(cellboard)

        # lowerboard
        lowerboard = graphics.Sprite(x=50, y = 450)
        cell_width = 40
        for i, letter in enumerate(string.ascii_uppercase[:13]):
            tile = BrailTile(letter = letter, cell_width = cell_width, x = i * (cell_width + 10) + 10)
            tile.connect("on-click", self.on_tile_click)
            lowerboard.add_child(tile)

        self.add_child(lowerboard)
示例#10
0
    def __init__(self, letter, cell_width, **kwargs):
        graphics.Sprite.__init__(self, **kwargs)

        self.letter = letter

        mouse_rectangle = graphics.Rectangle(cell_width, cell_width * 1.4, 7, stroke="#000", interactive = True)
        self.add_child(mouse_rectangle)

        mouse_rectangle.connect("on-mouse-over", self.on_mouse_over)
        mouse_rectangle.connect("on-mouse-out", self.on_mouse_out)
        mouse_rectangle.connect("on-click", self.on_click)

        self.add_child(BrailCell(letter, width = cell_width))
        self.add_child(graphics.Label(letter, size = 14, color="#000",
                                      x = 12, y = cell_width * 1.4 + 5))
示例#11
0
 def create_label_total(self, area, alto_label, alto_bar):
     """
     Crea la etiqueta que mostrará las horas asignadas al la línea dentro 
     del rango representado (que es un subconjunto del self.data).
     """
     tareas_area_rango = [t for t in self.data if
         t.area == area 
         and t.fecha >= self.start_datetime
         and t.fecha < self.end_datetime]
     total = area.calcular_horas_asignadas(tareas_area_rango)
     txttotal = str(int(total))
     label_total = graphics.Label(txttotal, alto_label, "#333", 
                             visible = True)
     self.labels["totales"][area] = label_total
     # Para label_total.x tengo que esperar a medir el offset_totales.
     label_total.y = 27 + self.lineas.index(area) * alto_bar
     self.add_child(label_total)
     ancho_label_total = label_total.measure(txttotal)[0]
     return ancho_label_total
示例#12
0
 def pintar_linea_vertical(self, cur_x, altura = None, label = None, 
                           label_center = False):
     if altura is None:
         altura = self.height
     vline = graphics.Rectangle(1, altura, fill= "#000")
     vline.x = cur_x
     vline.y = self.height - altura
     self.grid.append(vline)
     self.add_child(vline)
     if label:   # Añado arriba del todo una etiqueta con el texto recibido.
         ldia = graphics.Label(label, 10, "#999", visible = True)
         self.labels["días"][label] = ldia
         self.add_child(ldia)
         if not label_center:
             ldia.x = cur_x + 2
             ldia.y = 3
         else:
             ldia.x = cur_x - (ldia.measure(label)[0] / 2)
             ldia.y = 13
示例#13
0
    def __init__(self):
        graphics.Scene.__init__(self)

        self.thing = Thing()
        self.rotator = Rotator(x=self.thing.pivot_x, y=self.thing.pivot_y)

        self.add_child(self.thing)

        self.add_child(graphics.Label("Drag to rotate", size=24, color="#999"))
        self.rotating = True

        self.connect("on-drag-start", self.on_drag_start)
        self.connect("on-drag-finish", self.on_drag_finish)

        self.connect("on-mouse-move", self.on_mouse_move)
        self.connect("on-mouse-down", self.on_mouse_down)
        self.connect("on-mouse-up", self.on_mouse_up)

        self.drag_point = None
        self.start_rotation = None
示例#14
0
 def create_label_empleado(self, empleado, alto_label, alto_bar, 
                           offset_totales):
     """
     Crea y coloca tanto el label del empleado como la línea horizontal.
     """
     nombre = empleado.nombre
     lnombre = graphics.Label(nombre, alto_label, "#333", visible = True)
     self.labels["empleados"][empleado] = lnombre
     lnombre.x = 0
     lnombre.y = 27 + self.empleados.index(empleado) * alto_bar
     self.add_child(lnombre)
     hline = graphics.Rectangle(self.width +  offset_totales, 1, 
                                fill = "#000")
     hline.x = 0
     hline.y = lnombre.y
     self.grid.append(hline)
     self.add_child(hline)
     ancho_label_nombre = lnombre.measure(nombre)[0]
     self.coords_y[lnombre.y] = empleado
     return ancho_label_nombre
示例#15
0
    def __init__(self, text, interactive=True, color="#F1EAAA"):
        graphics.Sprite.__init__(self, interactive=interactive)

        self.width, self.height = 0, 0

        font = gtk.Style().font_desc
        font_size = int(font.get_size() * 0.8 / pango.SCALE)  # 80% of default

        self.label = graphics.Label(text,
                                    size=font_size,
                                    color=(30, 30, 30),
                                    y=1)
        self.color = color
        self.add_child(self.label)

        self.corner = int((self.label.height + 3) / 3) + 0.5
        self.label.x = self.corner + 6

        self.text = stuff.escape_pango(text)
        self.connect("on-render", self.on_render)
示例#16
0
 def create_label_area(self, area, alto_label, alto_bar, 
                           offset_totales):
     """
     Crea y coloca tanto el label del area como la línea horizontal.
     """
     nombre = area.nombre or ""
     lnombre = graphics.Label(nombre, alto_label, "#333", visible = True)
     self.labels["lineas"][area] = lnombre
     lnombre.x = 0
     lnombre.y = 27 + self.lineas.index(area) * alto_bar
     self.add_child(lnombre)
     hline = graphics.Rectangle(self.width +  offset_totales, 1, 
                                fill = "#000")
     hline.x = 0
     hline.y = lnombre.y
     self.grid.append(hline)
     self.add_child(hline)
     ancho_label_nombre = lnombre.measure(nombre)[0]
     self.coords_y[lnombre.y] = area
     return ancho_label_nombre
示例#17
0
    def __init__(self):
        graphics.Scene.__init__(self)

        self.connect("on-mouse-over", self.on_mouse_over)
        self.connect("on-mouse-out", self.on_mouse_out)
        self.connect("on-mouse-up", self.on_mouse_up)
        self.connect("on-mouse-move", self.on_mouse_move)
        self.connect("on-enter-frame", self.on_enter_frame)
        self.cache_as_bitmap = True
        self.paint_color = None
        self.add_child(
            graphics.Rectangle(600, 40, 4, "#666", opacity=0.8,
                               z_order=999998))
        self.fps_label = graphics.Label(size=20,
                                        color="#fff",
                                        z_order=999999,
                                        x=10,
                                        y=4)
        self.add_child(self.fps_label)
        self.bubbles = []
        self.max_zorder = 1
示例#18
0
 def create_label_total(self, empleado, alto_label, alto_bar):
     """
     Crea la etiqueta que mostrará las horas asignadas al empleado dentro 
     del rango representado (que es un subconjunto del self.data).
     """
     tareas_empleado_rango = [t for t in self.data if
         t.empleado == empleado 
         and t.fecha >= self.start_datetime
         and t.fecha < self.end_datetime]
     tareas_empleado = [t for t in self.data if t.empleado == empleado]
     total = empleado.calcular_horas_asignadas(tareas_empleado_rango)
     total_totaloso = empleado.calcular_horas_asignadas(tareas_empleado)
     txttotal = "%d (%d)" % (int(total), int(total_totaloso))
     label_total = graphics.Label(txttotal, alto_label, "#333", 
                             visible = True)
     self.labels["totales"][empleado] = label_total
     # Para label_total.x tengo que esperar a medir el offset_totales.
     label_total.y = 27 + self.empleados.index(empleado) * alto_bar
     self.add_child(label_total)
     ancho_label_total = label_total.measure(txttotal)[0]
     return ancho_label_total
示例#19
0
    def __init__(self):
        graphics.Scene.__init__(self)

        self.tweener.default_duration = 0.1

        self.total_hours = 24
        self.height = 500
        self.pixels_in_minute = float(self.height) / (self.total_hours * 60)

        self.spacing = 1

        self.fact_list = graphics.Sprite(x=40, y=50)
        self.add_child(self.fact_list)

        self.fragments = Container(30)

        self.connectors = graphics.Sprite(x=self.fragments.x +
                                          self.fragments.width)
        self.connectors.width = 30

        self.entries = Container(500,
                                 x=self.connectors.x + self.connectors.width)

        self.fact_list.add_child(self.fragments, self.connectors, self.entries)

        self.storage = hamster.client.Storage()

        self._date = dt.datetime.combine(dt.date.today(),
                                         dt.time()) + dt.timedelta(hours=5)

        self.date_label = graphics.Label("", size=18, y=10, color="#444")
        self.add_child(self.date_label)

        self.entry_positions = []

        self.set_size_request(610, 500)

        self.current_entry = None

        self.connect("on-enter-frame", self.on_enter_frame)
示例#20
0
    def new_graph(self):
        self.clear()
        self.display_nodes = []
        self.add_child(
            graphics.Label(
                "Click on screen to add node. Right-click to stop the thread from going on",
                color="#666",
                x=10,
                y=10))

        self.edge_buffer = []

        if not self.graph:
            self.graph = Graph(self.width, self.height)
        else:
            self.graph.populate_nodes(self.width, self.height)
            self.queue_relayout()

        for node in self.graph.nodes:
            self.add_node(node.x, node.y, node)

        self.update_buffer()

        self.redraw()
    def new_graph(self):
        self.clear()
        self.display_nodes = []
        self.add_child(
            graphics.Label(
                "Click on screen to add nodes. After that you can drag them around",
                color="#666",
                x=10,
                y=10))

        self.edge_buffer = []

        if not self.graph:
            self.graph = Graph(self.width, self.height)
        else:
            self.graph.populate_nodes(self.width, self.height)
            self.queue_relayout()

        for node in self.graph.nodes:
            self.add_node(node.x, node.y, node)

        self.update_buffer()

        self.redraw()
示例#22
0
    def __init__(self):
        graphics.Scene.__init__(self)
        self.nodes = []
        self.centres = []

        self.edges = []

        self.edge_dict = {}

        self.points = [
        ]  # [Vector2(-10000, -10000), Vector2(10000, -10000), Vector2(0, 10000)]

        self.connect("on-enter-frame", self.on_enter_frame)
        self.connect("on-click", self.on_mouse_click)
        self.connect("on-drag", self.on_node_drag)

        self.add_child(
            graphics.Label(
                "Add some points and observe Delaunay triangulation",
                x=5,
                y=5,
                color="#666"))

        self.draw_circles = False
示例#23
0
    def __init__(self,
                 text="",
                 draw_border=True,
                 valid_chars=None,
                 validate_on_type=True,
                 single_paragraph=True,
                 text_formatter=None,
                 alignment=None,
                 font_desc=None,
                 **kwargs):
        Bin.__init__(self, **kwargs)

        self.display_label = graphics.Label(color=self.color)

        self.viewport = Viewport(self.display_label)
        self.viewport.connect("on-render", self.__on_viewport_render)

        self.add_child(self.viewport)

        self.can_focus = True

        self.interactive = True

        self.editable = True

        #: current cursor position
        self.cursor_position = None

        #: start position of the selection
        self.selection_start = 0

        #: end position of the selection
        self.selection_end = 0

        if font_desc is not None:
            self.font_desc = font_desc
        self.display_label.font_desc = self.font_desc

        #: text alignment in the entry
        self.alignment = alignment

        #: if True, a border will be drawn around the input element
        self.draw_border = draw_border

        #self.connect("on-key-press", self.__on_key_press)
        self.connect("on-mouse-down", self.__on_mouse_down)
        self.connect("on-double-click", self.__on_double_click)
        self.connect("on-triple-click", self.__on_triple_click)
        self.connect("on-blur", self.__on_blur)
        self.connect("on-focus", self.__on_focus)

        self.connect_after("on-render", self.__on_render)

        self._scene_mouse_move = None
        self._scene_mouse_up = None
        self._selection_start_position = None
        self._letter_positions = []

        #: a string, function or regexp or valid chars for the input
        #: in case of function, it will receive the string to be tested
        #: as input and expects to receive back a boolean of whether the string
        #: is valid or not
        self.valid_chars = valid_chars

        #: should the content be validate right when typing and invalid version prohibited
        self.validate_on_type = validate_on_type

        #: function to style the entry text - change color and such
        #: the function receives one param - the text, and must return
        #: processed text back. will be using original text if the function
        #: does not return anything.
        #: Note: this function can change only the style, not the actual content
        #: as the latter will mess up text selection because of off-sync between
        #: the label value and what is displayed
        self.text_formatter = text_formatter if text_formatter else self.text_formatter

        #: should the text input support multiple lines
        self.single_paragraph = single_paragraph

        self.update_text(text)
        self._last_good_value = text  # last known good value of the input
示例#24
0
    def __init__(self, width, fact, color, **kwargs):
        graphics.Sprite.__init__(self, **kwargs)
        self.width = width
        self.height = 27
        self.natural_height = 27
        self.fact = fact
        self.color = color

        self.interactive = True
        self.mouse_cursor = gdk.CursorType.XTERM

        self.fact_labels = graphics.Sprite()

        self.start_label = graphics.Label("",
                                          color="#333",
                                          size=11,
                                          x=10,
                                          y=5,
                                          interactive=True,
                                          mouse_cursor=gdk.CursorType.XTERM)
        self.start_label.text = "%s - " % fact.start_time.strftime("%H:%M")
        self.fact_labels.add_child(self.start_label)

        self.end_label = graphics.Label("",
                                        color="#333",
                                        size=11,
                                        x=65,
                                        y=5,
                                        interactive=True,
                                        mouse_cursor=gdk.CursorType.XTERM)
        if fact.end_time:
            self.end_label.text = fact.end_time.strftime("%H:%M")
        self.fact_labels.add_child(self.end_label)

        self.activity_label = graphics.Label(fact.activity,
                                             color="#333",
                                             size=11,
                                             x=120,
                                             y=5,
                                             interactive=True,
                                             mouse_cursor=gdk.CursorType.XTERM)
        self.fact_labels.add_child(self.activity_label)

        self.category_label = graphics.Label("",
                                             color="#333",
                                             size=9,
                                             y=7,
                                             interactive=True,
                                             mouse_cursor=gdk.CursorType.XTERM)
        self.category_label.text = stuff.escape_pango(" - %s" % fact.category)
        self.category_label.x = self.activity_label.x + self.activity_label.width
        self.fact_labels.add_child(self.category_label)

        self.duration_label = graphics.Label(stuff.format_duration(fact.delta),
                                             size=11,
                                             color="#333",
                                             interactive=True,
                                             mouse_cursor=gdk.CursorType.XTERM)
        self.duration_label.x = self.width - self.duration_label.width - 5
        self.duration_label.y = 5
        self.fact_labels.add_child(self.duration_label)

        self.add_child(self.fact_labels)

        self.edit_links = graphics.Sprite(x=10, y=110, opacity=0)

        self.delete_link = graphics.Label("Delete",
                                          size=11,
                                          color="#555",
                                          interactive=True)
        self.save_link = graphics.Label("Save",
                                        size=11,
                                        x=390,
                                        color="#555",
                                        interactive=True)
        self.cancel_link = graphics.Label("Cancel",
                                          size=11,
                                          x=440,
                                          color="#555",
                                          interactive=True)
        self.edit_links.add_child(self.delete_link, self.save_link,
                                  self.cancel_link)

        self.add_child(self.edit_links)

        for sprite in self.fact_labels.sprites:
            sprite.connect("on-click", self.on_sprite_click)

        self.connect("on-render", self.on_render)
        self.connect("on-click", self.on_click)
示例#25
0
    def __init__(self):
        now = dt.datetime.now()

        graphics.Scene.__init__(self)

        self.notebook = ui.Notebook(tab_position = "top-left", scroll_position="end", show_scroll = "auto_invisible", scroll_selects_tab = False)

        # boxes packed and nested horizontally and vertically, with a draggable corner
        self.box = ui.HBox(spacing = 3, x=10, y=10)
        self.button = ui.Button("My image changes position", image = graphics.Image("assets/hamster.png"), fill = False)
        self.button.connect("on-click", self.on_button_click)

        self.box.add_child(*[ui.VBox([self.button,
                                      ui.ToggleButton("I'm a toggle button! Have a tooltip too!", image = graphics.Image("assets/day.png"), fill = True, tooltip="Oh hey there, i'm a tooltip!"),
                                      ui.Label("I'm a label \nand we all can wrap", image = graphics.Image("assets/week.png"), spacing = 5, padding = 5, x_align = 0),
                                      ui.Entry("Feel free to edit me! I'm a rather long text that will scroll nicely perhaps. No guarantees though!", expand = False),
                                      ui.Entry("And me too perhaps", expand = False)],
                                     spacing = 5, padding = 10),
                             Rectangle(20, expand = False),
                             graphics.Label("rrrr", color="#666"),
                             Rectangle(20, expand = False),
                             ui.VBox([Rectangle(fill = False), Rectangle(), Rectangle()], spacing = 3)
                             ])


        box_w, box_h = self.box.get_min_size()
        self.corner = graphics.Rectangle(10, 10, fill="#666",
                                         x = self.box.x + box_w,
                                         y = self.box.y + box_h,
                                         draggable=True,
                                         interactive=True,
                                         z_order = 100)
        self.corner.connect("on-drag", self.on_corner_drag)


        # a table
        self.table = ui.Table(3, 3, snap_to_pixel = False, padding=10)
        self.table.attach(Rectangle(fill_color = "#f00", expand_vert = False), 0, 3, 0, 1) # top
        self.table.attach(Rectangle(fill_color = "#0f0", expand = False), 2, 3, 1, 2)      # right
        self.table.attach(Rectangle(fill_color = "#f0f", expand_vert = False), 0, 3, 2, 3) # bottom
        self.table.attach(Rectangle(fill_color = "#0ff", expand = False), 0, 1, 1, 2)      # left
        center = Rectangle()
        center.connect("on-mouse-over", self.on_table_mouse_over)
        center.connect("on-mouse-out", self.on_table_mouse_out)
        self.table.attach(center, 1, 2, 1, 2)


        # a scroll area with something to scroll in it
        self.scroll = ui.ScrollArea(border = 0)
        self.scroll.add_child(ui.Container(ui.Button("Scroll me if you can!", width = 1000, height = 300, fill=False), fill = False, padding=15))


        # bunch of different input elements
        inputs = ui.Panes(padding=10)
        listitem = ui.ListItem(["Sugar", "Spice", "Everything Nice", "--", "Feel",
                                "Free", "To", "Click", "On", "Me", {'markup': "<span color='red'>And</span>"},
                                "Use", "The", "Arrows!", "Ah", "And", "It", "Seems",
                                "That", "There", "Are", "So", "Many", "Elements"])

        def print_selection(listitem, item):
            print "selection", item

        def print_change(listitem, item):
            print "change", item

        listitem.connect("on-change", print_change)
        listitem.connect("on-select", print_selection)
        inputs.add_child(listitem)

        one = ui.ToggleButton("One", margin=[15, 10, 20, 30], id="one")

        group1 = ui.Group([one,
                           ui.ToggleButton("Two", scale_x = 0.5, scale_y = 0.5, expand=False, id="two"),
                           ui.ToggleButton("Three", id="three"),
                           ui.ToggleButton("Four", id="four")],
                          expand = False, allow_no_selection=True)
        label1 = ui.Label("Current value: none selected", x_align=0, expand = False)
        def on_toggle1(group, current_item):
            if current_item:
                label1.text = "Current value: %s" % current_item.label
            else:
                label1.text = "No item selected"
        group1.connect("on-change", on_toggle1)

        group2 = ui.Group([ui.RadioButton("One"),
                           ui.RadioButton("Two"),
                           ui.RadioButton("Three"),
                           ui.RadioButton("Four")],
                          horizontal = False)
        label2 = ui.Label("Current value: none selected", x_align = 0, expand=False)
        def on_toggle2(group, current_item):
            label2.text = "Current value: %s" % current_item.label
        group2.connect("on-change", on_toggle2)

        slider = ui.Slider(range(100),
                           expand = False,
                           snap_to_ticks = False,
                           range=True,
                           selection=(23, 80),
                           grips_can_cross = False,
                           snap_points = [5, 20, 50, 75],
                           snap_on_release = True)
        slider_value = ui.Label(" ")
        def on_slider_change(slider, value):
            slider_value.text = str(value)
        slider.connect("on_change", on_slider_change)

        spinner = ui.Spinner(active = False, expand=False, width = 40)
        spinner_button = ui.Button("Toggle spin", expand=False)
        spinner_button.spinner = spinner

        def on_spinner_button_click(button, event):
            button.spinner.active = not button.spinner.active
        spinner_button.connect("on-click", on_spinner_button_click)

        combo = ui.ComboBox(["Sugar", "Spice", "Everything Nice", "And", "Other", "Nice", "Things"],
                             open_below=True,
                             expand = False)
        inputs.add_child(ui.VBox([combo,
                                  group1, label1,
                                  ui.HBox([group2,
                                           ui.VBox([ui.CheckButton("And a few of those", expand = False),
                                                    ui.CheckButton("Check boxes", expand = False),
                                                    ui.CheckButton("Which don't work for groups", expand = False)])
                                          ]),
                                  label2,
                                  slider,
                                  slider_value,
                                  ui.HBox([spinner, spinner_button], expand=False, spacing = 10),
                                  ui.HBox([ui.ScrollArea(ui.Label(sample_text * 3, overflow = pango.WrapMode.WORD, fill=True, padding=[2, 5]), height=45, scroll_horizontal=False),
                                           ui.SpinButton(expand = False, fill=False)], expand = False),
                                  ],
                                 expand = False, spacing = 10))

        combo.rows = ["some", "things", "are", "made", "of", "bananas", "and", "icecream"]


        menu = ui.Menu([ui.MenuItem(label="One", menu=ui.Menu([ui.MenuItem(label="One one", menu=ui.Menu([ui.MenuItem(label="One one one"),
                                                                                                          ui.MenuItem(label="One one two"),
                                                                                                          ui.MenuSeparator(),
                                                                                                          ui.MenuItem(label="One one three")])),
                                                               ui.MenuSeparator(),
                                                               ui.MenuItem(label="One two", mnemonic="Ctrl+1"),
                                                               ui.MenuItem(label="One three", mnemonic="Alt+1")])),

                        ui.MenuItem(label="Two", menu=ui.Menu([ui.MenuItem(label="Two one", mnemonic="Ctrl+Alt+2"),
                                                               ui.MenuItem(label="Two two", mnemonic="Ctrl+2"),
                                                               ui.MenuSeparator(),
                                                               ui.MenuItem(label="Two three", mnemonic="Alt+2")])),

                        ui.MenuItem(label="Three", menu=ui.Menu([ui.MenuItem(label="Three one", mnemonic="Ctrl+Alt+3"),
                                                                 ui.MenuItem(label="Three two", mnemonic="Ctrl+3"),
                                                                 ui.MenuSeparator(),
                                                                 ui.MenuItem(label="Three three", mnemonic="Alt+3")])),
                        ui.MenuItem(label="Four", menu=ui.Menu([ui.MenuItem(label="Four one", mnemonic="Ctrl+Alt+4"),
                                                                ui.MenuItem(label="Four two", mnemonic="Ctrl+4"),
                                                                ui.MenuSeparator(),
                                                                ui.MenuItem(label="Four three", mnemonic="Alt+4")])),
                       ], horizontal=True)

        self.menu_selection_label = ui.Label("Pick a menu item!", expand = False, x_align = 1)
        def on_menuitem_selected(menu, item, event):
            self.menu_selection_label.text = item.label
        menu.connect("selected", on_menuitem_selected)

        # adding notebook and attaching pages
        self.notebook.add_page(ui.NotebookTab(image=graphics.Image("assets/day.png"), label="boxes", padding=[1,5]),
                               ui.Fixed([self.box, self.corner], x = 10, y = 10))
        self.notebook.add_page(ui.NotebookTab("Table", tooltip="Oh hey, i'm a table!"), self.table)
        self.notebook.add_page("Scroll Area", self.scroll)
        self.notebook.add_page("Input Elements", inputs)

        self.notebook.add_page("Menu", ui.VBox([menu, self.menu_selection_label,
                                                ui.HBox(ui.Menu([ui.MenuItem(label="", image = graphics.Image("assets/day.png"), submenu_offset_x = 0, submenu_offset_y = 0,
                                                                       menu=ui.Menu([ui.MenuItem(label="", image = graphics.Image("assets/month.png")),
                                                                                     ui.MenuItem(label="", image = graphics.Image("assets/hamster.png")),
                                                                                     ui.MenuSeparator(),
                                                                                     ui.MenuItem(label="", image = graphics.Image("assets/hamster.png")),
                                                                                     ui.MenuItem(label="", image = graphics.Image("assets/month.png"))], horizontal=True)),
                                                                 ui.MenuItem(label="", image = graphics.Image("assets/hamster.png"),submenu_offset_x = 0, submenu_offset_y = 0,
                                                                       menu=ui.Menu([ui.MenuItem(label="", image = graphics.Image("assets/month.png")),
                                                                                     ui.MenuItem(label="", image = graphics.Image("assets/month.png")),
                                                                                     ui.MenuItem(label="", image = graphics.Image("assets/week.png")),
                                                                                     ui.MenuSeparator(),
                                                                                     ui.MenuItem(label="", image = graphics.Image("assets/month.png"))], horizontal=True)),
                                                                 ui.MenuItem(label="", image = graphics.Image("assets/month.png"), submenu_offset_x = 0, submenu_offset_y = 0,
                                                                       menu=ui.Menu([ui.MenuItem(label="", image = graphics.Image("assets/week.png")),
                                                                                     ui.MenuItem(label="", image = graphics.Image("assets/week.png")),
                                                                                     ui.MenuSeparator(),
                                                                                     ui.MenuItem(label="", image = graphics.Image("assets/week.png")),
                                                                                     ui.MenuItem(label="", image = graphics.Image("assets/month.png"))], horizontal=True)),
                                                                ], horizontal=False, spacing=50, hide_on_leave = True, open_on_hover = 0.01), expand=False),
                                                ui.Box()], padding=10))



        self.slice_image = ui.Image('assets/slice9.png', fill=True, slice_left = 35, slice_right = 230, slice_top = 35, slice_bottom = 220)

        data = []
        image = graphics.Image("assets/day.png")
        for i in range(10):
            data.append(["aasdf asdfasdf asdfasdf", "basdfasdf asdfasdf asdfasdf", image, "rrr"])
            data.append(["1", "2", None, "rrr"])
            data.append(["4", "5", None, "rrr"])

        tree = ui.ListItem(data,
                           [ui.LabelRenderer(editable=True),
                            ui.LabelRenderer(editable=True),
                            ui.ImageRenderer(expand=False, width=90)],
                           headers=["Text", "More text", "An icon!"],
                           fixed_headers = False,
                           scroll_border = 0
                           )
        self.notebook.add_page("Tree View", tree)

        #tree.data[0][1] = "I was actually modified afterwards!"


        self.notebook.add_page("Accordion", ui.Accordion([
            ui.AccordionPage("I'm am the first in the row", [ui.Label(accordion_text, overflow = pango.WrapMode.WORD, padding=5)]),
            ui.AccordionPage("I'm am the first in the row", [ui.Label(accordion_text, overflow = pango.WrapMode.WORD, padding=5)]),
            ui.AccordionPage("I'm am the first in the row", [ui.Label(accordion_text, overflow = pango.WrapMode.WORD, padding=5)]),
            ui.AccordionPage("I'm am the first in the row", [ui.Label(accordion_text, overflow = pango.WrapMode.WORD, padding=5)]),
            ui.AccordionPage("I'm am the first in the row", [ui.Label(accordion_text, overflow = pango.WrapMode.WORD, padding=5)]),
            ui.AccordionPage("I'm am the first in the row", [ui.Label(accordion_text, overflow = pango.WrapMode.WORD, padding=5)]),
            ui.AccordionPage("I'm am the first in the row", [ui.Label(accordion_text, overflow = pango.WrapMode.WORD, padding=5)]),
            ui.AccordionPage("I'm am the first in the row", [ui.Label(accordion_text, overflow = pango.WrapMode.WORD, padding=5)]),
            ui.AccordionPage("I'm am the first in the row", [ui.Label(accordion_text, overflow = pango.WrapMode.WORD, padding=5)]),
            ui.AccordionPage("I'm am the first in the row", [ui.Label(accordion_text, overflow = pango.WrapMode.WORD, padding=5)]),
            ui.AccordionPage("I'm am the first in the row", [ui.Label(accordion_text, overflow = pango.WrapMode.WORD, padding=5)]),
            ui.AccordionPage("I'm different!", [
                ui.VBox([
                    ui.Button("I'm a button", fill=False, expand=False),
                    ui.Button("I'm another one", fill=False, expand=False),
                    ui.Group([
                        ui.ToggleButton("We"),
                        ui.ToggleButton("Are"),
                        ui.ToggleButton("Brothers"),
                        ui.ToggleButton("Radio Brothers"),
                    ], expand=False)
                ], expand=False)
            ]),
        ], padding_top = 1, padding_left = 1))

        from pie_menu import Menu
        pie_menu = Menu(0, 0)
        pie_menu.y_align = 0.45

        self.magic_box = ui.VBox([ui.HBox([ui.Button("Hello", expand=False),
                                           ui.Button("Thar", expand=False),
                                           ui.Label("Drag the white area around", x_align=1)], expand=False, padding=5),
                                  pie_menu], x=50, y=50, spacing=50, draggable=True)
        self.magic_box.width = 500
        self.magic_box.height = 400
        def just_fill():
            box = self.magic_box
            box.graphics.fill_area(0, 0, box.width, box.height, "#fefefe")
        self.magic_box.do_render = just_fill
        self.notebook.add_page("Ordinary Sprite", ui.Fixed(self.magic_box))

        for i in range(5):
            self.notebook.add_page("Tab %d" % i)


        self.notebook.current_page = 3


        # a little button to change tab orientation
        self.tab_orient_switch = ui.Button("Change tab attachment", expand=False, tooltip="change")
        self.tab_orient_switch.connect("on-click", self.on_tab_orient_click)

        self.page_disablist = ui.Button("Enable/Disable current tab", expand=False, tooltip="disable")
        self.page_disablist.connect("on-click", self.on_page_disablist_click)

        self.dialog_button = ui.Button("Show a dialog", expand=False, tooltip="show")
        self.dialog_button.connect("on-click", self.on_dialog_button_click)


        top_menu = ui.Menu([ui.MenuItem(label="One", menu=ui.Menu([ui.MenuItem(label="One one oh one oh one etc etc",
                                                                               menu=ui.Menu([ui.MenuItem(label="One one one"),
                                                                                    ui.MenuItem(label="One one two"),
                                                                                    ui.MenuItem(label="One one three")])),
                                                                   ui.MenuItem(label="One two"),
                                                                   ui.MenuItem(label="One three")])),
                            ui.MenuItem(label="Two", menu=ui.Menu([ui.MenuItem(label="Two one"),
                                                        ui.MenuItem(label="Two two"),
                                                        ui.MenuItem(label="Two three")])),
                            ui.MenuItem(label="Three", menu=ui.Menu([ui.MenuItem(label="Three one"),
                                                          ui.MenuItem(label="Three two"),
                                                          ui.MenuItem(label="Three three")])),
                            ui.MenuItem(label="Four", menu=ui.Menu([ui.MenuItem(label="Four one"),
                                                         ui.MenuItem(label="Four two"),
                                                         ui.MenuItem(label="Four three")])),
                            ui.MenuItem(label="Five")
                            ], horizontal=True, disable_toggling=True)


        # not sure how elegant but let's override the flow for now for demo purposes!
        dummy_flow = ui.Flow()
        def flow_resize():
            dummy_flow.alloc_w, dummy_flow.alloc_h = top_menu.alloc_w, top_menu.alloc_h
            dummy_flow.sprites = top_menu.sprites
            dummy_flow.resize_children()
            top_menu.height = top_menu.sprites[-1].y + top_menu.sprites[-1].height

        def flow_height_for_width_size():
            dummy_flow.alloc_w, dummy_flow.alloc_h = top_menu.alloc_w, top_menu.alloc_h
            dummy_flow.sprites = top_menu.sprites
            w, h = dummy_flow.get_height_for_width_size()
            return w, h

        def flow_min_size():
            dummy_flow.sprites = top_menu.sprites
            w, h = dummy_flow.get_min_size()
            return w+ top_menu.horizontal_padding, h  + top_menu.vertical_padding

        # flow if b0rken ATM
        for i in range(20):
            top_menu.add_child(ui.MenuItem(label="flow %d" % i))
        top_menu.resize_children = flow_resize
        #top_menu.get_height_for_width_size = flow_height_for_width_size
        top_menu.get_min_size = flow_min_size





        self.add_child(ui.VBox([top_menu, ui.VBox([self.notebook,
                                                   ui.HBox([self.tab_orient_switch,
                                                            self.page_disablist,
                                                            self.dialog_button], expand = False, fill=False, x_align=1),
                               ], padding=20, spacing=10)], spacing = 10))






        self.connect("on-click", self.on_click)

        self.notebook.after_tabs.add_child(ui.Button("Yohoho"))
        print dt.datetime.now() - now