[Pychord-commits] r84 - in trunk: . docs pychord2
danilo at garage.maemo.org
danilo at garage.maemo.org
Fri Apr 4 21:27:22 EEST 2008
Author: danilo
Date: 2008-04-04 21:27:21 +0300 (Fri, 04 Apr 2008)
New Revision: 84
Modified:
trunk/docs/button_blue_playlist.svg
trunk/pychord.py
trunk/pychord2/pysql.py
trunk/pychord2/window_playlist.py
trunk/pychord2/window_show.py
Log:
-Added playlist feature
Modified: trunk/docs/button_blue_playlist.svg
===================================================================
--- trunk/docs/button_blue_playlist.svg 2008-04-04 16:00:28 UTC (rev 83)
+++ trunk/docs/button_blue_playlist.svg 2008-04-04 18:27:21 UTC (rev 84)
@@ -70,7 +70,10 @@
sodipodi:rx="17.875"
sodipodi:ry="17.875"
d="M 48.375,37.25 A 17.875,17.875 0 1 1 12.625,37.25 A 17.875,17.875 0 1 1 48.375,37.25 z"
- transform="matrix(1.3986014,0,0,1.3986014,-17.657343,-27.097902)" />
+ transform="matrix(1.3986014,0,0,1.3986014,-17.657343,-27.097902)"
+ inkscape:export-filename="/Users/danilo/Projects/pychord2/trunk/img/playlist.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90" />
<path
transform="matrix(1.2027972,0,0,1.2027972,-12.060315,-18.554195)"
d="M 48.375,37.25 A 17.875,17.875 0 1 1 12.625,37.25 A 17.875,17.875 0 1 1 48.375,37.25 z"
@@ -80,7 +83,10 @@
sodipodi:cx="30.5"
id="path3163"
style="opacity:0.39800995;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
- sodipodi:type="arc" />
+ sodipodi:type="arc"
+ inkscape:export-filename="/Users/danilo/Projects/pychord2/trunk/img/playlist.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90" />
<path
sodipodi:type="arc"
style="opacity:1;fill:#0509c3;fill-opacity:1;stroke:none;stroke-width:0.83139533;stroke-miterlimit:0;stroke-dasharray:none;stroke-opacity:1"
@@ -90,7 +96,10 @@
sodipodi:rx="17.875"
sodipodi:ry="17.875"
d="M 48.375,37.25 A 17.875,17.875 0 1 1 12.625,37.25 A 17.875,17.875 0 1 1 48.375,37.25 z"
- transform="matrix(1.2027972,0,0,1.2027972,-11.935315,-20.304195)" />
+ transform="matrix(1.2027972,0,0,1.2027972,-11.935315,-20.304195)"
+ inkscape:export-filename="/Users/danilo/Projects/pychord2/trunk/img/playlist.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90" />
<path
transform="matrix(1.3986014,0,0,1.3986014,-17.657343,-27.097902)"
d="M 48.375,37.25 A 17.875,17.875 0 1 1 12.625,37.25 A 17.875,17.875 0 1 1 48.375,37.25 z"
@@ -100,7 +109,10 @@
sodipodi:cx="30.5"
id="path3501"
style="opacity:1;fill:#0004b1;fill-opacity:1;stroke:none;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
- sodipodi:type="arc" />
+ sodipodi:type="arc"
+ inkscape:export-filename="/Users/danilo/Projects/pychord2/trunk/img/playlist.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90" />
<path
sodipodi:type="arc"
style="opacity:0.39800995;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
@@ -110,7 +122,10 @@
sodipodi:rx="17.875"
sodipodi:ry="17.875"
d="M 48.375,37.25 A 17.875,17.875 0 1 1 12.625,37.25 A 17.875,17.875 0 1 1 48.375,37.25 z"
- transform="matrix(1.2027972,0,0,1.2027972,-12.060315,-18.554195)" />
+ transform="matrix(1.2027972,0,0,1.2027972,-12.060315,-18.554195)"
+ inkscape:export-filename="/Users/danilo/Projects/pychord2/trunk/img/playlist.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90" />
<path
transform="matrix(1.2027972,0,0,1.2027972,-11.935315,-20.304195)"
d="M 48.375,37.25 A 17.875,17.875 0 1 1 12.625,37.25 A 17.875,17.875 0 1 1 48.375,37.25 z"
@@ -120,12 +135,18 @@
sodipodi:cx="30.5"
id="path3505"
style="opacity:1;fill:#0509c3;fill-opacity:1;stroke:none;stroke-width:0.83139533;stroke-miterlimit:0;stroke-dasharray:none;stroke-opacity:1"
- sodipodi:type="arc" />
+ sodipodi:type="arc"
+ inkscape:export-filename="/Users/danilo/Projects/pychord2/trunk/img/playlist.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90" />
<flowRoot
xml:space="preserve"
id="flowRoot3493"
style="font-size:12px;font-style:normal;font-weight:normal;fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:0.28059629;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;font-family:Bitstream Vera Sans"
- transform="matrix(3.5638389,0,0,3.5638389,-32.553839,-38.214816)"><flowRegion
+ transform="matrix(3.5638389,0,0,3.5638389,-32.553839,-38.214816)"
+ inkscape:export-filename="/Users/danilo/Projects/pychord2/trunk/img/playlist.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90"><flowRegion
id="flowRegion3495"><rect
id="rect3497"
width="28.875"
Modified: trunk/pychord.py
===================================================================
--- trunk/pychord.py 2008-04-04 16:00:28 UTC (rev 83)
+++ trunk/pychord.py 2008-04-04 18:27:21 UTC (rev 84)
@@ -108,16 +108,39 @@
def save(self):
f = open (self.file, 'w')
f.write('db='+ self.opt['db'] +'\n')
- f.write('datadir='+ self.opt['datadir'])
+ f.write('datadir='+ self.opt['datadir'] + '\n')
- # Writing playlist
- f.write("playlist="+ self.opt['playlist'])
+ if self.opt['playlist'] == ',':
+ self.opt['playlist'] = ''
+ f.write("playlist="+ self.opt['playlist'])
+ f.close()
- f.close()
+
+ def addToPlaylist(self, id):
+ opt = self.opt['playlist'].split(',')
+ if opt.count(id) == 0:
+ opt.append(id)
+ self.opt['playlist'] = ','.join(opt)
+ self.save()
+
+ def removeFromPlaylist(self, id):
+ opt = self.opt['playlist'].split(',')
+ if self.isInPlaylist(id):
+ opt.remove(id)
+ self.opt['playlist'] = ','.join(opt)
+ self.save()
+
+ def isInPlaylist(self, id):
+ opt = self.opt['playlist'].split(',')
+ if opt.count(id) != 0:
+ return True
+ return False
+
+
def main( argv ):
#primeiro vamos verificar que estamos no diretorio certo para conseguir
#encontrar as imagens e outros recursos, e inicializar o pygame com as
Modified: trunk/pychord2/pysql.py
===================================================================
--- trunk/pychord2/pysql.py 2008-04-04 16:00:28 UTC (rev 83)
+++ trunk/pychord2/pysql.py 2008-04-04 18:27:21 UTC (rev 84)
@@ -84,7 +84,12 @@
def search(self, by, key):
cur = self.connection.cursor()
- sql = 'select id,artist,song from tabs where '+by+' like "%'+ key +'%" LIMIT 30'
+
+ if by == 'playlist':
+ sql = 'select id,artist,song from tabs where id IN ('+ key +') LIMIT 100'
+ else:
+ sql = 'select id,artist,song from tabs where '+by+' like "%'+ key +'%" LIMIT 30'
+
cur.execute(sql)
return cur.fetchall()
Modified: trunk/pychord2/window_playlist.py
===================================================================
--- trunk/pychord2/window_playlist.py 2008-04-04 16:00:28 UTC (rev 83)
+++ trunk/pychord2/window_playlist.py 2008-04-04 18:27:21 UTC (rev 84)
@@ -1,24 +1,64 @@
-# -*- coding: utf-8 -*-
from pgui import window
from pgui import label
+from pgui import input
from pgui import Ibutton
+from pgui import list
-
+from pysql import *
import pygame
-
class window_playlist( window ):
+
def __init__(self, screen, pyc):
+
+ # creating window
window.__init__(self, None, screen )
- self.setBackground((0,0,0))
+ # Put something in the screen
+ # while sqlite search by the keyword
+ # When it finish, clean the event list
+ lbls = label(self, [250,250],"Opening Playlist...", ptsize=60, bgcolor = (0,0,255))
+ lbls.draw(screen)
+ pygame.display.flip()
+
self.pyc = pyc
+ # SQL RESULTS
+ p = pysql(pyc.opt['db'],pyc.opt['datadir'])
+
+ res = p.search('playlist',pyc.opt['playlist'])
+
+
+ # clear event list
+ pygame.event.clear()
+
btX = Ibutton(self,[730,10],"x.png")
btX.registerClickSlot(self.close)
self.addElement(btX)
+
+ lblSearch = label(self, [10,10],"Playlist", ptsize = 40)
+ self.addElement(lblSearch)
- # Title Label
- lbl = label(self,[20,30],"Playlist", ptsize = 50)
- self.addElement(lbl)
\ No newline at end of file
+ lst = list(self, [10,60], width=700, height=400, ptsize=40) # creating the widget
+ lst.setBackground((10,10,10))
+ self.addElement(lst)
+
+
+ i = 0
+ for l in res:
+ j = l[2] + ', by ' + l[1] + ''
+ lbl = lst.addLine(j, 20)
+ lbl.registerClickSlot(self.openSong, l[0])
+ i += 1
+
+ # If there ae no results
+ if i == 0:
+ noresult = label(self, [20, 200],'No result found',ptsize=35)
+ self.addElement(noresult)
+
+ def openSong(self, song):
+ from window_show import window_show
+ window = window_show(self.screen, self.pyc, song)
+ window.show()
+ self.repaint()
\ No newline at end of file
Modified: trunk/pychord2/window_show.py
===================================================================
--- trunk/pychord2/window_show.py 2008-04-04 16:00:28 UTC (rev 83)
+++ trunk/pychord2/window_show.py 2008-04-04 18:27:21 UTC (rev 84)
@@ -109,8 +109,11 @@
def __init__(self, father, screen, pyc, SongCod, lst):
- size = [400,100]
+ size = [500,100]
position = [300,100]
+
+ self.Song = SongCod
+ self.pyc = pyc
window.__init__(self, father, screen, [], position, size)
@@ -125,24 +128,38 @@
btToneDown.registerClickSlot(self.close)
self.addElement(btToneDown)
- btAddToPlaylist = Tbutton(self, [150,10],"Add to Playlist", height = 50)
- btAddToPlaylist.registerClickSlot(self.addToPlaylist)
- btAddToPlaylist.registerClickSlot(self.close)
- self.addElement(btAddToPlaylist)
+ self.btAddToPlaylist = Tbutton(self, [150,10],"Add to Playlist", height = 50)
+ self.btAddToPlaylist.registerClickSlot(self.addToPlaylist)
+
+ self.btRmToPlaylist = Tbutton(self, [150,10],"Remove From Playlist", height = 50)
+ self.btRmToPlaylist.registerClickSlot(self.removeFromPlaylist)
+
+ if not self.pyc.isInPlaylist(str(self.Song)):
+ self.addElement(self.btAddToPlaylist)
+ else:
+ self.addElement(self.btRmToPlaylist)
+
+
self.setBackground((50,50,50))
def setIsPress(self):
if not self.rect.collidepoint(pygame.mouse.get_pos()):
self.close()
window.setIsPress(self)
-
- def select(self, key):
- self.selected = key
+
+ def addToPlaylist(self):
+ self.pyc.addToPlaylist(str(self.Song))
+ self.delElement(self.btAddToPlaylist)
+ self.addElement(self.btRmToPlaylist)
self.close()
- def addToPlaylist(self):
- print "addToPlaylist"
+ def removeFromPlaylist(self):
+ self.pyc.removeFromPlaylist(str(self.Song))
+ self.addElement(self.btAddToPlaylist)
+ self.delElement(self.btRmToPlaylist)
+ self.close()
+
def ismaemo():
import platform
More information about the Pychord-commits
mailing list