Exemplo n.º 1
0
 def album_data():
     try:
         cwd = os.getcwd()
         coverart = cwd +  '/coverart'
         f=open(coverart)
         coverart = f.readline()
         file = cStringIO.StringIO(urllib.urlopen(coverart).read())
         img = pygame.image.load(file)
         screen.blit(pygame.transform.scale(img, (200, 200)), (140, 112))
         pygame.draw.rect(screen, black, [  4, 4, 480, 100])
         make_label(song(),4,2,32,music_data_color)
         make_label(artist(),4,28,32,music_data_color)
         make_label(album(),4,52,32,music_data_color)
         make_label(station(),4,76,32,music_data_color)
         pygame.display.update()            
     except IOError:
         pass 
Exemplo n.º 2
0
def songtext():
    # colors    R    G    B
    white   = (255, 255, 255)
    red     = (255,   0,   0)
    green   = (  0, 255,   0)
    blue    = (102, 102,   0)
    #blue    = (  0,   0, 255)
    black   = (  0,   0,   0)
    cyan    = ( 50, 255, 255)
    magenta = (255,   0, 255)
    yellow  = (255, 255,   0)
    orange  = (255, 127,   0)

    # Set up the base menu you can customize your menu with the colors above

    #set size of the screen
    size = width, height = 480, 320
    screen = pygame.display.set_mode((size), pygame.FULLSCREEN )
    pygame.init()
    pygame.mouse.set_visible(1)

    # the 'normal' font
    base_font = pygame.font.SysFont('Arial', 24, 1)

    # the 'mouse-over' font
    mod_font  = pygame.font.SysFont('Arial', 24, 1)
    mod_font.set_underline(True)

    # always use some kind of cache when rendering font
    # font rendering is very expensive, and it *will*
    # slow down your application if you render some text
    cache = {}

    # always use a Clock to keep your framerate constant
    clock = pygame.time.Clock()

    run = True
    while run:




        def render(text, mod=False):
            if not mod in cache:
                cache[mod] = {}
            if not text in cache[mod]:
                cache[mod][text] = (mod_font if mod else base_font).render(text, True, (255, 255, 255))
            return cache[mod][text]

    # create a list of (text, Rect)-tuples
        x, y = 1, 20
        objetcs = [(t, render(t).get_rect()) for t in (song(), artist(), album(), station())]

    # just move some objects around
        for (_, r) in objetcs:
            r.top, r.left = y, x
            x *= 2
            y += 60




        # clear the screen
        screen.fill((0, 0, 0))

        # draw all objects
        for (t, r) in objetcs:
            # decide if we want to render the text with or without the underline
            # based on the result of collidepoint(pygame.mouse.get_pos())
            # note that collidepoint is a method of Rect, not Surface
            screen.blit(render(t, r.collidepoint(pygame.mouse.get_pos())), r)

        # check which item is clicked
        if pygame.event.get(pygame.MOUSEBUTTONDOWN):
            # calling 'render' over and over again is cheap now, since the resut is cached
            for text in [t for (t, r) in objetcs if r.collidepoint(pygame.mouse.get_pos())]:
                print "'{}' was clicked".format(text)

        # draw the screen ONCE
        pygame.display.flip()
        if pygame.event.get(pygame.QUIT): run = False
        # clear all unwanted events
        pygame.event.clear()
        clock.tick(60)


        for event in pygame.event.get():
            if event.type == KEYDOWN:
                if event.key == K_ESCAPE:
                   sys.exit()
Exemplo n.º 3
0
def test_album1():
    return album(10, 2, 5, [4, 7], [7, 1, 2, 8, 3]) == 1
Exemplo n.º 4
0
def test_album2():
    return album(10, 2, 6, [4, 7], [7, 1, 8, 4, 9, 3]) == 0
Exemplo n.º 5
0
def test_album4():
    return album(8, 4, 10, [2, 4, 6, 8], [3, 1, 1, 5, 3, 1, 7, 7, 1, 1]) == 4
Exemplo n.º 6
0
def test_album5():
    return album(10, 2, 5, [4, 7], [7, 7, 2, 8, 3]) == 1
Exemplo n.º 7
0
def test_03():
    assert album(car=[2,4,6,8],com=[3,1,1,5,3,1,7,7,1,1]) == 4
Exemplo n.º 8
0
def test_02():
    assert album(car=[4,7],com=[7,1,8,4,9,3]) == 0
Exemplo n.º 9
0
def test_01():
    assert album(car=[4,7],com=[7,1,2,8,3]) == 1
Exemplo n.º 10
0
from album import album
import sys
import os

path = sys.argv[1]
alb = album(path)
alb.save()
os.remove(path + "/___temp.jpg")
Exemplo n.º 11
0
    currentAlbum = 0
    if (platform.machine() == "armv7h"):
        os.putenv('SDL_MOUSEDRV', 'TSLIB')
        screen = pygame.display.set_mode((w, h), pygame.FULLSCREEN, 32)
    else:
        screen = pygame.display.set_mode((w, h), 0, 32)

    screen.fill(((255, 64, 64)))

    Albums = []

    queue = Queue.Queue()
    rootDir = '../../emilMP3/music'
    for dirName in os.listdir(rootDir):
        log.debug('Found directory: %s' % dirName)
        Albums.append(album(os.path.join(rootDir, dirName)))

    log.debug(Albums)
    ButtonRight = AAfilledRoundedRect(screen, (710, 20, 80, 80), (200, 20, 20),
                                      0.5, unichr(0xf105), 80)
    ButtonLeft = AAfilledRoundedRect(screen, (490, 20, 80, 80), (200, 20, 20),
                                     0.5, unichr(0xf104), 80)
    ButtonUp = AAfilledRoundedRect(screen, (710, 140, 80, 80), (200, 20, 20),
                                   0.5, unichr(0xf106), 80)
    ButtonDown = AAfilledRoundedRect(screen, (490, 140, 80, 80), (200, 20, 20),
                                     0.5, unichr(0xf107), 80)
    ButtonVolumeUp = AAfilledRoundedRect(screen, (710, 260, 80, 80),
                                         (200, 20, 20), 0.5, unichr(0xf028))
    ButtonVolumeDown = AAfilledRoundedRect(screen, (490, 260, 80, 80),
                                           (200, 20, 20), 0.5, unichr(0xf027))
    #ButtonStop = AAfilledRoundedRect(screen,(710,380,80,80),(200,20,20),0.5,unichr(0xf04d),50)