コード例 #1
0
ファイル: camera.py プロジェクト: Vitali64GitHub/Lanchie
    def __init__(self, width=128, height=100):
        GtkClutter.Embed.__init__(self)

        self.set_size_request(width, height)

        self.stage = self.get_stage()
        self.stage.set_size(width, height)

        self.layout_manager = Clutter.BoxLayout()
        self.container = Clutter.Actor(layout_manager=self.layout_manager)
        self.stage.add_actor(self.container)

        self.video_texture = Clutter.Texture.new()
        self.video_texture.set_keep_aspect_ratio(True)
        self.video_texture.set_size(width, height)

        self.layout_manager.pack(self.video_texture,
                                 expand=False,
                                 x_fill=False,
                                 y_fill=False,
                                 x_align=Clutter.BoxAlignment.CENTER,
                                 y_align=Clutter.BoxAlignment.CENTER)

        self.camera = Cheese.Camera.new(video_texture=self.video_texture,
                                        camera_device_node=None,
                                        x_resolution=640,
                                        y_resolution=480)

        try:
            self.camera.setup()
            self.camera_found = True
        except GLib.GError as error:
            logging.warning(error)
            self.camera_found = False
            return
コード例 #2
0
ファイル: pisak_text.py プロジェクト: karolaug/pisak
    def __init__(self):
        super().__init__()

        self.set_title("TextApp")
        self.set_size(800, 600)

        self.text = TestText()
        self.cursor = Cursor_Canvas()
        layout = Clutter.BinLayout()
        self.container = Clutter.Actor()
        self.container.set_layout_manager(layout)
        self.container.add_child(self.text)
        self.container.add_child(self.cursor)

        self.pos = Clutter.Text()
        self.pos2 = Clutter.Text()
        self.pos.set_background_color(Clutter.Color.new(0, 0, 255, 255))

        cursor_pos = self.text.get_cursor_position()
        coords = self.text.position_to_coords(cursor_pos)

        self.pos.set_text(''.join(["Kursor na pozycji: ", str(cursor_pos)]))
        self.pos2.set_text(''.join(["Kursor na koordynatach: ", str(coords)]))

        self.layout = Clutter.BoxLayout()
        self.layout.set_orientation(Clutter.Orientation.VERTICAL)
        self.set_layout_manager(self.layout)
        self.add_child(self.pos)
        self.add_child(self.container)
        self.add_child(self.pos2)

        self.text.connect("cursor_changed", lambda _1: self.onKeyPress(_1))
コード例 #3
0
ファイル: key_focus_app.py プロジェクト: karolaug/pisak
 def __init__(self):
     super().__init__()
     self.connect("key-release-event", self.key_release)
     self.connect("notify::mapped", self.start_focus)
     self.button = MyButton()
     self.add_child(self.button)
     self.set_layout_manager(Clutter.BoxLayout())
コード例 #4
0
 def _init_stripes(self):
     layout = Clutter.BoxLayout()
     layout.set_spacing(dims.H_SPACING_PX)
     layout.set_orientation(Clutter.Orientation.VERTICAL)
     self.set_layout_manager(layout)
     for _ in range(STRIPE_COUNT):
         actor = Stripe()
         self.add_child(actor)
コード例 #5
0
 def __init__(self):
     super().__init__()
     self.dynamic_canvas = DynamicCanvas()
     self.dynamic_canvas.set_x_expand(True)
     self.dynamic_canvas.set_y_expand(True)
     self.add_child(self.dynamic_canvas)
     self.layout = Clutter.BoxLayout()
     self.set_layout_manager(self.layout)
     Clutter.threads_add_timeout(0, 33, self._render, None)
コード例 #6
0
ファイル: scroll-actor.py プロジェクト: xrombik/pyclutter
    def __init__(self):
        Clutter.Actor.__init__(self)

        layout = Clutter.BoxLayout(orientation=Clutter.Orientation.VERTICAL,
                                   spacing=12)
        self.props.layout_manager = layout
        self.props.background_color = Clutter.Color.get_static(
            Clutter.StaticColor.BLACK)

        self._current_idx = 0
コード例 #7
0
ファイル: pager.py プロジェクト: karolaug/pisak
 def __init__(self, width, height, rows, columns, tiles, strategy, selector,
              ratio_spacing):
     super().__init__()
     self.set_size(width, height)
     self.strategy = strategy
     self.selector = selector
     layout = Clutter.BoxLayout()
     layout.set_spacing(unit.h(ratio_spacing))
     layout.set_orientation(Clutter.Orientation.VERTICAL)
     self.set_layout_manager(layout)
     self.set_y_align(Clutter.ActorAlign.START)
     self._add_tiles(rows, columns, tiles, ratio_spacing)
コード例 #8
0
 def __init__(self, items, spacing, strategy, sound, row_sounds):
     super().__init__()
     self.items = []  # flat container for the page content
     self.strategy = strategy
     self.sound = sound
     self.row_sounds = row_sounds
     self.layout = Clutter.BoxLayout()
     self.layout.set_spacing(spacing)
     self.layout.set_orientation(Clutter.Orientation.VERTICAL)
     self.set_layout_manager(self.layout)
     self.set_y_align(Clutter.ActorAlign.START)
     self._add_items(items, spacing)
コード例 #9
0
ファイル: clutterscope.py プロジェクト: lpsinger/clutterscope
	def __init__(self):
		super(ClutterScope, self).__init__()
		self.graticule = Graticule()
		self.add_actor(self.graticule)
		#self.set_reactive(True)

		self.traces = []

		layout = Clutter.BoxLayout()
		layout.set_vertical(False)
		layout.set_use_animations(True)
		layout.set_easing_duration(100)
		layout.set_spacing(4)
		label_box = Clutter.Box()
		label_box.set_layout_manager(layout)
		self.add_actor(label_box)
		label_box.set_position(0, 0)
		constraint = Clutter.BindConstraint()
		constraint.set_coordinate(Clutter.BindCoordinate.WIDTH)
		label_box.add_constraint(constraint)

		# Add some traces (just for looks)
		tr = Trace()
		tr.set_position(0, -50)
		self.graticule.add_actor(tr)
		self.traces += [tr]
		label_box.add_actor(TraceLabel(tr))
		tr.set_name('H1:DMT-STRAIN')

		tr = Trace()
		tr.set_color(color_from_string('magenta'))
		self.graticule.add_actor(tr)
		self.traces += [tr]
		label_box.add_actor(TraceLabel(tr))
		tr.set_name('L1:DMT-STRAIN')

		tr = Trace()
		tr.set_color(color_from_string('yellow'))
		tr.set_position(0, 50)
		self.graticule.add_actor(tr)
		self.traces += [tr]
		label_box.add_actor(TraceLabel(tr))
		tr.set_name('A1:DMT-STRAIN')

		# State for event signal handlers
		self.selected_trace = self.traces[0]
		self.__last_scroll_time = 0
		self.__drag_origin = None
コード例 #10
0
def setup_stage(config):
    stage_color = Clutter.Color.new(0, 0, 0, 0)
    text_color = Clutter.Color.new(0, 128, 0, 255)

    Clutter.init(sys.argv)
    stage = Clutter.Stage()
    stage.set_title("Speakup")
    stage.set_use_alpha(True)
    stage.set_background_color(stage_color)
    stage.connect("delete-event", stage_on_delete, config)
    stage.connect("button-press-event", stage_on_button_press, config)

    layout = Clutter.BoxLayout()
    layout.set_orientation(Clutter.Orientation.VERTICAL)
    layout.set_spacing(15)
    stage.set_layout_manager(layout)

    old_entries = []
    for i in range(15):
        old_entry = Clutter.Text.new_with_text("Sans 28px", "")
        old_entry.set_color(Clutter.Color.new(0, 128, 0, (i + 1) * 16))
        old_entries.append(old_entry)
        stage.add_actor(old_entry)
    old_entries.reverse()

    entry = Clutter.Text.new_with_text("Sans 28px", "")
    entry.set_color(text_color)
    entry.set_editable(True)
    entry.set_reactive(True)
    entry.set_single_line_mode(True)
    entry.set_line_alignment(Pango.Alignment.CENTER)
    entry.connect("key-press-event", entry_on_key_press, config)
    stage.add_actor(entry)
    entry.old_entries = old_entries
    entry.old_iterator = -1

    stage.show()
    stage.set_fullscreen(True)
    stage.set_key_focus(entry)

    stage_window = ClutterGdk.get_stage_window(stage)
    stage_window.set_keep_above(True)
    stage_window.set_modal_hint(True)
    stage_window.set_skip_taskbar_hint(True)
    stage_window.set_skip_pager_hint(True)
コード例 #11
0
ファイル: speller.py プロジェクト: karolaug/pisak
    def _init_elements(self):

        self.text_buffer = TextBuffer()
        self.text_field = TextField(self.text_buffer)
        self.text_field.set_height(200)
        self.text_field.set_x_expand(True)
        self.text_field.set_y_expand(False)

        self.tiles_table = TilesTable(self)
        self.tiles_table.set_height(610)
        self.tiles_table.set_width(1350)
        self.tiles_table.set_x_expand(True)
        self.tiles_table.set_y_expand(False)

        layout = Clutter.BoxLayout()
        layout.set_vertical(True)
        layout.set_spacing(30)
        self.set_layout_manager(layout)
        self.add_actor(self.text_field)
        self.add_actor(self.tiles_table)
コード例 #12
0
def create_listbox(posX,
                   posY,
                   sizeX,
                   sizeY,
                   orientation=Clutter.Orientation.HORIZONTAL,
                   iD="listbox",
                   pad=1,
                   handle_mouse=_handle_lb_mouse,
                   handle_itemclick=None):
    boxLayout = Clutter.BoxLayout()
    boxLayout.set_orientation(orientation)
    boxLayout.set_spacing(pad)
    boxList = Clutter.ScrollActor()
    if orientation == Clutter.Orientation.HORIZONTAL:
        boxList.set_scroll_mode(Clutter.ScrollMode.HORIZONTALLY)
    elif orientation == Clutter.Orientation.VERTICAL:
        boxList.set_scroll_mode(Clutter.ScrollMode.VERTICALLY)
    #boxList = Clutter.Actor()
    boxList.set_layout_manager(boxLayout)
    boxList.set_id(iD)
    boxList.set_position(posX, posY)
    boxList.set_size(sizeX, sizeY)
    boxList.set_reactive(True)
    gActors[iD] = {
        'curIndex': 0,  # index to current selection in the listbox
        'startTime': None,  # store time of button press
        'prevPos': None,
        'prevTime':
        None,  # location and time of mouse wrt last event during scroll
        'posX': 0,
        'posY': 0,  # Corresponds to offset wrt Viewport start
        'handle_itemclick':
        handle_itemclick,  # custom handler for handling itemclicks
        'blur': False
    }  # Tell if blur effect is currently active, for example during scroll beyond boundries
    if handle_mouse != None:
        boxList.connect("button-press-event", handle_mouse)
        boxList.connect("button-release-event", handle_mouse)
        boxList.connect("motion-event", handle_mouse)
    return boxList
コード例 #13
0
    def __init__(self):
        Clutter.Actor.__init__(self)

        layout = Clutter.BoxLayout(orientation=Clutter.Orientation.VERTICAL,
                                   spacing=12)
        self.props.layout_manager = layout

        self.props.background_color = Clutter.Color.get_static(
            Clutter.StaticColor.BLACK)

        self._current_idx = -1

        def create_menu_item_view(item):
            view = MenuItemView()
            item.bind_property('label', view, 'text',
                               GObject.BindingFlags.SYNC_CREATE)
            item.bind_property(
                'selected', view, 'selected', GObject.BindingFlags.SYNC_CREATE
                | GObject.BindingFlags.BIDIRECTIONAL)
            return view

        self._model = Gio.ListStore(item_type=MenuItemModel)
        self.bind_model(self._model, create_menu_item_view)
コード例 #14
0
ファイル: mx_box_app.py プロジェクト: karolaug/pisak
    def __init__(self):
        super().__init__()

        self.layout = Clutter.BoxLayout()
        self.set_layout_manager(self.layout)

        # Uncomment one of these lines
        #self.box = self.create_box_actor()
        #self.box = self.create_box_mx()
        self.box = self.create_box_custom()

        self.box.set_x_expand(True)
        self.box.set_y_expand(True)
        self.add_child(self.box)

        self.button_a = Mx.Button()
        self.button_a.set_label("A")
        self.box.add_child(self.button_a)

        self.button_b = Mx.Button()
        self.button_b.set_label("B")
        self.button_b.set_x_expand(True)
        self.box.add_child(self.button_b)
コード例 #15
0
    def __init__(self):
        self.stage = Clutter.Stage()
        self.stage.set_size(400, 400)
        self.layout_manager = Clutter.BoxLayout()
        self.textures_box = Clutter.Actor(layout_manager=self.layout_manager)
        self.stage.add_actor(self.textures_box)

        self.video_texture = Clutter.Texture.new()

        self.video_texture.set_keep_aspect_ratio(True)
        self.video_texture.set_size(400, 400)
        self.layout_manager.pack(self.video_texture,
                                 expand=False,
                                 x_fill=False,
                                 y_fill=False,
                                 x_align=Clutter.BoxAlignment.CENTER,
                                 y_align=Clutter.BoxAlignment.CENTER)

        self.camera = Cheese.Camera.new(self.video_texture, None, 100, 100)
        Cheese.Camera.setup(self.camera, None)
        Cheese.Camera.play(self.camera)

        def added(signal, data):
            uuid = data.get_uuid()
            node = data.get_device_node()
            print "uuid is " + str(uuid)
            print "node is " + str(node)
            self.camera.set_device_by_device_node(node)
            self.camera.switch_camera_device()

        device_monitor = Cheese.CameraDeviceMonitor.new()
        device_monitor.connect("added", added)
        device_monitor.coldplug()

        self.stage.show()
        Clutter.main()
コード例 #16
0
    def _init_elements(self):

        self.revert = 0
        self.game = memory.MemoryGame((4, 6))
        self.game.create_info_field()

        self.tiles_table = TilesTable(self)
        self.tiles = self.tiles_table.tiles
        self.tiles_table.set_height(750)
        self.tiles_table.set_width(1350)
        self.tiles_table.set_x_expand(True)
        self.tiles_table.set_y_expand(False)

        self.row = None
        self.col = None

        self.old_row = None
        self.old_col = None

        layout = Clutter.BoxLayout()
        layout.set_vertical(True)
        layout.set_spacing(20)
        self.set_layout_manager(layout)
        self.add_actor(self.tiles_table)
コード例 #17
0
ファイル: mx_box_app.py プロジェクト: karolaug/pisak
 def create_box_actor(self):
     box = Clutter.Actor()
     box.set_layout_manager(Clutter.BoxLayout())
     return box
コード例 #18
0
    Clutter.init([])
    stage = Clutter.Stage()
    stage.set_size(800, 500)
    stage.set_title('Clutter - 9 Patch Actor')
    stage.set_user_resizable(True)

    # quit when the window gets closed
    stage.connect('destroy', clutter_quit)

    # close window on escape
    stage.connect('key-press-event', stage_key)

    container = Clutter.Actor()
    container.set_background_color(color('pink'))
    container.set_layout_manager(Clutter.BoxLayout())

    nine_patch_actor = NinePatchActor('ninepatch_bubble.9.png', stage)
    nine_patch_actor.set_x_expand(True)
    nine_patch_actor.set_y_expand(True)
    margin = 50
    nine_patch_actor.set_margin_top(margin)
    nine_patch_actor.set_margin_right(margin)
    nine_patch_actor.set_margin_bottom(margin)
    nine_patch_actor.set_margin_left(margin)

    container.add_child(nine_patch_actor)
    stage.add_child(container)

    # bind the size of cairo_actor to the size of the stage
    container.add_constraint(
コード例 #19
0
ファイル: layout.py プロジェクト: Sasza/pisak
 def __init__(self):
     super().__init__()
     self.layout = Clutter.BoxLayout()
     self.set_layout_manager(self.layout)
     self.apply_props()
コード例 #20
0
    def __init__(self):
        Gtk.Window.__init__(self, type=Gtk.WindowType.TOPLEVEL)
        self.set_title('GFreenect View')
        self.connect('delete-event', self._on_delete_event)
        self.set_size_request(800, 600)

        contents = Gtk.Box.new(Gtk.Orientation.VERTICAL, 12)
        self.add(contents)

        top_contents = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 12)
        contents.pack_start(top_contents, fill=True, expand=True, padding=0)
        embed = GtkClutter.Embed.new()
        top_contents.pack_start(embed, fill=True, expand=True, padding=12)

        stage = embed.get_stage()
        stage.set_title('GFreenect View')
        stage.set_user_resizable(True)
        stage.set_color(Clutter.Color.new(0, 0, 0, 255))

        layout_manager = Clutter.BoxLayout()
        textures_box = Clutter.Box.new(layout_manager)
        stage.add_actor(textures_box)
        geometry = stage.get_geometry()
        textures_box.set_geometry(geometry)
        stage.connect('allocation-changed', self._on_allocation_changed,
                      textures_box)

        self._tilt_scale_timeout = 0
        self._tilt_scale = self._create_tilt_scale()
        top_right_contents = Gtk.Box.new(Gtk.Orientation.VERTICAL, 12)
        top_contents.pack_start(top_right_contents,
                                fill=False,
                                expand=False,
                                padding=12)
        label = Gtk.Label()
        label.set_label('Tilt _Motor:')
        label.set_use_underline(True)
        label.set_mnemonic_widget(self._tilt_scale)

        top_right_contents.pack_start(label,
                                      fill=False,
                                      expand=False,
                                      padding=0)
        top_right_contents.pack_start(self._tilt_scale,
                                      fill=True,
                                      expand=True,
                                      padding=0)

        middle_contents = Gtk.Box(Gtk.Orientation.HORIZONTAL, 12)
        contents.pack_start(middle_contents,
                            fill=False,
                            expand=False,
                            padding=0)

        self.rgb_format_radio = Gtk.RadioButton.new_with_label(
            None, 'RGB Format')
        self.rgb_format_radio.connect('toggled',
                                      self._on_video_format_radio_clicked)
        self.ir_format_radio = Gtk.RadioButton.new_from_widget(
            self.rgb_format_radio)
        self.ir_format_radio.set_label('IR Format')
        middle_contents.pack_start(self.rgb_format_radio,
                                   fill=False,
                                   expand=False,
                                   padding=12)
        middle_contents.pack_start(self.ir_format_radio,
                                   fill=False,
                                   expand=False,
                                   padding=0)

        self.led_combobox = self._create_led_combobox()
        label = Gtk.Label()
        label.set_text('_LED:')
        label.set_use_underline(True)
        label.set_mnemonic_widget(self.led_combobox)
        bottom_contents = Gtk.Box(Gtk.Orientation.HORIZONTAL, 12)
        contents.pack_end(bottom_contents, fill=False, expand=False, padding=0)
        bottom_contents.pack_start(label, fill=False, expand=False, padding=12)
        bottom_contents.pack_start(self.led_combobox,
                                   fill=False,
                                   expand=False,
                                   padding=0)

        self._accel_timeout = 0
        self._accel_x_label = Gtk.Label()
        self._accel_y_label = Gtk.Label()
        self._accel_z_label = Gtk.Label()
        label = Gtk.Label()
        label.set_text('Accelerometer:')
        bottom_contents.pack_start(label, fill=False, expand=False, padding=0)
        bottom_contents.pack_start(self._accel_x_label,
                                   fill=False,
                                   expand=False,
                                   padding=6)
        bottom_contents.pack_start(self._accel_y_label,
                                   fill=False,
                                   expand=False,
                                   padding=6)
        bottom_contents.pack_start(self._accel_z_label,
                                   fill=False,
                                   expand=False,
                                   padding=6)

        # Initialize GFreenect asynchronously
        self.kinect = None
        GFreenect.Device.new(0, GFreenect.Subdevice.ALL, None,
                             self._on_kinect_ready, layout_manager)

        self.show_all()
コード例 #21
0
    with actor.easing_state(500, Clutter.AnimationMode.EASE_OUT_BOUNCE):
        actor.set_z_position(z_pos)

    return True


if __name__ == '__main__':
    Clutter.init(None)

    stage = Clutter.Stage(title="Three Flowers in a Vase")
    stage.props.user_resizable = True
    stage.connect('destroy', Clutter.main_quit)

    vase = Clutter.Actor(name='vase')
    vase.props.layout_manager = Clutter.BoxLayout()
    vase.props.background_color = Clutter.Color.get_static(
        Clutter.StaticColor.SKY_BLUE_LIGHT)
    vase.add_constraint(
        Clutter.AlignConstraint(source=stage,
                                align_axis=Clutter.AlignAxis.BOTH,
                                factor=0.5))
    stage.add_child(vase)

    flowers = []

    flower = ToggleActor()
    flower.set_name('flower.1')
    flower.set_size(128, 128)
    flower.set_margin_left(12)
    flower.set_background_color(
コード例 #22
0
 def _init_layout(self):
     self.layout = Clutter.BoxLayout()
     self.set_layout_manager(self.layout)
コード例 #23
0
ファイル: mx_box_app.py プロジェクト: karolaug/pisak
 def __init__(self):
     super().__init__()
     self.set_layout_manager(Clutter.BoxLayout())
     self.set_background_color(Clutter.Color(255, 255, 255, 255))
     self.set_size(1, 1)
コード例 #24
0
 def __init__(self):
     super(ActionTile, self).__init__()
     self.layout = Clutter.BoxLayout()
     self.set_layout_manager(self.layout)
     self.layout.set_vertical(True)
     self._init_elements()
コード例 #25
0
ファイル: events_app.py プロジェクト: karolaug/pisak

# highlight handler
def hover(source, event):
    source.set_background_color(Clutter.Color.new(96, 224, 96, 255))


Clutter.init(sys.argv)

# init stage
stage = Clutter.Stage()

# issue occurs only in fullscreen
stage.set_fullscreen(True)

stage.set_layout_manager(Clutter.BoxLayout())
stage.connect("destroy", lambda _: Clutter.main_quit())

# create vertical stripes
for _ in range(8):
    actor = Clutter.Actor()

    actor.set_x_expand(True)
    actor.set_background_color(Clutter.Color.new(128, 128, 128, 255))
    actor.set_reactive(True)
    actor.connect("enter-event", hover)

    stage.add_child(actor)

# start the app
stage.show_all()