예제 #1
0
파일: layout.py 프로젝트: crew/dds-slides
    def setupbg(self):
        # Draw images
        bg = clutter.Rectangle()
        bg.set_color(clutter.color_from_string('#6a9cd2'))
        bg.set_size(1920, 1080)
        bg.set_position(0, 0)
        bg.set_depth(1)
        self.group.add(bg)

        self.sunbeams = clutter.Texture('sunbeams.png')
        self.sunbeams.set_position(-800, -500)
        self.sunbeams.set_size(4000, 4000)
        self.sunbeams.set_depth(2)
        self.group.add(self.sunbeams)

        acmlogo = clutter.Texture('nuacmlogo.png')
        acmlogo.set_position(50, 50)
        acmlogo.set_depth(3)
        self.group.add(acmlogo)

        skyline = clutter.Texture('skyline_blue.png')
        skyline.set_size(952, 436)
        skyline.set_position(1920-952, 1080-436)
        skyline.set_depth(3)
        self.group.add(skyline)

        stripe = clutter.Rectangle()
        stripe.set_color(clutter.color_from_string('#ffffff'))
        stripe.set_size(1920, 200)
        stripe.set_position(0, 250)
        stripe.set_opacity(30)
        stripe.set_depth(3)
        self.group.add(stripe)
예제 #2
0
    def __init__(self, element):
        easyevent.User.__init__(self)
        Group.__init__(self)
        self.name = name = element.get_name()
        self.gstelt = element
        if name.find("src") != -1:
            color = clutter.color_from_string("Blue")
        elif name.find("sink") != -1:
            color = clutter.color_from_string("LightBlue")
        else:
            color = clutter.color_from_string("Green")
        self.back = r = Rectangle(color)
        r.set_size(wwidth,wheight)
        r.show()
        self.add(r)
        self.label = l = Text()
        l.show()
        self.add(l)
        self.set_reactive(True)
        self.connect("button-press-event", self.display_props)

        if name.startswith("queue"):
            self.leaky = leaky = int(element.get_property("leaky"))
            if leaky > 0:
                self.name = "%s, leaky" %name
            self.register_event("queue_state")
        if name.startswith("progressreport"):
            self.register_event("progress_report")
        if name.startswith("videorate"):
            self.register_event("videorate")
        l.set_text(self.name)
        self.show()
예제 #3
0
 def __init__(self,
              width,
              height,
              arc,
              step,
              color=None,
              border_color=None,
              border_width=0):
     """
     Creates a new rounded rectangle
     """
     super(RoundedRectangle, self).__init__()
     self._width = width
     self._height = height
     self._arc = arc
     self._step = step
     if color:
         self._color = color
     else:
         self._color = clutter.color_from_string("#000")
     if border_color:
         self._border_color = border_color
     else:
         self._border_color = clutter.color_from_string("#000")
     self._border_width = border_width
예제 #4
0
파일: ui.py 프로젝트: fbz/banjo
    def changeAvatar(self, avatar):
        self.avatar = avatar
        if self.name:
            self.name.destroy()
        self.name = clutter.Text("Ernest 100px", "", clutter.color_from_string("White"))
        self.add(self.name)

        if self.lives:
            self.lives.destroy()
        self.lives = clutter.Text("Ernest 50px", "Lives:", clutter.color_from_string("White"))
        self.lives.set_position(0, 90)
        self.add(self.lives)

        if self.livecount:
            self.livecount.destroy()
        self.livecount = clutter.Text("Ernest 120px", "", clutter.color_from_string("Green"))
        self.livecount.set_position(0, 100)
        self.add(self.livecount)

        if self.image:
            self.image.destroy()
        if self.rect:
            self.rect.destroy()

        self.image = None
        if self.avatar.imagefile:
            self.image = clutter.Clone(self.avatar.original)
            self.add(self.image)
            h = self.name.get_height()
            self.image.set_size(h,h)

        self.show_all()
        self.update()
예제 #5
0
파일: layout.py 프로젝트: crew/dds-slides
    def decorate(self, pointer_side):
        self.background = clutter.Rectangle()
        self.background.set_color(clutter.color_from_string(BORDER_COLOR))
        self.background.set_size(self.width + 2 * BORDER_WIDTH,
                                 self.height + 2 * BORDER_WIDTH)
        self.background.set_position(self.x - BORDER_WIDTH,
                                     self.y - BORDER_WIDTH)
        self.background.set_depth(0)

        pointer_size = 5 * BORDER_WIDTH
        self.pointer = clutter.Rectangle()
        self.pointer.set_color(clutter.color_from_string(BORDER_COLOR))
        self.pointer.set_size(pointer_size, pointer_size)
        self.pointer.set_depth(0)
        self.pointer.set_anchor_point(pointer_size / 2.0, pointer_size / 2.0)
        self.pointer.set_rotation(clutter.Z_AXIS, 45, 0, 0, 0)
        if pointer_side == TOP:
            self.pointer.set_position(self.x + self.width / 2.0,
                                      self.y - BORDER_WIDTH)
        elif pointer_side == BOTTOM:
            self.pointer.set_position(self.x + self.width / 2.0,
                                      self.y + self.height + BORDER_WIDTH)
        elif pointer_side == LEFT:
            self.pointer.set_position(self.x - BORDER_WIDTH,
                                      self.y + self.height / 2.0)
        else:
            self.pointer.set_position(self.x + self.width + BORDER_WIDTH,
                                      self.y + self.height / 2.0)

        self.slide.group.add(self.background)
        self.slide.group.add(self.pointer)
예제 #6
0
파일: layout.py 프로젝트: crew/dds-slides
    def setuptext(self):
        self.eventtitle = clutter.Text()
        self.eventtitle.set_font_name('Baskerville 60')
        self.eventtitle.set_color(clutter.color_from_string('#ffffff'))
        self.eventtitle.set_size(1600, 1)
        self.eventtitle.set_position(125, 225)
        self.eventtitle.set_ellipsize(3)
        self.eventtitle.set_depth(3)
        self.group.add(self.eventtitle)

        self.dateline = clutter.Text()
        self.dateline.set_font_name('Baskerville 52')
        self.dateline.set_color(clutter.color_from_string('#ffffff'))
        self.dateline.set_position(160, 370)
        self.dateline.set_size(250, 1)
        self.dateline.set_depth(3)
        self.group.add(self.dateline)

        self.descblock = clutter.Text()
        self.descblock.set_font_name('Baskerville 24')
        self.descblock.set_color(clutter.color_from_string('#ffffff'))
        self.descblock.set_position(160, 475)
        self.descblock.set_size(1700, 550)
        self.descblock.set_ellipsize(3)
        self.descblock.set_depth(3)
        self.descblock.set_line_wrap(True)
        self.group.add(self.descblock)
예제 #7
0
파일: layout.py 프로젝트: crew/dds-slides
  def render(self):
    """Renders the rows and colums from the rows object in this slide."""
    rowContainer = clutter.Group()

    # Server
    titleText = "login.ccs.neu.edu"
    title = clutter.Text()
    title.set_text(titleText)
    title.set_font_name("Monospace Bold 56")
    title.set_color(clutter.color_from_string("white"))
    title.set_position(290, 50)

    rowContainer.add(title)

    # Days
    subtitleText = "<i>%s</i> Days Since Last Downtime"
    subtitleText %= timedelta(seconds=float(self.data["uptime"])).days
    subtitle = clutter.Text()
    subtitle.set_text(subtitleText)
    subtitle.set_use_markup(True)
    subtitle.set_font_name("Monospace 36")
    subtitle.set_color(clutter.color_from_string("white"))
    subtitle.set_position(290, 50+title.get_height())

    rowContainer.add(subtitle)

    self.group.add(rowContainer)
예제 #8
0
파일: layout.py 프로젝트: crew/dds-slides
    def setuptext(self):
        # Title
        self.title.set_markup("<b>This client is unconfigured</b>")
        self.title.set_font_name("sans 32")
        self.title.set_color(clutter.color_from_string("white"))
        self.title.set_size(1920, 100)
        self.title.set_position(550, 740)
        self.title.set_depth(2)

        # Message
        jid = config.Option("client-jid")
        jid = jid.split('@')[0]
        unconfigured = ('Please use the DDS Web interface to add JID '
                        '<i>%s</i>'
                        ' to a client group.' % jid)

        self.message.set_markup(unconfigured)
        self.message.set_font_name("sans 24")
        self.message.set_line_wrap(True)
        self.message.set_color(clutter.color_from_string("white"))
        self.message.set_size(1400, 30)
        self.message.set_position(300, 800)
        self.message.set_depth(2)
        # Show it when the animation happens
        self.message.hide()
예제 #9
0
 def evt_progress_report(self, event):
     name = event.content["name"]
     progress_s = event.content["progress_s"]
     if self.name == name:
         text = "%s\nLate by: %s sec" %(name, progress_s)
         if int(progress_s) < 0 and int(progress_s) > -2:
             self.back.set_color(clutter.color_from_string("Orange"))
         elif int(progress_s) <= -2:
             self.back.set_color(clutter.color_from_string("Red"))
         else:
             self.back.set_color(clutter.color_from_string("Green"))
         self.label.set_text(text)
예제 #10
0
    def __init__(self):
        super(ClutterScope, self).__init__()
        self.graticule = Graticule()
        self.add(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(layout)
        self.add(label_box)
        label_box.set_position(0, 0)
        #label_box.add_constraint(clutter.SnapConstraint(self, clutter.SNAP_EDGE_BOTTOM, clutter.SNAP_EDGE_BOTTOM, 0.))
        label_box.add_constraint(
            clutter.BindConstraint(self, clutter.BIND_WIDTH, 0.))

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

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

        tr = Trace()
        tr.set_color(clutter.color_from_string('yellow'))
        tr.set_position(0, 50)
        self.graticule.add(tr)
        self.traces += [tr]
        label_box.add(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

        # Hook up event signal handlers
        self.connect_after('button-press-event', self.button_press)
        self.connect_after('button-release-event', self.button_release)
        self.connect_after('motion-event', self.motion)
        self.connect_after('scroll-event', self.scroll)
예제 #11
0
    def __init__(self):
        super(ClutterScope, self).__init__()
        self.graticule = Graticule()
        self.add(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(layout)
        self.add(label_box)
        label_box.set_position(0, 0)
        # label_box.add_constraint(clutter.SnapConstraint(self, clutter.SNAP_EDGE_BOTTOM, clutter.SNAP_EDGE_BOTTOM, 0.))
        label_box.add_constraint(clutter.BindConstraint(self, clutter.BIND_WIDTH, 0.0))

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

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

        tr = Trace()
        tr.set_color(clutter.color_from_string("yellow"))
        tr.set_position(0, 50)
        self.graticule.add(tr)
        self.traces += [tr]
        label_box.add(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

        # Hook up event signal handlers
        self.connect_after("button-press-event", self.button_press)
        self.connect_after("button-release-event", self.button_release)
        self.connect_after("motion-event", self.motion)
        self.connect_after("scroll-event", self.scroll)
예제 #12
0
파일: hello.py 프로젝트: pmarti/pyclutter
    def __init__ (self, message):
        self.stage = clutter.Stage()
        self.stage.set_color(clutter.color_from_string('DarkSlateGrey'))
        self.stage.set_size(800, 600)
        self.stage.set_title('My First Clutter Application')
        self.stage.connect('key-press-event', clutter.main_quit)
        self.stage.connect('button-press-event',
                           self.on_button_press_event)

        color = clutter.Color(0xff, 0xcc, 0xcc, 0xdd)

        self.label = clutter.Text()
        self.label.set_font_name('Mono 32')
        self.label.set_text(message)
        self.label.set_color(color)
        (label_width, label_height) = self.label.get_size()
        label_x = self.stage.get_width() - label_width - 50
        label_y = self.stage.get_height() - label_height
        self.label.set_position(label_x, label_y)
        self.stage.add(self.label)

        self.cursor = clutter.Rectangle()
        self.cursor.set_color(color)
        self.cursor.set_size(20, label_height)
        cursor_x = self.stage.get_width() - 50
        cursor_y = self.stage.get_height() - label_height
        self.cursor.set_position(cursor_x, cursor_y)
        self.stage.add(self.cursor)

        self.timeline = clutter.Timeline(500)
        self.timeline.set_loop(True)
        alpha = clutter.Alpha(self.timeline, clutter.LINEAR)
        self.behaviour = clutter.BehaviourOpacity(0xdd, 0, alpha)
        self.behaviour.apply(self.cursor)
예제 #13
0
파일: ui.py 프로젝트: fbz/banjo
    def enter_editing(self, s):
        self.set_color(clutter.color_from_string("#666666"))

        self.grid = PixelGrid(self.plugin.spriteGrid, 40)
        self.grid.changedHandler = self.plugin.delayTimeOut
        
        self.add(self.grid)

        self.stage.show_all()

        self.setNotifyText(self.plugin.user['the_name']+"'s avatar")

        self.buttons = []
        def verify():
            if self.plugin.validSprite():
                self.plugin.saveAndStop()
            else:
                self.plugin.error("Your avatar is too small.")
 
        self.buttons.append(dialogs.RoundedButton(self, "done!", 50, 100, verify))

        self.buttons.append(dialogs.RoundedButton(self, "invert", 50, 200, lambda : self.grid.invert()))
        self.buttons.append(dialogs.RoundedButton(self, "clear", 50, 300, lambda : self.grid.clear()))
        self.buttons.append(dialogs.RoundedButton(self, "cancel", 50, 400, lambda : self.plugin.setState("start"), color=Style.button_color_secondary))

        [self.add(b) for b in self.buttons]
        self.reposition()
예제 #14
0
 def __init__ (self):
     clutter.Actor.__init__(self)
     self._color = clutter.color_from_string('White')
     self._is_pressed = False
     self.connect('button-press-event', self.do_button_press_event)
     self.connect('button-release-event', self.do_button_release_event)
     self.connect('leave-event', self.do_leave_event)
예제 #15
0
파일: gfx.py 프로젝트: arjan/iteav2
 def created(self):
     #clutter.set_default_frame_rate(10)
     self.set_color(clutter.color_from_string("Black"))
     self.bs = {}
     def spawn():
         self.addLine(random.choice(self.app.lines))
     task.LoopingCall(spawn).start(5)
예제 #16
0
 def __init__(self):
     super(Trace, self).__init__()
     self.set_size(0, 0)
     self.set_anchor_point_from_gravity(clutter.GRAVITY_CENTER)
     self.color = clutter.color_from_string("cyan")
     self.scale_level_x = 0
     self.scale_level_y = 0
예제 #17
0
파일: rects.py 프로젝트: pmarti/pyclutter
def main (args):
    stage = clutter.Stage()
    stage.set_size(800,600)
    stage.set_color(clutter.color_from_string('DarkSlateGray'))
    stage.connect('actor-added', on_stage_add)
    stage.connect('button-press-event', on_button_press_event)
    
    print "stage color: %s" % (stage.get_color())
   
    color = clutter.Color(0x35, 0x99, 0x2a, 0x66)
    border_color = color.lighten()
    rect = None
    for i in range(1, 10):
        rect = clutter.Rectangle()
        rect.set_position((800 - (80 * i)) / 2, (600 - (60 * i)) / 2)
        rect.set_size(80 * i, 60 * i)

        # colors are either clutter.Color or 4-tuples
        if i % 2 == 0:
            rect.set_color(color)
        else:
            rect.set_color((0x35, 0x99, 0x2a, 0x33))
        
        rect.set_border_width(10)
        rect.set_border_color(border_color)

        stage.add(rect)
        rect.show()

    stage.show()
    clutter.main()

    return 0
예제 #18
0
def main(args):
    stage = clutter.Stage()
    stage.set_size(800, 600)
    stage.set_color(clutter.color_from_string('DarkSlateGray'))
    stage.connect('actor-added', on_stage_add)
    stage.connect('button-press-event', on_button_press_event)

    print "stage color: %s" % (stage.get_color())

    color = clutter.Color(0x35, 0x99, 0x2a, 0x66)
    border_color = color.lighten()
    rect = None
    for i in range(1, 10):
        rect = clutter.Rectangle()
        rect.set_position((800 - (80 * i)) / 2, (600 - (60 * i)) / 2)
        rect.set_size(80 * i, 60 * i)

        # colors are either clutter.Color or 4-tuples
        if i % 2 == 0:
            rect.set_color(color)
        else:
            rect.set_color((0x35, 0x99, 0x2a, 0x33))

        rect.set_border_width(10)
        rect.set_border_color(border_color)

        stage.add(rect)
        rect.show()

    stage.show()
    clutter.main()

    return 0
예제 #19
0
    def __init__(self, message):
        self.stage = clutter.Stage()
        self.stage.set_color(clutter.color_from_string('DarkSlateGrey'))
        self.stage.set_size(800, 600)
        self.stage.set_title('My First Clutter Application')
        self.stage.connect('key-press-event', clutter.main_quit)
        self.stage.connect('button-press-event', self.on_button_press_event)

        color = clutter.Color(0xff, 0xcc, 0xcc, 0xdd)

        self.label = clutter.Text()
        self.label.set_font_name('Mono 32')
        self.label.set_text(message)
        self.label.set_color(color)
        (label_width, label_height) = self.label.get_size()
        label_x = self.stage.get_width() - label_width - 50
        label_y = self.stage.get_height() - label_height
        self.label.set_position(label_x, label_y)
        self.stage.add(self.label)

        self.cursor = clutter.Rectangle()
        self.cursor.set_color(color)
        self.cursor.set_size(20, label_height)
        cursor_x = self.stage.get_width() - 50
        cursor_y = self.stage.get_height() - label_height
        self.cursor.set_position(cursor_x, cursor_y)
        self.stage.add(self.cursor)

        self.timeline = clutter.Timeline(500)
        self.timeline.set_loop(True)
        alpha = clutter.Alpha(self.timeline, clutter.LINEAR)
        self.behaviour = clutter.BehaviourOpacity(0xdd, 0, alpha)
        self.behaviour.apply(self.cursor)
예제 #20
0
파일: polygons.py 프로젝트: jozef/champlain
def make_button(text):
    button = clutter.Group()
    button_bg = clutter.Rectangle()
    button_bg.set_color(clutter.color_from_string('white'))
    button_bg.set_opacity(0xcc)
    button.add(button_bg)

    button_text = clutter.Text('Sans 10', text, \
        clutter.color_from_string('black'))
    button.add(button_text)

    width, height = button_text.get_size()
    button_bg.set_size(width+PADDING*2, height+PADDING*2)
    button_bg.set_position(0, 0)
    button_text.set_position(PADDING, PADDING)
    return button
    def __init__(self):
        # Set up Clutter stage and actors
        self.stage = clutter.Stage()
        self.stage.set_title('PyClutter Screensaver')
        self.stage.set_color('#000000')
        #self.stage.set_size(640, 480)
        self.stage.set_user_resizable(True)
        self.stage.connect('destroy', self.quit)
        self.stage.connect('notify::allocation', self.size_changed)
        self.stage.connect('allocation-changed', self.size_changed)
        self.stage.connect('key-press-event', self.key_pressed)
        
        # Set up foreign window, if specified
        if 'XSCREENSAVER_WINDOW' in os.environ:
            print 'XSCREENSAVER_WINDOW=' + os.environ['XSCREENSAVER_WINDOW']
            xwin = int(os.environ['XSCREENSAVER_WINDOW'], 0)
            clutter.x11.set_stage_foreign(self.stage, xwin)
        
        # Allow SIGINT to pass through
        signal.signal(signal.SIGINT, signal.SIG_DFL)
        
        # Rect
        self.rect = clutter.Rectangle()
        self.rect.set_color(clutter.color_from_string("green"))
        self.rect.set_size(200, 200)
        self.rect.set_anchor_point(100, 100)
        
        self.stage.add(self.rect)
        
        # Text
        '''
        self.text = clutter.Text()
        self.text.set_text("PyClutter")
        self.text.set_color(clutter.color_from_string("green"))
        self.text.set_font_name("Helvetica 40")
        
        w, h = self.text.get_size()
        
        print "Text size:", w, h
        
        self.text.set_anchor_point(w/2, h/2)
        self.text.set_position(640./2, 480./2)
        
        self.stage.add(self.text)
        '''
        
        # Animation
        self.timeline = clutter.Timeline(duration=5000)
        self.timeline.set_loop(True)

        self.alpha = clutter.Alpha(self.timeline, clutter.EASE_OUT_QUAD)
        self.rot = clutter.BehaviourRotate(alpha=self.alpha,
                                           axis=clutter.Y_AXIS,
                                           angle_start=0.0, angle_end=359.0)
        #self.rot.apply(self.text)
        self.rot.apply(self.rect)
        
        self.timeline.start()
        
        self.stage.show_all()
 def draw_route(self, faff):
     route = champlain.Polygon()
     for x in faff:
         route.append_point(x[0], x[1])
     route.set_stroke_width(5.0)
     route.set_stroke_color(clutter.color_from_string('blue'))
     self.view.add_polygon(route)
예제 #23
0
 def __init__(self):
     super(Trace, self).__init__()
     self.set_size(0, 0)
     self.set_anchor_point_from_gravity(clutter.GRAVITY_CENTER)
     self.color = clutter.color_from_string('cyan')
     self.scale_level_x = 0
     self.scale_level_y = 0
예제 #24
0
 def __init__(self):
     clutter.Actor.__init__(self)
     self._color = clutter.color_from_string('White')
     self._is_pressed = False
     self.connect('button-press-event', self.do_button_press_event)
     self.connect('button-release-event', self.do_button_release_event)
     self.connect('leave-event', self.do_leave_event)
예제 #25
0
파일: layout.py 프로젝트: crew/dds-slides
 def add_title(self, text, x, y):
     title = clutter.Text()
     title.set_text(text)
     title.set_font_name('serif 65')
     title.set_color(clutter.color_from_string(TITLE_COLOR))
     title.set_position(x, y)
     title.set_size(1920, 220)
     self.group.add(title)
예제 #26
0
 def draw_route(self, list_of_points, color='blue'):
     route = champlain.Polygon()
     for x in list_of_points:
         route.append_point(x[0], x[1])
     route.set_stroke_width(5.0)
     route.set_stroke_color(clutter.color_from_string(color))
     self.view.add_polygon(route)
     return route
예제 #27
0
파일: layout.py 프로젝트: crew/dds-slides
    def setup_text(self):
        self.desc_block = clutter.Text()
        self.desc_block.set_font_name('Baskerville 30')
        self.desc_block.set_color(clutter.color_from_string('#ffffff'))
        self.desc_block.set_position(160, 375)
        self.desc_block.set_size(1700, 550)
        self.desc_block.set_ellipsize(3)
        self.desc_block.set_depth(3)
        self.desc_block.set_line_wrap(True)
        self.group.add(self.desc_block)

        self.date_line = clutter.Text()
        self.date_line.set_font_name('Baskerville 30')
        self.date_line.set_color(clutter.color_from_string('#ffffff'))
        self.date_line.set_position(160, 800)
        self.date_line.set_size(250, 100)
        self.date_line.set_depth(3)
        self.group.add(self.date_line)
예제 #28
0
파일: ui.py 프로젝트: fbz/banjo
 def setLives(self, lives):
     if lives > 3:
         color = "Green"
     else:
         color = "Red"
     s = "*" * lives
     self.livecount.set_text(s)
     self.livecount.set_color(clutter.color_from_string(color))
     self.lives.set_text("Lives: %d" % lives)
예제 #29
0
    def __init__(self, stage):
        # Now, the stage
        #self.stage = clutter.Stage()
        self.stage = stage
        self.stage.set_color(clutter.color_from_string('black'))
        self.stage.set_size(WIDTH, HEIGHT)

        label = clutter.Text()
        label.set_text("Hello Clutter")
        label.set_color(clutter.color_from_string('white'))
        self.stage.add(label)
        # If no position is given it defaults to the upper most left corner.

        rect = clutter.Rectangle()
        rect.set_size(100, 100)
        rect.set_color(clutter.color_from_string('white'))
        self.stage.add(rect)

        self.stage.show_all()
예제 #30
0
    def __init__(self, stage):
        # Now, the stage
        #self.stage = clutter.Stage()
        self.stage = stage
        self.stage.set_color(clutter.color_from_string('black'))
        self.stage.set_size(WIDTH, HEIGHT)

        label = clutter.Text()
        label.set_text("Hello Clutter")
        label.set_color(clutter.color_from_string('white'))
        self.stage.add(label)
        # If no position is given it defaults to the upper most left corner.

        rect = clutter.Rectangle()
        rect.set_size(100, 100)
        rect.set_color(clutter.color_from_string('white'))
        self.stage.add(rect)

        self.stage.show_all()
예제 #31
0
파일: layout.py 프로젝트: crew/dds-slides
 def __init__(self, dataURL):
   """ Initializes the stage and score for this slide, using the
       given url to get the uptime data. """
   baseslide.BaseSlide.__init__(self)
   self.dataURL = dataURL
   # Background
   self.background = clutter.Rectangle()
   self.background.set_color(clutter.color_from_string("black"))
   self.background.set_size(SCREEN_WIDTH, SCREEN_HEIGHT)
   self.background.set_position(0, 0)
예제 #32
0
 def do_standalone_display(self):
   """This might be useful somewhere. (no resize)"""
   stage = clutter.Stage()
   stage.connect('destroy', clutter.main_quit)
   stage.connect('key-press-event', lambda x,y: clutter.main_quit())
   stage.set_fullscreen(True)
   stage.set_color(clutter.color_from_string('black'))
   stage.add(self.group)
   stage.show_all()
   clutter.main()
예제 #33
0
파일: ui.py 프로젝트: fbz/banjo
 def __init__(self, size, toggler, getter):
     clutter.Group.__init__(self)
     self.toggler = toggler
     self.getter = getter
     self.size = size
     self.rect = clutter.Rectangle()
     self.rect.set_size(size, size)
     self.rect.set_color(clutter.color_from_string("#000000"))
     self.add(self.rect)
     self.active = True
     self.paint()
예제 #34
0
  def __init__(self, pb, mieru, name="", fitOnStart=True):
#    clutter.Texture.__init__(self,imagePath,load_data_async=True)
    page.Page.__init__(self)
    clutter.Texture.__init__(self)
    if pb.props.has_alpha:
      bpp = 4
    else:
      bpp = 3
    self.set_from_rgb_data(
            pb.get_pixels(),
            pb.props.has_alpha,
            pb.props.width,
            pb.props.height,
            pb.props.rowstride,
            bpp, 0)
    del pb
    self.originalSize = self.get_size()

    self.mieru = mieru
    self.initialPosition = (0,0)
    self.motionCallbackId = None

    if fitOnStart:
      self.setFitMode(self.mieru.get('fitMode', 'original')) # implement current fit mode
    self._color = clutter.color_from_string('White')
    self.isPressed = False
    self.pressStart = (0,0)
    self.lastMotion = None
    self.lastMotionTimestamp = 0
    self.lastDTDXDY = (0,0,0)
    self.clickCount = 0
    self.msButtonLastReleaseTimestamp = 0

    self.decelTl = clutter.Timeline(3000)
    self.decelTl.connect('new_frame', self._decelerateCB)
    self.stopDecel = True
    self._resetDecel()


    """first number id for the horizontal and second for the vertical axis,
    0 means movement in this axis is disabled, 1 means movement is enabled"""
    self.movementEnabled = (1,1) # the page is fit to screen so it should not be move


    self.zoomIn=True
    self.msButtonLastPressTimestamp = None
    self.pressLength = 100

    self.connect('button-press-event', self.do_button_press_event)
    self.connect('button-release-event', self.do_button_release_event)
    self.resizeCallbackId = None
    

    self.set_keep_aspect_ratio(True) # we want to preserve the aspect ratio
예제 #35
0
파일: stage.py 프로젝트: arjan/sparked
 def addMonitors(self):
     """
     Add a widget to the stage which shows when one of the monitors
     reports an error.
     """
     self.app.monitors.events.addObserver("updated", self.updateMonitors)
     self._monitorText = clutter.Text()
     self._monitorText.set_font_name("helvetica bold 18px")
     self._monitorText.set_color(clutter.color_from_string("#ff0000"))
     self._monitorText.set_x(3)
     self.add(self._monitorText)
예제 #36
0
 def __init__(self, stage):
     clutter.Text.__init__(self)
     self.set_color(clutter.color_from_string('Black'))
     self.set_text("Test entry (modify me)")
     self.set_position(10,10)
     self.set_reactive(True)
     self.set_editable(True)
     self.connect("button-press-event", self.on_press_cb)
     self.connect("key-press-event", self.key_cb)
     self.connect("activate", self.activated_cb)
     self.stage = stage
예제 #37
0
    def __init__(self):
        # Create a stage and with a clor se to red
        # and title of "My Blinking Rectangle Example'
        self.stage = clutter.Stage()
        self.stage.set_color(clutter.color_from_string("red"))
        self.stage.set_size(400, 400)
        self.stage.set_title('My Blinking Rectangle Example')

        self.rect = clutter.Rectangle()
        self.rect.set_color(clutter.color_from_string("green"))
        self.rect.set_size(200, 200)

        rect_xpos = self.stage.get_width() / 4
        rect_ypos = self.stage.get_height() / 4

        self.rect.set_position(rect_xpos, rect_ypos)

        # Create a time line with 30 frames per second and
        # 10 frames
        self.timeline = clutter.Timeline(duration=3000)

        # Set the timeline to loop forever
        self.timeline.set_loop(True)

        # Create a behaviour for the Green rectangle.
        #  Create an alpha channel and add it to a behaviour
        # and apply the behaviour to our Rectangle.
        # Not sure what clutter.ramp_func does
        # Sets the the up an alpha to the clutter timeline.
        alpha = clutter.Alpha(self.timeline, clutter.EASE_IN_OUT_QUART)
        # Sets the Opacity of alpha object we created above. 
        self.behaviour = clutter.BehaviourOpacity(alpha=alpha , opacity_start=0xdd, opacity_end=0)
        # Apply the behaviour and timeline to our Rectangle that was created above
        self.behaviour.apply(self.rect)

        # start the timeline running
        self.timeline.start()

        self.stage.add(self.rect)
        self.stage.show_all()
        self.stage.connect('destroy', clutter.main_quit)
예제 #38
0
    def __init__(self, trace):
        super(TraceLabel, self).__init__()
        self.trace = trace
        self.set_size(144, 48)
        self.name_label = clutter.Text()
        self.name_label.set_color(clutter.color_from_string('black'))
        self.name_label.set_text('foo bar')
        self.add(self.name_label)
        self.name_label.set_position(6, 6)
        self.name_label.set_size(*self.get_size())

        self.trace.connect_after('notify::color', self.color_changed)
        self.trace.connect_after('notify::name', self.name_changed)
예제 #39
0
def main(args):
    stage = clutter.Stage()
    stage.set_size(800, 600)
    stage.set_color(clutter.Color(0xcc, 0xcc, 0xcc, 0xff))
    stage.connect('key-press-event', clutter.main_quit)
    stage.connect('destroy', clutter.main_quit)

    rect = clutter.Rectangle()
    rect.set_position(0, 0)
    rect.set_size(150, 150)
    rect.set_color(clutter.Color(0x33, 0x22, 0x22, 0xff))
    rect.set_border_color(clutter.color_from_string('white'))
    rect.set_border_width(15)
    rect.show()

    knots = ( \
            (   0,   0 ),   \
            ( 300,   0 ),   \
            ( 300, 300 ),   \
            (   0, 300 ),   \
    )

    path = clutter.Path('M 0 0 L 300 0 L 300 300 L 0 300')

    timeline = clutter.Timeline(3000)
    timeline.set_loop(True)
    alpha = clutter.Alpha(timeline, clutter.EASE_OUT_SINE)

    o_behaviour = clutter.BehaviourOpacity(alpha=alpha,
                                           opacity_start=0x33,
                                           opacity_end=255)
    o_behaviour.apply(rect)

    p_behaviour = clutter.BehaviourPath(alpha, path)
    path.add_move_to(0, 0)
    p_behaviour.apply(rect)

    r_behaviour = BehaviourRotate(alpha)
    r_behaviour.apply(rect)

    stage.add(rect)
    stage.show()

    timeline.start()

    clutter.main()

    return 0
예제 #40
0
    def showPreview(self, thumbnail, type, pressedAction=None):
        if self.previewBox:  # replace previous preview
            self.hidePreview()

        (pBoxY, pBoxX, pBoxShownX, pBoxSide, pBoxInSide,
         border) = self._getPBoxCoords(type)
        # 50% transparent yellow TODO: take this from current OS theme ?
        backgroundColor = clutter.color_from_string("yellow")
        backgroundColor.alpha = 128
        background = clutter.Rectangle(color=backgroundColor)
        background.set_size(pBoxSide, pBoxSide)
        background.set_reactive(True)
        background.connect('button-release-event', self._previewPressedCB,
                           pressedAction)

        # resize and fit in the thumbnail
        thumbnail.set_keep_aspect_ratio(True)
        (tw, th) = thumbnail.get_size()
        wf = float(pBoxInSide) / tw
        hf = float(pBoxInSide) / th
        if tw >= th:
            thumbnail.set_size(tw * wf, th * wf)
        else:
            thumbnail.set_size(tw * hf, th * hf)
        (tw, th) = thumbnail.get_size()
        print(tw, th)
        thumbnail.move_by(border + (pBoxInSide - tw) / 2.0,
                          border + (pBoxInSide - th) / 2.0)

        # create a container for the thumbnail and background
        box = clutter.Group()
        box.add(background)
        box.add(thumbnail)
        # TODO: preview layer above the buttons layer ?
        self.buttons.getLayer().add(box)
        box.show()
        box.set_position(pBoxX, pBoxY)
        self.previewBoxStartingPoint = (pBoxX, pBoxY)
        box.animate(clutter.LINEAR, 300, "x", pBoxShownX)
        self.previewBox = box
예제 #41
0
        self._color = color
        self.queue_redraw()

    def get_border_width(self):
        return self._border_width

    def set_border_width(self, width):
        self._border_width = width
        self.queue_redraw()

    def get_border_color(color):
        return self._border_color

    def set_border_color(self, color):
        self._border_color = color
        self.queue_redraw()


stage = clutter.Stage()
stage.set_size(400, 400)
rect = RoundedRectangle(200, 200, 12, 0.5)
rect.set_color(clutter.color_from_string("#88C"))
rect.set_border_width(5)
rect.set_position(12, 12)
stage.add(rect)
#show everything in the stage
stage.show_all()
stage.connect("destroy", clutter.main_quit)
#main clutter loop
clutter.main()
예제 #42
0
 def do_set_property(self, pspec, value):
     if pspec.name == 'color':
         self._color = clutter.color_from_string(value)
     else:
         raise TypeError('Unknown property ' + pspec.name)
예제 #43
0
 def set_color(self, color):
     self._color = clutter.color_from_string(color)
예제 #44
0
        if self.should_pick_paint() == False:
            return

        (x1, y1, x2, y2) = self.get_allocation_box()
        self.__paint_triangle(x2 - x1, y2 - y1, pick_color)

    def do_clicked(self):
        sys.stdout.write("Clicked!\n")


gobject.type_register(Triangle)

if __name__ == '__main__':
    stage = clutter.Stage()
    stage.set_size(640, 480)
    stage.set_color(clutter.color_from_string('Black'))
    stage.connect('destroy', clutter.main_quit)

    triangle = Triangle()
    triangle.set_color('Red')
    triangle.set_reactive(True)
    triangle.set_size(200, 200)
    triangle.set_anchor_point(100, 100)
    triangle.set_position(320, 240)
    stage.add(triangle)
    triangle.connect('clicked', clutter.main_quit)

    label = clutter.Text()
    label.set_font_name('Sans 36px')
    label.set_text('Click me!')
    label.set_color(clutter.color_from_string('Red'))
예제 #45
0
        self.set_width(width)
        self.set_height(height)
        # do we have an alpha value?
        if pixbuf.props.has_alpha:
            bpp = 4
        else:
            bpp = 3

        self.set_from_rgb_data(pixbuf.get_pixels(), pixbuf.props.has_alpha,
                               pixbuf.props.width, pixbuf.props.height,
                               pixbuf.props.rowstride, bpp, 0)


if __name__ == '__main__':
    if len(sys.argv) > 1:
        pixbuf = gdk.pixbuf_new_from_file(sys.argv[1])
        texture = PixbufTexture(300, 300, pixbuf)
        stage = clutter.Stage()
        stage.add(texture)
        stage.set_size(500, 500)
        stage.set_color(clutter.color_from_string("#000"))
        stage.show_all()
        stage.connect('destroy', clutter.main_quit)
        clutter.main()
    else:
        print("Provide the full path to the image to load")

# execute the script providing the full path to the image to load
# example:
# python clutterpixbuftexture.py /home/mandel/Projects/python-snippets/pixbuftexture/clutter/jono.png
예제 #46
0
 def set_color(self, color):
     self._color = clutter.color_from_string(color)
     self.set_opacity(self._color.alpha)
     if self.props.visible:
         clutter.Actor.queue_redraw(self)
예제 #47
0
                cogl.rectangle(box.x1, box.y1, box.x2, box.y2)
            child.paint()


def on_key_group_activate(key_group, child):
    print "Child %s activated!" % child


if __name__ == '__main__':
    stage = clutter.Stage()
    stage.connect('destroy', clutter.main_quit)

    key_group = KeyGroup()
    stage.add(key_group)

    rect = clutter.Rectangle(clutter.color_from_string('red'))
    rect.set_size(50, 50)
    rect.set_position(0, 0)
    key_group.add(rect)

    rect = clutter.Rectangle(clutter.color_from_string('green'))
    rect.set_size(50, 50)
    rect.set_position(75, 0)
    key_group.add(rect)

    rect = clutter.Rectangle(clutter.color_from_string('blue'))
    rect.set_size(50, 50)
    rect.set_position(150, 0)
    key_group.add(rect)

    key_group.set_position(stage.get_width() / 2 - key_group.get_width() / 2,