def __init__(self, sonos, title, tracks, playlist):
        NavigationScene.__init__(self, title)

        self.sonos = sonos
        self.background_color = colors.NAVY

        self.tracks = tracks
        self.track_titles = []
        self.playlist = playlist
        for track in self.tracks:
            self.track_titles.append(track.title)       

        # Add list of tracks
        self.track_list_view = ListView(Rect(0,80,Window.frame.width, Window.frame.height - 80),self.track_titles)
        self.track_list_view.on_selected.connect(self.track_selected)
        self.add_child(self.track_list_view)

        ##### Play All Button #####
        play_all_button_image = Image('play_all_button',filename='play_all.png')
        self.play_all_button = Button(Rect(30,self.frame.height - 55,30,30),image=play_all_button_image)        
        self.play_all_button.on_tapped.connect(self.play_all)        
        self.add_child(self.play_all_button)

        ##### Shuffle Button #####
        shuffle_button_image = Image('shuffle_button',filename='shuffle.png')
        self.shuffle_button = Button(Rect(250,self.frame.height - 60,40,40),image=shuffle_button_image)        
        self.shuffle_button.on_tapped.connect(self.shuffle)        
        self.add_child(self.shuffle_button) 
    def __init__(self, frame, items):
        View.__init__(self, frame)

        self.items = items
        self.list_buttons = []
        self.list_index = 0
        self.per_page = 7

        self.on_selected = Signal()

        ##### Previous Button #####
        previous_button_image = Image('previous_button',
                                      filename='previous_button.png')
        self.previous_button = Button(Rect(110, self.frame.height - 60, 40,
                                           40),
                                      image=previous_button_image)
        self.previous_button.on_tapped.connect(self.previous)
        self.previous_button.hidden = True
        self.add_child(self.previous_button)

        ##### Next Button #####
        next_button_image = Image('next_button', filename='next_button.png')
        self.next_button = Button(Rect(170, self.frame.height - 60, 40, 40),
                                  image=next_button_image)
        self.next_button.on_tapped.connect(self.next)
        self.next_button.hidden = True
        self.add_child(self.next_button)

        self.layout()

        self.create_items()
예제 #3
0
 def post(self):
     data = self.request.get("img_data")
     name = self.request.get("img_name")
     if data == "":
         logging.info("image upload missing data")
     elif name == "":
         logging.info("image upload missing name")
     else:
         image = Image()
         image.name = name
         image.data = db.Blob(data)
         image.put()
     self.redirect("/admin/?image=" + name)
예제 #4
0
def choices_from_db(force_reload=False):
    global BACKGROUND_IMAGES
    if (BACKGROUND_IMAGES is None) or force_reload:
        from ui.image import Image
        objs = Image.gql("WHERE role = :1", "attribute").fetch(MAX_COUNT)
        BACKGROUND_IMAGES = sorted(map(lambda x: x.name.split("/")[1], objs))
    return BACKGROUND_IMAGES
예제 #5
0
def populars_from_db():
    global POPULAR_IMAGES
    if POPULAR_IMAGES is None:
        from ui.image import Image
        objs = Image.gql("WHERE role = :1", "popular").fetch(MAX_COUNT)
        POPULAR_IMAGES = sorted(map(lambda x: x.name.split("/")[1], objs))
    return POPULAR_IMAGES
예제 #6
0
 def __init__(self, parent):
     self.scrWidth = parent.screen.get_rect().width
     self.scrHeight = parent.screen.get_rect().height
     self.items = []
     self.createMenuItems(('New Game', 'Continue', 'Options', 'Quit Game'))
     self.mainImage = Image("menu/s2_Logo.png", (700, 400),
                            (self.scrWidth / 6, 0))
     MusicLoader.loadMusic("menu/Battle2.mp3")
     MusicLoader.play(True)
    def generate_rooms(self):
        checkbox_empty_image = Image('checkbox_empty',
                                     filename='checkbox_empty.png')
        checkbox_filled_image = Image('checkbox_filled',
                                      filename='checkbox_filled.png')
        members = self.sonos.group_members
        y = 80
        for zone in self.sonos.potential_members:
            select_room_button = Button(Rect(60, y, 280, 30),
                                        34,
                                        Label.LEFT,
                                        image=checkbox_empty_image,
                                        checked_image=checkbox_filled_image,
                                        text=zone)
            select_room_button.on_tapped.connect(self.select_room)
            self.add_child(select_room_button)
            self.room_buttons.append(select_room_button)
            y += 60

            if zone in members:
                # this zone is already a member
                select_room_button.checked = True
    def __init__(self, sonos):
        ModalScene.__init__(self, sonos.current_zone)

        self.sonos = sonos

        in_party_mode = Sonos.in_party_mode()

        ##### Party Mode On Button #####
        icon_party_on_image = Image('icon_party_on',
                                    filename='icon_party_on.png')
        self.party_on_button = Button(Rect(270, 20, 30, 30),
                                      image=icon_party_on_image)
        self.party_on_button.hidden = in_party_mode
        self.party_on_button.on_tapped.connect(self.group_all)
        self.add_child(self.party_on_button)

        ##### Party Mode Off Button #####
        icon_party_off_image = Image('icon_party_off',
                                     filename='icon_party_off.png')
        self.party_off_button = Button(Rect(270, 20, 30, 30),
                                       image=icon_party_off_image)
        self.party_off_button.on_tapped.connect(self.group_none)
        self.party_off_button.hidden = not in_party_mode
        self.add_child(self.party_off_button)

        ##### Done Button #####
        self.done_button = Button(Rect(20, 430, 280, 40), 40, text='Done')
        self.done_button.on_tapped.connect(self.done)
        self.add_child(self.done_button)

        self.room_buttons = []

        self.unchanged = True

        self.layout()
        self.generate_rooms()
    def __init__(self, title):
        Scene.__init__(self)

        self.background_color = colors.MODAL

        # Title label
        self.title_label = Label(Rect(50, 20, 220, 40), title, 40,
                                 colors.WHITE)
        self.add_child(self.title_label)

        ##### Back Button #####
        icon_back_image = Image('icon_back', filename='icon_back.png')
        self.back_button = Button(Rect(20, 20, 30, 30), image=icon_back_image)
        self.back_button.on_tapped.connect(self.back)
        self.add_child(self.back_button)

        self.layout()
    def update_track_info(self, track, tv_playing):
        self.track_label.text = track['title']
        self.artist_label.text = track['artist']
        self.album_label.text = track['album']

        if tv_playing:
            self.play_button.enabled = False
            self.update_play_pause('PAUSED_PLAYBACK')    

        # Only set the image if the album name has changed or if it is empty 
        # (sometimes the album name is empty) but the album art has changed
        if self.album_art_view.image.name != self.album_label.text or self.album_label.text == "":                    
            # Set album art to the url given if it is not empty, otherwise use the default image
            if track['album_art'].strip() != "":
                album_art_image = Image(self.album_label.text,image_url=track['album_art'])
                if album_art_image.surface is not None:
                    self.album_art_view.image = album_art_image
                else:
                    self.album_art_view.image = self.empty_album_image
            elif tv_playing:
                self.album_art_view.image = self.tv_album_image
            else:
                self.album_art_view.image = self.empty_album_image         
예제 #11
0
def send_img(name, role):
    filename = IMG_PATH + name
    name = name[:-4]
    logging.debug("try to send %s" % name)
    img = Image.gql("WHERE name = :1", name).get()
    if img is not None:
        logging.info("image %s exists" % name)
        return False
    try:
        f = open(filename, 'r')
    except IOError:
        logging.info("missing file %s" % name)
        return False
    data = f.read()
    f.close()
    image = Image()
    image.name = name
    image.data = db.Blob(data)
    image.role = role
    image.put()
    logging.debug("sent ok")
    return True
    def __init__(self, sonos):
        Scene.__init__(self)
        self.sonos = sonos                  
        self.firstLoad = True

        ########## SETUP UI ##########

        self.background_color = colors.NAVY

        # Select Music
        select_music_image = Image('select_music',filename='select_music.png')
        self.select_music_button = Button(Rect(20,20,30,30),image=select_music_image)
        self.select_music_button.on_tapped.connect(self.select_music_modal)
        self.add_child(self.select_music_button)

        # Current Room   
        self.room_label = Label(Rect(50,24,220,30),self.sonos.current_zone_label,30,colors.WHITE)
        self.add_child(self.room_label)

        # Select Room
        select_room_image = Image('select_room',filename='select_room.png')
        self.select_room_button = Button(Rect(270,20,30,30),image=select_room_image)
        self.select_room_button.on_tapped.connect(self.select_room_modal)
        self.add_child(self.select_room_button)

        # Album Art
        self.empty_album_image = Image('empty_album',filename='empty_album_art.png')
        self.tv_album_image = Image('tv_album_art',filename='tv_album_art.png')
        self.album_art_view = ImageView(Rect(80,72,160,160),self.empty_album_image)
        self.add_child(self.album_art_view)

        # Track Title   
        self.track_label = Label(Rect(20,256,280,30),"",36, colors.WHITE)             
        self.add_child(self.track_label)
        # Artist
        self.artist_label = Label(Rect(20,296,280,20),"",24, colors.GRAY)
        self.add_child(self.artist_label)
        # Album
        self.album_label = Label(Rect(20,321,280,20),"",24, colors.GRAY)
        self.add_child(self.album_label)

        ##### Play Button #####
        play_track_img = Image('play_track',filename='play_track.png')
        play_track_disabled_img = Image('play_track_disabled',filename='play_track_disabled.png')
        self.play_button = Button(Rect(130,360,60,60),image=play_track_img, disabled_image=play_track_disabled_img)
        #Touch Handler
        self.play_button.on_tapped.connect(self.play)
        self.add_child(self.play_button)

        ##### Pause Button #####
        pause_track_img = Image('pause_track',filename='pause_track.png')
        self.pause_button = Button(Rect(130,360,60,60),image=pause_track_img)
        self.pause_button.hidden = True
        #Touch Handler
        self.pause_button.on_tapped.connect(self.pause)
        self.add_child(self.pause_button)

        ##### Previous Track #####
        previous_track_img = Image('previous_track',filename='previous_track.png')
        previous_track_disabled_img = Image('previous_track_disabled',filename='previous_track_disabled.png')        
        self.previous_button = Button(Rect(65,370,40,40),image=previous_track_img, disabled_image=previous_track_disabled_img)
        #Touch Handler
        self.previous_button.on_tapped.connect(self.previous)
        self.add_child(self.previous_button)

        ##### Next Track #####
        next_track_img = Image('next_track',filename='next_track.png')
        next_track_disabled_img = Image('next_track_disabled',filename='next_track_disabled.png')
        self.next_button = Button(Rect(215,370,40,40),image=next_track_img,disabled_image=next_track_disabled_img)
        #Touch Handler
        self.next_button.on_tapped.connect(self.next)
        self.add_child(self.next_button)

        ##### Volume Down Button #####
        volume_down_img = Image('volume_down',filename='volume_down.png')
        self.volume_down_button = Button(Rect(92,438,30,30),image=volume_down_img)
        #Touch Handler
        self.volume_down_button.on_tapped.connect(self.volume_down)
        self.add_child(self.volume_down_button)

        ##### Volume On Button #####
        volume_on_img = Image('volume_on',filename='volume_on.png')
        self.volume_on_button = Button(Rect(147,440,26,26),image=volume_on_img)
        #Touch Handler
        self.volume_on_button.on_tapped.connect(self.mute)
        self.add_child(self.volume_on_button)

        ##### Volume Mute Button #####
        volume_mute_img = Image('volume_mute',filename='volume_mute.png')
        self.volume_mute_button = Button(Rect(147,440,26,26),image=volume_mute_img)
        self.volume_mute_button.hidden = True
        #Touch Handler
        self.volume_mute_button.on_tapped.connect(self.unmute)
        self.add_child(self.volume_mute_button)

        # Volume Level Label
        self.volume_label = Label(Rect(30,447,40,30),"",20, colors.GRAY)
        self.add_child(self.volume_label)

        ##### Volume Up Button #####
        volume_up_img = Image('volume_up',filename='volume_up.png')    
        self.volume_up_button = Button(Rect(197,438,30,30),image=volume_up_img)
        #Touch Handler
        self.volume_up_button.on_tapped.connect(self.volume_up)
        self.add_child(self.volume_up_button)

        ##### Group Rooms Button #####
        group_rooms_img = Image('group_rooms',filename='group_rooms.png')
        self.group_rooms_button = Button(Rect(270,440,26,26),image=group_rooms_img)
        #Touch Handler
        self.group_rooms_button.on_tapped.connect(self.group_rooms_modal)
        self.add_child(self.group_rooms_button)        

        # Layout the scene
        self.layout()

        # Keep hidden until everything has loaded
        self.hidden = True

        ########## END SETUP UI ##########

        # Listen for all changes to the current zone   
        self.sonos.listen_for_zone_changes(self.zone_state_changed)