Beispiel #1
0
    def __init__(self):
        self.feed = feedparser.parse(
            'http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/world/rss.xml')
        self.img, self.data = urllib.urlretrieve(self.feed.feed.image.href)
        self.stage = clutter.Stage()
        self.ident = clutter.texture_new_from_file(self.img)
        self.head = clutter.Text()
        self.body = clutter.Text()
        self.entry = 0
        #initialize elements of the display group
        self.head.set_position(130, 5)
        self.head.set_color(blue)
        self.body = clutter.Text()
        self.body.set_max_length(70)
        self.body.set_position(130, 22)
        self.body.set_size(250, 100)
        self.body.set_line_wrap(True)

        #get first feeed entry for text elements
        self.setfeed()
        #create group to hold elements
        self.group = clutter.Group()
        self.group.add(self.ident, self.head, self.body)
        self.group.show_all()
        #set up stage
        self.stage.set_size(400, 60)
        self.stage.set_color(white)
        self.stage.show_all()
        self.stage.add(self.group)
        self.stage.connect('key-press-event', self.parseKeyPress)
        clutter.main()
Beispiel #2
0
    def __init__(self):
        super(FinalJeopardyBox, self).__init__(clutter.BoxLayout())

        self.set_color(config.background_color)
        layout = self.get_layout_manager()
        layout.set_vertical(True)

        text = clutter.Text(config.admin_font_header, "FINAL JEOPARDY")
        self.add(text)

        self.players = game.get_players()
        for player in self.players:
            text = clutter.Text(
                config.admin_font,
                'Player %s ($%d) wager:' % (player.name, player.score))
            text.set_color('white')
            self.add(text)

            wager = clutter.Text(config.admin_font, "0")
            wager.set_color('white')
            wager.player = player
            wager.value = 0
            wager.set_activatable(True)
            wager.set_reactive(True)
            wager.set_editable(True)
            wager.connect('activate', lambda actor: self.set_wager(actor))
            self.add(wager)
            layout.set_fill(wager, True, False)

            correct = clutter.Text(config.admin_font, "CORRECT")
            correct.set_color('green')
            correct.player = player
            correct.wager = wager
            correct.set_reactive(True)
            correct.connect('button-release-event',
                            lambda actor, event: self.correct(actor))
            self.add(correct)
            layout.set_fill(correct, True, False)

            wrong = clutter.Text(config.admin_font, "WRONG")
            wrong.set_color('red')
            wrong.player = player
            wrong.wager = wager
            wrong.set_reactive(True)
            wrong.connect('button-release-event',
                          lambda actor, event: self.wrong(actor))
            self.add(wrong)
            layout.set_fill(wrong, True, False)
Beispiel #3
0
    def __init__(self):
        super(FrontScreen, self).__init__(
            clutter.BinLayout(clutter.BIN_ALIGNMENT_CENTER,
                              clutter.BIN_ALIGNMENT_CENTER)
            )
        layout = self.get_layout_manager()

        self.credits = Credits()
        layout.add(self.credits,
                   clutter.BIN_ALIGNMENT_START,
                   clutter.BIN_ALIGNMENT_END)

        self.right_arrow = RightArrow()
        layout.add(self.right_arrow,
                   clutter.BIN_ALIGNMENT_END,
                   clutter.BIN_ALIGNMENT_CENTER)

        self.boxed_contents = clutter.Box(clutter.BoxLayout())
        box_layout = self.boxed_contents.get_layout_manager()
        box_layout.set_use_animations(True)
        box_layout.set_vertical(True)
        box_layout.set_spacing(100)

        self.header = LogoLarge()
        box_layout.pack(self.header, True, False, False,
                        clutter.BOX_ALIGNMENT_CENTER,
                        clutter.BOX_ALIGNMENT_CENTER)

        self.labels = (
            clutter.Text(settings.FRONT_SCREEN_FONT, 'songs'),
            clutter.Text(settings.FRONT_SCREEN_FONT, 'artists'),
            )

        self.selected = self.labels[0]

        for label in self.labels:
            label.set_color(FONT_COLOR)
            label.set_opacity(FONT_OPACITY)
            label.set_property('scale-gravity', clutter.GRAVITY_CENTER)
            box_layout.pack(label, True, False, False,
                            clutter.BOX_ALIGNMENT_CENTER,
                            clutter.BOX_ALIGNMENT_CENTER)

        layout.add(self.boxed_contents,
                   clutter.BIN_ALIGNMENT_CENTER,
                   clutter.BIN_ALIGNMENT_START)

        self.highlight(self.selected)
Beispiel #4
0
def main():
    stage_color = clutter.Color(0, 0, 0, 255)
    actor_color = clutter.Color(255, 255, 255, 153)

    # Get the stage and set its size and color
    stage = clutter.Stage()
    stage.set_size(200, 200)
    stage.set_color(stage_color)

    # Add a rectangle to the stage
    rect = clutter.Rectangle(actor_color)
    rect.set_size(100, 100)
    rect.set_position(20, 20)
    stage.add(rect)
    rect.show()

    # Add a label to the stage
    label = clutter.Text("Sans 12", "Some Text", actor_color)
    label.set_size(500, 500)
    label.set_position(20, 150)
    stage.add(label)
    label.show()

    # Show the stage
    stage.connect("destroy", clutter.main_quit)
    stage.show_all()

    # Start the main loop, so we can respond to events:
    clutter.main()

    return 0
Beispiel #5
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)
Beispiel #6
0
    def __init__(self, song):
        super(SongDetailScreen, self).__init__(
            clutter.BinLayout(clutter.BIN_ALIGNMENT_CENTER,
                              clutter.BIN_ALIGNMENT_CENTER))
        # Immediately store song information
        self.song = song
        self.set_name('song detail %s' % self.song.title)
        layout = self.get_layout_manager()

        self.header = Header('Song Details')
        self.header.set_width(self.get_width())
        layout.add(self.header, clutter.BIN_ALIGNMENT_CENTER,
                   clutter.BIN_ALIGNMENT_START)

        self.left_arrow = LeftArrow()
        self.play = PlaySymbol()

        self.box = clutter.Box(clutter.BoxLayout())
        box_layout = self.box.get_layout_manager()
        box_layout.set_vertical(True)
        box_layout.set_spacing(20)
        text = clutter.Text(settings.SONG_TITLE_FONT, self.song.title)
        text.set_line_alignment(ALIGN_CENTER)
        text.set_line_wrap(True)
        text.set_color(clutter.Color(230, 230, 230, 0xff))
        self.box.add(text)
        text = clutter.Text(settings.SONG_ARTIST_FONT,
                            "by %s" % self.song.artist.name)
        text.set_line_alignment(ALIGN_CENTER)
        text.set_line_wrap(True)
        text.set_color(clutter.Color(210, 210, 210, 0xff))
        self.box.add(text)
        self.box.set_width(self.get_width() - (self.left_arrow.get_width() +
                                               self.play.get_width()))

        layout.add(
            self.box,
            clutter.BIN_ALIGNMENT_CENTER,
            clutter.BIN_ALIGNMENT_CENTER,
        )

        layout.add(self.left_arrow, clutter.BIN_ALIGNMENT_START,
                   clutter.BIN_ALIGNMENT_CENTER)

        layout.add(self.play, clutter.BIN_ALIGNMENT_END,
                   clutter.BIN_ALIGNMENT_CENTER)
Beispiel #7
0
    def __init__(self):
        super(Credits, self).__init__(clutter.BoxLayout())
        layout = self.get_layout_manager()
        layout.set_vertical(False)
        layout.set_spacing(20)

        self.credits_text = clutter.Text(settings.CREDITS_FONT, 'Credits:')
        self.credits_text.set_color(FONT_COLOR)

        self.previous_credits = credits_load()
        self.credits = clutter.Text(settings.CREDITS_FONT, credits_load())
        self.credits.set_property('scale-gravity', clutter.GRAVITY_CENTER)
        self.credits.set_color(clutter.Color(255, 255, 255, 230))

        layout.pack(self.credits_text, True, False, False,
                    clutter.BOX_ALIGNMENT_CENTER, clutter.BOX_ALIGNMENT_CENTER)
        layout.pack(self.credits, True, False, False,
                    clutter.BOX_ALIGNMENT_CENTER, clutter.BOX_ALIGNMENT_CENTER)
Beispiel #8
0
    def __init__(self, font, text):
        """
        """
        super(Text, self).__init__(clutter.FixedLayout())

        self.text = clutter.Text(font, text)
        self.text.set_line_alignment(ALIGN_CENTER)
        self.text.set_line_wrap(True)
        self.text.set_color(clutter.Color(255, 255, 255))

        self.shadow = clutter.Text(font, text)
        self.shadow.set_line_alignment(ALIGN_CENTER)
        self.shadow.set_line_wrap(True)
        self.shadow.set_color(clutter.Color(0, 0, 0))
        offset = int(self.font_size() / 24) + 2
        self.shadow.set_position(offset, offset)

        self.add(self.shadow)
        self.add(self.text)
Beispiel #9
0
    def __init__(self, width=DEFAULT_SYMBOL_SIZE):
        super(PlaySymbol, self).__init__(width=width, color='blue')

        self.box = clutter.Box(
            clutter.BinLayout(clutter.BIN_ALIGNMENT_CENTER,
                              clutter.BIN_ALIGNMENT_CENTER))
        self.play = clutter.Text('Router Ultra Bold 25', 'PLAY')
        self.play.set_color(clutter.Color(255, 255, 255, 102))
        self.box.add(self.play)
        self.add(self.box)
Beispiel #10
0
def main():
    stage_color = clutter.Color(176, 176, 176, 255) # light gray

    # Get the stage and set its size and color
    stage = clutter.Stage()
    stage.set_size(800, 600)
    stage.set_color(stage_color)

    # Create and add a label actor, hidden at first
    global label_filename
    label_filename = clutter.Text()
    label_color = clutter.Color(96, 96, 144, 255) # blueish
    label_filename.set_color(label_color)
    label_filename.set_font_name("Sans 24")
    label_filename.set_position(10, 10)
    label_filename.set_opacity(0)
    stage.add(label_filename)
    label_filename.show()

    # Add a plane under the ellipse of images
    rect_color = clutter.Color(255, 255, 255, 255) # white
    rect = clutter.Rectangle(rect_color)
    rect.set_height(ELLIPSE_HEIGHT + 20)
    rect.set_width(stage.get_width() + 100)
    # Position it so that its center is under the images
    rect.set_position(-(rect.get_width() - stage.get_width()) / 2,
                      ELLIPSE_Y + IMAGE_HEIGHT - (rect.get_height() / 2))
    # Rotate it around its center
    rect.set_rotation(clutter.X_AXIS, -90, 0, rect.get_height() / 2, 0)
    stage.add(rect)
    rect.show()

    # show the stage
    stage.connect("destroy", clutter.main_quit)
    stage.show_all()

    global timeline_rotation
    timeline_rotation = clutter.Timeline(2000) # milliseconds
    timeline_rotation.connect('completed', on_timeline_rotation_completed)

    # Add an actor for each image
    load_images("images")
    add_image_actors(stage)

    # timeline_rotation.set_loop(True)

    # Move them a bit to start with
    global list_items
    if list_items:
        rotate_all_until_item_is_at_front(list_items[0])

    # Start the main loop, so we can respond to events
    clutter.main()

    return 0
Beispiel #11
0
    def __init__(self):
        super(LogoSmall, self).__init__(clutter.BoxLayout())

        layout = self.get_layout_manager()
        layout.set_vertical(False)
        layout.set_spacing(20)
        layout.set_use_animations(True)

        self.as220 = clutter.Text(settings.LOGO_AS220_SMALL_FONT,
                                  'AS22O')
        self.as220.set_color(FONT_COLOR)
        self.jukebox = clutter.Text(settings.LOGO_JUKEBOX_SMALL_FONT,
                                    'Jukebox\nMusic')
        self.jukebox.set_color(FONT_COLOR)
        self.jukebox.set_line_alignment(ALIGN_CENTER)
        layout.pack(self.as220, True, False, False,
                    clutter.BOX_ALIGNMENT_CENTER,
                    clutter.BOX_ALIGNMENT_CENTER)
        layout.pack(self.jukebox, True, False, False,
                    clutter.BOX_ALIGNMENT_CENTER,
                    clutter.BOX_ALIGNMENT_CENTER)
Beispiel #12
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)
Beispiel #13
0
 def __init__(self):
     super(TransientMessage, self).__init__(
         clutter.BinLayout(clutter.BIN_ALIGNMENT_CENTER,
                           clutter.BIN_ALIGNMENT_CENTER))
     self.set_size(settings.SCREEN_WIDTH, settings.SCREEN_HEIGHT)
     self.set_color(clutter.Color(0, 0, 0, 0))
     self.text = clutter.Text(settings.TRANSIENT_MESSAGE_FONT, '')
     self.text.set_property('scale-gravity', clutter.GRAVITY_CENTER)
     self.text.set_line_alignment(ALIGN_CENTER)
     self.text.set_line_wrap(True)
     self.text.set_color(clutter.Color(230, 230, 230))
     self.add(self.text)
     self.animation = None
Beispiel #14
0
    def __init__(self):
        super(PlayerScoreBox, self).__init__(clutter.BoxLayout())

        self.set_color(config.background_color)
        layout = self.get_layout_manager()
        layout.set_vertical(True)

        self.players = game.get_players()

        self.scores = []
        for player in self.players:
            text = clutter.Text(config.admin_font,
                                'Player %s score:' % player.name)
            text.set_color('white')
            self.add(text)

            score = clutter.Text(config.admin_font, "%d" % player.score)
            score.set_color('white')
            score.player = player
            self.scores.append(score)
            score.set_activatable(True)
            score.set_reactive(True)
            score.set_editable(True)
            score.connect('activate', lambda actor: self.set_score(actor))
            self.add(score)
            layout.set_fill(score, True, False)

        text = clutter.Text(config.admin_font_header, "DRINKS")
        self.add(text)
        for player in self.players:
            drink = clutter.Text(config.admin_font,
                                 'Player %s Drink' % player.name)
            drink.player = player
            drink.set_color('white')
            drink.set_reactive(True)
            drink.connect('button-release-event',
                          lambda actor, event: self.drink(actor.player))
            self.add(drink)
Beispiel #15
0
    def __init__(self, artist):
        super(ArtistDetailScreen, self).__init__(
            clutter.BinLayout(clutter.BIN_ALIGNMENT_CENTER,
                              clutter.BIN_ALIGNMENT_CENTER))
        self.set_name('artist detail %s' % artist.name)
        layout = self.get_layout_manager()

        photo = artist.random_photo()
        self.background = BackgroundImages(artist)
        #self.background = clutter.Texture(settings.MEDIA_ROOT + "/" + photo.photo.name)
        self.background.set_opacity(30)
        layout.add(self.background, clutter.BIN_ALIGNMENT_END,
                   clutter.BIN_ALIGNMENT_END)
        self.background.lower_bottom()

        self.header = Header('Artist Details')
        self.header.set_width(self.get_width())
        layout.add(self.header, clutter.BIN_ALIGNMENT_CENTER,
                   clutter.BIN_ALIGNMENT_START)

        self.left_arrow = LeftArrow()

        songs = artist.song_set.filter(approved=True).order_by('title')
        self.songs = None
        if len(songs) > 0:
            self.right_arrow = RightArrow()
            self.songs = ScrollingText(
                map(BlinkingText, songs),
                items_on_screen=settings.SONG_LIST_ITEMS)
            self.songs.set_width(self.get_width() -
                                 (self.left_arrow.get_width() +
                                  self.right_arrow.get_width()))
            self.songs.set_height(self.get_height() - self.header.get_height())
            layout.add(self.songs, clutter.BIN_ALIGNMENT_CENTER,
                       clutter.BIN_ALIGNMENT_END)
            layout.add(self.right_arrow, clutter.BIN_ALIGNMENT_END,
                       clutter.BIN_ALIGNMENT_CENTER)

        else:
            text = clutter.Text('Router Bold 70', 'No songs available.')
            text.set_color(clutter.Color(200, 200, 200, 0xff))
            layout.add(text, clutter.BIN_ALIGNMENT_CENTER,
                       clutter.BIN_ALIGNMENT_CENTER)

        layout.add(self.left_arrow, clutter.BIN_ALIGNMENT_START,
                   clutter.BIN_ALIGNMENT_CENTER)
Beispiel #16
0
def main():
    stage_color = clutter.Color(0, 0, 0, 255)
    actor_color = clutter.Color(255, 255, 255, 153)

    # Get the stage and set its size and color
    stage = clutter.Stage()
    stage.set_size(200, 200)
    stage.set_color(stage_color)

    # Add a rectangle to the stage
    rect = clutter.Rectangle(actor_color)
    rect.set_size(100, 100)
    rect.set_position(20, 20)
    stage.add(rect)
    rect.show()

    # Rotate it 20 degrees away from us around the x axis
    # (around its top edge)
    rect.set_rotation(clutter.X_AXIS, -20, 0, 0, 0)

    # Add a label to the stage
    label = clutter.Text("Sans 12", "Some Text", actor_color)
    label.set_size(500, 500)
    label.set_position(20, 150)
    stage.add(label)
    label.show()

    # Scale it 300% along the x axis
    label.set_scale(3., 1.)

    # Move it up and to the right
    label.move_by(10, -10)

    # Move it along the z axis, further from the viewer
    label.set_depth(-20)

    # Show the stage
    stage.connect("destroy", clutter.main_quit)
    stage.show_all()

    # Start the main loop, so we can respond to events
    clutter.main()

    return 0
Beispiel #17
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()
Beispiel #18
0
    def __init__(self, title):
        super(Header, self).__init__(
            clutter.BinLayout(
                clutter.BIN_ALIGNMENT_CENTER,
                clutter.BIN_ALIGNMENT_START,
            ))
        layout = self.get_layout_manager()
        #layout.set_vertical(False)

        # Setup default header elements.
        self.logo = LogoSmall()
        self.title = clutter.Text(settings.HEADER_TITLE_FONT, title)
        self.title.set_color(FONT_COLOR)
        self.credits = Credits()
        layout.add(self.logo, clutter.BIN_ALIGNMENT_START,
                   clutter.BIN_ALIGNMENT_START)
        layout.add(self.title, clutter.BIN_ALIGNMENT_CENTER,
                   clutter.BIN_ALIGNMENT_START)
        layout.add(self.credits, clutter.BIN_ALIGNMENT_END,
                   clutter.BIN_ALIGNMENT_START)
Beispiel #19
0
    def __init__(self):
        self.current_mode = 0
        self.stage = clutter.Stage()
        self.stage.set_color(clutter.Color(0x88, 0x88, 0xdd, 0xff))

        self.rect = clutter.Rectangle()
        self.rect.set_color(clutter.Color(0xee, 0x33, 0, 0xff))
        self.rect.set_anchor_point_from_gravity(clutter.GRAVITY_CENTER)
        self.rect.set_size(50, 50)
        self.rect.set_position(self.stage.get_width() / 2,
                               self.stage.get_height() / 2)
        self.stage.add(self.rect)

        self.easing_mode_label = clutter.Text()
        self.stage.add(self.easing_mode_label)

        self.stage.connect('destroy', clutter.main_quit)
        self.stage.connect('button-press-event', self.on_button_press)
        self.stage.show()
        self.update_label()
Beispiel #20
0
    def display(self):
        if is_now_playing():
            self.set_color(clutter.Color(0, 0, 0, 250))
            self.set_opacity(250)

            # Remove existing text.
            for actor in self.now_playing_box.get_children():
                self.now_playing_box.remove(actor)

            song = now_playing()
            text = clutter.Text(settings.FOOTER_FONT, 'Now playing:')
            text.set_color(clutter.Color(200, 200, 200))
            self.now_playing_box.add(text)
            text = clutter.Text(settings.FOOTER_SONG_FONT, song)
            text.set_color(clutter.Color(240, 240, 40))
            self.now_playing_box.add(text)
            try:
                text = clutter.Text(settings.FOOTER_ARTIST_FONT,
                                    "by %s" % song.artist)
                text.set_color(clutter.Color(240, 240, 40))
                self.now_playing_box.add(text)
            except Exception:
                pass

            if has_next_song():
                song = next_song()

                # Remove existing text.
                for actor in self.next_song_box.get_children():
                    self.next_song_box.remove(actor)

                text = clutter.Text(settings.FOOTER_FONT, 'Next song:')
                text.set_color(clutter.Color(200, 200, 200))
                self.next_song_box.add(text)
                text = clutter.Text(settings.FOOTER_SONG_FONT, song)
                text.set_color(clutter.Color(240, 240, 40))
                self.next_song_box.add(text)
                try:
                    text = clutter.Text(settings.FOOTER_ARTIST_FONT,
                                        "by %s" % song.artist)
                    text.set_color(clutter.Color(240, 240, 40))
                    self.next_song_box.add(text)
                except Exception:
                    pass

            self.animation = self.animate(clutter.EASE_IN_CUBIC,
                                          settings.FOOTER_FADE_RATE, 'opacity',
                                          0)
Beispiel #21
0
def main():
    stage_color = clutter.Color(0, 0, 0, 255)
    actor_color = clutter.Color(255, 255, 255, 153)

    # Get the stage and set its size and color
    stage = clutter.Stage()
    stage.set_size(200, 200)
    stage.set_color(stage_color)

    # Add a group to the stage
    group = clutter.Group()
    group.set_position(40, 40)
    stage.add(group)
    group.show()

    # Add a rectangle to the group
    rect = clutter.Rectangle(actor_color)
    rect.set_size(50, 50)
    rect.set_position(0, 0)
    group.add(rect)
    rect.show()

    # Add a label to the group
    label = clutter.Text("Sans 9", "Some Text", actor_color)
    label.set_position(0, 60)
    group.add(label)
    label.show()

    # Scale the group 120% along the x axis
    group.set_scale(3.0, 1.0)

    # Rotate it around the z axis
    group.set_rotation(clutter.Z_AXIS, 10, 0, 0, 0)

    # Show the stage
    stage.connect("destroy", clutter.main_quit)
    stage.show_all()

    # Start the main loop, so we can respond to events
    clutter.main()
Beispiel #22
0
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'))
    label.set_position((640 - label.get_width()) / 2,
                       triangle.get_y() + triangle.get_height())
    stage.add(label)

    stage.show()

    clutter.main()

    sys.exit(0)
Beispiel #23
0
    stage.connect('destroy', clutter.main_quit)

    box = SampleBox()
    for i in range(10):
        rect = clutter.Rectangle()
        color = clutter.Color(random.randint(0, 255), random.randint(0, 255),
                              random.randint(0, 255), 255)
        rect.set_color(color)
        rect.set_size(50, 50)
        rect.set_reactive(True)
        rect.connect('button-press-event', on_child_button_pressed)
        box.add(rect)
        box.child_set_property(rect, 'allocate-hidden', False)
        if i % 2:
            rect.hide()

    stage.add(box)
    box.set_reactive(True)

    info = clutter.Text()
    info.set_text("Press 'h' to allocate hidden actors.\n" +
                  "Click the container actor to change it's orientation.")
    stage.add(info)
    info.set_y(stage.get_height() - info.get_height() - 10)

    box.connect('button-press-event', on_button_press)
    stage.connect('key-press-event', on_key_press, box)

    stage.show()
    clutter.main()
Beispiel #24
0
    def __init__(self):
        super(ClueBox,
              self).__init__(clutter.FlowLayout(clutter.FLOW_VERTICAL))
        layout = self.get_layout_manager()
        layout.set_column_spacing(10)
        layout.set_row_spacing(10)
        self.set_color(config.background_color)

        # Add clue answer and question.
        clue_box = clutter.Box(clutter.BoxLayout())
        self.add(clue_box)
        clue_layout = clue_box.get_layout_manager()
        clue_layout.set_vertical(True)

        clue = game.get_selected_clue()
        text = clutter.Text(config.admin_font_header, "CLUE")
        text.set_color('white')
        clue_layout.pack(text, False, False, False,
                         clutter.BOX_ALIGNMENT_START,
                         clutter.BOX_ALIGNMENT_CENTER)
        text = clutter.Text(config.admin_font, "Answer\n%s" % clue.answer)
        text.set_color('green')
        clue_layout.pack(text, False, False, False,
                         clutter.BOX_ALIGNMENT_START,
                         clutter.BOX_ALIGNMENT_CENTER)
        text = clutter.Text(config.admin_font, "Question\n%s" % clue.question)
        text.set_color('red')
        clue_layout.pack(text, False, False, False,
                         clutter.BOX_ALIGNMENT_START,
                         clutter.BOX_ALIGNMENT_CENTER)

        # Add player buzz in information.
        buzz_box = clutter.Box(clutter.BoxLayout())
        self.add(buzz_box)
        buzz_layout = buzz_box.get_layout_manager()
        buzz_layout.set_vertical(True)
        text = clutter.Text(config.admin_font_header, 'PLAYER BUZZES')
        buzz_layout.pack(text, False, False, False,
                         clutter.BOX_ALIGNMENT_START,
                         clutter.BOX_ALIGNMENT_CENTER)
        self.players = []
        for player in game.get_players():
            text = clutter.Text(config.admin_font, "Player %s" % player.name)
            text.set_color('white')
            text.player = player
            self.players.append(text)
            buzz_layout.pack(text, False, False, False,
                             clutter.BOX_ALIGNMENT_START,
                             clutter.BOX_ALIGNMENT_CENTER)

        if game.selected_clue.is_daily_double():
            dd_box = clutter.Box(clutter.BoxLayout())
            self.add(dd_box)
            dd_layout = dd_box.get_layout_manager()
            dd_layout.set_vertical(True)
            for player in game.get_players():
                text = clutter.Text(config.admin_font,
                                    "Player %s" % player.name)
                text.set_color('white')
                text.player = player
                text.set_reactive(True)
                text.connect('button-release-event',
                             lambda actor, event: self.choose_team(actor))
                dd_box.add(text)
            text = clutter.Text(config.admin_font, 'Daily Double Wager:')
            text.set_color('white')
            dd_box.add(text)
            self.wager = clutter.Text(config.admin_font, '0')
            self.wager.set_color('white')
            self.wager.set_reactive(True)
            self.wager.set_editable(True)
            self.wager.connect(
                'text-changed',
                lambda actor: game.set_daily_double_wager(self.get_wager()))
            dd_box.add(self.wager)
            dd_layout.set_fill(self.wager, True, False)
Beispiel #25
0
		Sierpinski(size/2,x,y+(size/2),depth)

        t3=Triangle()
        t3.set_size(size/2,size/2)       
        t3.set_position(x+(size/2),y+(size/2))    
        t3.set_color(color,color,color,color)
        stage.add(t3)
	if depth != 0:
		Sierpinski(size/2,x+(size/2),y+(size/2),depth)
	return 

if __name__ == "__main__":
	depth = int(sys.argv[1])
	gobject.type_register(Triangle)
	stage=clutter.Stage()
	stage.set_size(480,480)
	stage.set_color(clutter.Color(0,0,0,255))
	stage.connect('destroy',clutter.main_quit)
	(x,y) = (10,0)
	size = 440
	text = clutter.Text()
	text.set_text("Sierpinski Triangle")
	text.set_color((255,255,255,255))
	text.set_position(10,450)
	stage.add(text)
	Sierpinski(size,x,y,depth) 
	stage.show()
	stage.set_title("www.hackerfantastic.com")
	clutter.main()

Beispiel #26
0
def main():
    stage_color = clutter.Color(0, 0, 0, 255)
    actor_color = clutter.Color(255, 255, 204, 255)

    # Get the stage and set its size and color
    stage = clutter.Stage()
    stage.set_size(800, 200)
    stage.set_color(stage_color)

    # Add a non-editable text actor to the stage
    text = clutter.Text()

    # Setup text properties
    text.set_color(actor_color)
    text.set_text("Non-editable text: Wizard imps and sweat sock pimps,"
                  "interstellar mongrel nymphs.")
    text.set_font_name("Sans 12")
    text.set_editable(False)
    text.set_line_wrap(False)

    # Discover the preferred height and use that height
    min_height, natural_height = text.get_preferred_height(750)
    text.set_size(750, natural_height)
    text.set_position(5, 5)
    stage.add(text)
    text.show()

    # Add a multi-line editable text actor to the stage
    text = clutter.Text()

    # Setup text properties
    text.set_color(actor_color)
    text.set_text(
        "Editable text: And as I sat there brooding on the old, unknown world, I thought of "
        "Gatsby's wonder when he first picked out the green light at the end of "
        "Daisy's dock. He had come a long way to this blue lawn and his dream "
        "must have seemed so close that he could hardly fail to grasp it. He did "
        "not know that it was already behind him, somewhere back in that vast "
        "obscurity beyond the city, where the dark fields of the republic rolled "
        "on under the night.")
    text.set_font_name("Sans 12")
    text.set_editable(True)
    text.set_line_wrap(True)

    # Discover the preferred height and use that height
    min_height, natural_height = text.get_preferred_height(750)
    text.set_size(750, natural_height)

    text.set_position(5, 50)
    stage.add(text)
    text.show()

    # Set focus to handle key presses on the stage
    stage.set_key_focus(text)

    # Show the stage
    stage.show_all()
    stage.connect('destroy', clutter.main_quit)

    # Start the main loop, so we can respond to events
    clutter.main()

    return 0
Beispiel #27
0
    def __init__(self):
        if len(sys.argv) != 2:  #TODO: move to ... or remove
            raise SystemExit("Usage: python main.py <image file>")

        # Create a new window
        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)

        self.window.connect("delete-event", self.delete_event)
        self.window.connect("destroy", self.destroy)

        # Sets the border width of the window.
        self.window.set_title('BNF Viewer')
        self.window.set_border_width(10)
        #self.window.set_size_request(200,100)
        self.window.set_default_size(640, 400)

        self.vbox = gtk.VBox()  #False, 0
        #self.box1.pack_start(self.button1, True, True, 0)

        self.toolbar = gtk.Toolbar()
        self.toolbar.set_style(gtk.TOOLBAR_TEXT)

        self.toolbar.append_item('Rules', 'Show Rules', 'private text', None,
                                 self.on_button_clicked)
        self.toolbar.append_space()

        self.vbox.add(self.toolbar)

        self.table = gtk.Table(2, 2, False)

        self.clutter_widget = cluttergtk.Embed()
        self.clutter_widget.set_size_request(200, 200)

        self.table.attach(self.clutter_widget, 0, 1, 0, 1,
                          gtk.EXPAND | gtk.FILL, gtk.EXPAND | gtk.FILL, 0, 0)

        self.vbox.add(
            self.table)  # pack_end(self.clutter_widget, True, True, 0)

        self.stage_color = clutter.Color(0, 0, 0, 255)  # Black
        self.actor_color = clutter.Color(255, 255, 255, 153)

        self.stage = self.clutter_widget.get_stage()
        self.stage.set_color(self.stage_color)
        self.stage.set_size(640, 480)

        # Create a viewport actor to be able to scroll actor. By passing NULL it
        # will create new GtkAdjustments
        self.viewport = cluttergtk.Viewport()
        self.stage.add(self.viewport)
        self.viewport.set_size(640, 480)

        # Load image from first command line argument and add it to viewport
        self.texture = clutter.Texture(sys.argv[1])
        self.viewport_group = clutter.Group()

        self.viewport_group.add(self.texture)
        self.viewport.add(self.viewport_group)

        self.texture.set_position(0, 0)

        # Create scrollbars and connect them to viewport
        self.h_adjustment, self.v_adjustment = self.viewport.get_adjustments()
        self.scrollbar = gtk.VScrollbar(self.v_adjustment)
        self.table.attach(self.scrollbar, 1, 2, 0, 1, 0, gtk.EXPAND | gtk.FILL,
                          0, 0)

        self.scrollbar = gtk.HScrollbar(self.h_adjustment)
        self.table.attach(self.scrollbar, 0, 1, 1, 2, gtk.EXPAND | gtk.FILL, 0,
                          0, 0)

        # Connect a signal handler to handle mouse clicks and key presses on the stage
        self.stage.connect("button-press-event", self.on_stage_button_pressed)

        # Add a group to the stage
        self.group = clutter.Group()
        self.group.set_position(40, 40)
        self.viewport_group.add(self.group)

        # Add a rectangle to the stage
        self.rect = clutter.Rectangle(self.actor_color)
        self.rect.set_size(100, 400)
        self.rect.set_position(20, 20)
        self.group.add(self.rect)
        #self.rect.show()

        # Add a label to the stage
        self.label = clutter.Text("Sans 12", "Some Text", self.actor_color)
        self.label.set_size(500, 500)
        self.label.set_position(20, 15)
        self.group.add(self.label)
        #label.show()

        # This packs the button into the window (which is a container).
        self.window.add(self.vbox)

        # Show the window and the button
        self.window.show_all()