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
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)
def pointer_leave_cb(self, event, state): state.set_state("fade-out") return True stage = Clutter.Stage() stage.set_color(Clutter.Color.from_string("#333355")) stage.set_title("btn") stage.connect("destroy", Clutter.main_quit) layout = Clutter.BinLayout.new(Clutter.BinAlignment.FILL, Clutter.BinAlignment.FILL) box = Clutter.Box() box.set_layout_manager(layout) box.set_position(25, 25) box.set_reactive(True) box.set_size(100, 30) # background for the button rect = Clutter.Rectangle() rect.set_color(Clutter.Color.from_string("#aa9900")) box.add_actor(rect) # text for the button text = Clutter.Text.new_full("Sans 10pt", "Hover me", Clutter.Color.from_string("white")) text.set_line_alignment(Pango.Alignment.CENTER)
if __name__ == "__main__": stage = Clutter.Stage() stage.set_color(Clutter.Color.from_string("#000")) stage.set_size(500, 250) stage.set_title("Text Fields") stage.connect("destroy", Clutter.main_quit) table = Clutter.TableLayout() table.set_column_spacing(6) table.set_row_spacing(6) box = Clutter.Box(table) box.add_constraint( Clutter.BindConstraint.new(stage, Clutter.BindCoordinate.WIDTH, -24)) box.add_constraint( Clutter.BindConstraint.new(stage, Clutter.BindCoordinate.HEIGHT, -24)) box.set_position(12, 12) box.pack(create_label("#fff", "<b>Input field: </b>"), row=0, column=0, x_expand=False, y_expand=False) box.pack(create_entry("#ccc", '*', 0), row=0,