Skip to content

Instantly share code, notes, and snippets.

@vindolin
Created April 18, 2014 08:19
Show Gist options
  • Save vindolin/11031245 to your computer and use it in GitHub Desktop.
Save vindolin/11031245 to your computer and use it in GitHub Desktop.
import sys
from gi.repository import Clutter
Clutter.init(sys.argv)
stage = Clutter.Stage()
stage.set_size(350, 200)
stage.set_title('Fixed Position')
def color(string):
return Clutter.color_from_string(string)[1]
def stage_key(element, event):
if event.keyval == Clutter.Escape:
clutter_quit()
def clutter_quit(*args):
Clutter.main_quit()
box = Clutter.Actor()
box.set_background_color(color('gray'))
box_layout = Clutter.BoxLayout.new()
box.set_layout_manager(box_layout)
red = Clutter.Actor()
red.set_background_color(color('red'))
red.set_size(100, 100)
green = Clutter.Actor()
green.set_background_color(color('green'))
green.set_size(100, 100)
blue = Clutter.Actor()
blue.set_background_color(color('blue'))
blue.set_size(100, 100)
blue.set_position(50, 50)
box.add_child(red)
box.add_child(green)
box.add_child(blue)
stage.connect('destroy', clutter_quit)
stage.connect('key-press-event', stage_key)
box.add_constraint(Clutter.BindConstraint.new(stage, Clutter.BindCoordinate.SIZE, 0.0))
stage.add_child(box)
stage.show()
Clutter.main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment