Ejemplo n.º 1
0
    def __init__(self, widget):
        Clutter.Actor.__init__(self)

        self.props.reactive = True

        self._widget = widget
        self._context = widget.get_style_context()

        self._canvas = Clutter.Canvas(width=100, height=100)
        self._canvas.connect('draw', self._on_canvas_draw)
        self.props.content = self._canvas
        self.set_content_scaling_filters(Clutter.ScalingFilter.TRILINEAR,
                                         Clutter.ScalingFilter.LINEAR)

        action = Clutter.ClickAction()
        action.connect('clicked', self._on_clicked)
        self.add_action(action)

        self._crossing = False
Ejemplo n.º 2
0
    def __init__(self):
        Clutter.Actor.__init__(self)

        self.__text = None
        self.__click = Clutter.ClickAction()
        self.__child = Clutter.Box()
        self.__label = Clutter.Text()

        self.__label.set_line_alignment(Pango.Alignment.CENTER)
        self.__label.set_ellipsize(Pango.EllipsizeMode.END)

        self.__click.connect("clicked", self.clicked)

        self.__child.set_layout_manager(
            Clutter.BinLayout.new(Clutter.BinAlignment.CENTER,
                                  Clutter.BinAlignment.CENTER))
        self.__child.add_actor(self.__label)
        self.__child.set_parent(self)

        self.set_reactive(True)
        self.add_action(self.__click)
        self._path.foreach(self.convert_clutter_path_node, None)

        Cogl.Path.fill()


def clicked_cb(self, *args, **kwargs):
    print("click!")


if __name__ == "__main__":
    stage = Clutter.Stage()

    stage.set_title("star-actor")
    stage.connect("destroy", Clutter.main_quit)

    star_actor = StarActor()
    star_actor.set_size(200, 200)

    color = Clutter.Color.from_string("black")
    star_actor.set_color(color)

    click_action = Clutter.ClickAction()
    click_action.connect("clicked", clicked_cb)
    star_actor.add_action(click_action)

    stage.add_actor(star_actor)
    stage.show()

    Clutter.main()