[Pychord-commits] r52 - in trunk: pgui pychord2
danilo at garage.maemo.org
danilo at garage.maemo.org
Sun Mar 9 20:07:47 EET 2008
Author: danilo
Date: 2008-03-09 20:07:38 +0200 (Sun, 09 Mar 2008)
New Revision: 52
Added:
trunk/pychord2/pysql.py
Modified:
trunk/pgui/combo.py
trunk/pgui/input.py
trunk/pgui/label.py
trunk/pgui/pguiobject.py
trunk/pychord2/window_show.py
Log:
- Combo bug fixed
- Fixing SQLite3 support
Modified: trunk/pgui/combo.py
===================================================================
--- trunk/pgui/combo.py 2008-03-09 15:59:11 UTC (rev 51)
+++ trunk/pgui/combo.py 2008-03-09 18:07:38 UTC (rev 52)
@@ -46,8 +46,8 @@
self.modify("")
else:
self.modify(self.options[key])
+
-
class comboWindow(window):
def __init__(self, father, screen, options, selected, position, hOffset, width):
Modified: trunk/pgui/input.py
===================================================================
--- trunk/pgui/input.py 2008-03-09 15:59:11 UTC (rev 51)
+++ trunk/pgui/input.py 2008-03-09 18:07:38 UTC (rev 52)
@@ -55,7 +55,7 @@
# Cuting the image
self.label.cutImg(self.size[0] - 4)
self.dirty = True
- pass
+
def onMouseOn(self):
self.input.setBackground((200,100,100))
Modified: trunk/pgui/label.py
===================================================================
--- trunk/pgui/label.py 2008-03-09 15:59:11 UTC (rev 51)
+++ trunk/pgui/label.py 2008-03-09 18:07:38 UTC (rev 52)
@@ -36,4 +36,4 @@
pass
def modify(self, text):
- self.__init__(self.father, self.position, text, self.color, self.bgcolor, self.fontfile, self.ptsize)
\ No newline at end of file
+ self.__init__(self.father, self.position, text, self.color, self.bgcolor, self.fontFile, self.ptsize)
\ No newline at end of file
Modified: trunk/pgui/pguiobject.py
===================================================================
--- trunk/pgui/pguiobject.py 2008-03-09 15:59:11 UTC (rev 51)
+++ trunk/pgui/pguiobject.py 2008-03-09 18:07:38 UTC (rev 52)
@@ -94,7 +94,6 @@
def onClick(self):
- print "onClick",self
self.mouseOn = True
self.clicked = True
self.onMouseOn()
Added: trunk/pychord2/pysql.py
===================================================================
--- trunk/pychord2/pysql.py (rev 0)
+++ trunk/pychord2/pysql.py 2008-03-09 18:07:38 UTC (rev 52)
@@ -0,0 +1,78 @@
+import sqlite3
+import sys
+import os
+import string
+
+
+class DirFileList:
+ def __init__(self):
+ self._dirFileList = []
+
+ def __listDirs(self, path):
+ try:
+ if os.path.isfile(path) is True:
+ if path[-3:] == 'chr':
+ self._dirFileList.append(path)
+ else:
+ abspath = map(lambda x: os.path.join(path, x),os.listdir(path))
+ if abspath is not []:
+ map(lambda x: self.__listDirs(x), abspath)
+ except:
+ self._dirFileList.extend(path)
+
+ def getDirFileList(self):
+ return self._dirFileList
+
+ def setDirFileList(self, path):
+ self.__listDirs(path)
+
+ dirFileList = property(fget=getDirFileList, fset=setDirFileList)
+
+
+class pysql( object ):
+
+ cur = None
+ connection = None
+
+ def __init__(self, dbFileName, tdName):
+ self.connection = sqlite3.connect(dbFileName)
+
+ self.tdName = tdName
+ self.dbFileName = dbFileName
+
+ def update(self):
+ p = DirFileList()
+ p.setDirFileList(self.tdName)
+
+ for file in p.getDirFileList():
+ f = open(file)
+ name = f.readline()[:-1][6:]
+ artist = f.readline()[:-1][8:]
+ tab = f.read()
+ f.close()
+
+ cur = self.connection.cursor()
+ sql = 'INSERT INTO tabs ( id, artist, song, tab) VALUES (null, %s, %s, %s)'
+ cur.execute(sql,(artist,name,tab))
+ self.connection.commit()
+
+ def create(self):
+ import os
+ os.unlink(self.dbFileName)
+ self.__init__(self.dbFileName, self.tdName)
+ cur = self.connection.cursor()
+ sql = "Create Table tabs (id INTEGER PRIMARY KEY, artist VARCHAR, song VARCHAR, tab VARCHAR)"
+ cur.execute(sql)
+ self.connection.commit()
+
+ def search(self, by, key):
+ cur = self.connection.cursor()
+ sql = 'select id,artist,song from tabs where '+by+' like "%'+ key +'%" LIMIT 10'
+ cur.execute(sql)
+ return cur.fetchall()
+
+ def get (self, id):
+ cur = self.connection.cursor()
+ sql = 'select tab from tabs where id=%s LIMIT 10'
+ cur.execute(sql,(id))
+ return cur.fetchall()
\ No newline at end of file
Modified: trunk/pychord2/window_show.py
===================================================================
--- trunk/pychord2/window_show.py 2008-03-09 15:59:11 UTC (rev 51)
+++ trunk/pychord2/window_show.py 2008-03-09 18:07:38 UTC (rev 52)
@@ -13,49 +13,38 @@
-class main_window( window ):
+class window_show( window ):
- def __init__(self, screen, pyc):
-
- self.pyc = pyc
+ def __init__(self, screen, pyc, SongCod):
window.__init__(self, None, screen )
self.setBackground((0,0,0))
- btX = Ibutton(self,[730,10],"x.png")
- btX.registerClickSlot(self.close)
- self.addElement(btX)
+ # Geting the chords
+ self.pyc = pyc
+ self.SongCod = SongCod
+ p = pysql(pyc.opt['db'],pyc.opt['datadir'])
+ res = p.get(id)
-# lbl = label(self, [10,70],"Search By:")
-# self.addElement(lbl)
-#
-# inp = input(self, [10, 110],"",width=700)
-# self.addElement(inp)
-#
-# lbl = label(self, [10,200],"Search on:")
-# self.addElement(lbl)
-#
-# cmb = combo(self, [10, 240], {'tab':'By Word','artist':'By Artist','song':'By Music'} ,width=700)
-# self.addElement(cmb)
-#
-# btSearch = Tbutton(self, [410,300], "Search", width = 300, bsize = 3, padding = 6)
-# self.addElement(btSearch)
-
- lst = chordlist(self, [0,0],["Ola mundo, aaaaaaaaaaaaaaaaaaa bla bla aaaaaaaa bla", "Ola mundo, bla bla bla",
- "Ola mundo, aaaaaaaaaaaaaaaaaaabla bla bla","Ola mundo, bla bla bla","Ola mundo, bla bla bla",
- "Ola mundo, aaaaaaaaaaaaaaaaaaabla bla bla","Ola mundo, bla bla bla","Ola mundo, bla bla bla",
- "Ola mundo, aaaaaaaaaaaaaaaaaaabla bla bla","Ola mundo, bla bla bla","Ola mundo, bla bla bla",
- "Ola mundo, bla bla bla","Ola mundo, bla bla bla","Ola mundo, bla bla bla",
- "Ola mundo, bla bla bla", "Ola mundo, bla bla bla",
- "Ola mundo, bla bla bla","Ola mundo, bla bla bla","Ola mundo, bla bla bla",
- "Ola mundo, bla bla bla","Ola mundo, bla bla bla","Ola mundo, bla bla bla"])
+ lines = res[0][0]
+ lines = lines.replace("\t"," ") # tabs -> 4 spaces
+ lines = lines.splitlines()
+ lst = chordlist(self, [0,0],lines) # creating the widget
lst.setBackground((10,10,10))
lst.autoScroll(2)
self.addElement(lst)
self.chordList = lst
+
+ btX = Ibutton(self,[730,10],"x.png")
+ btX.registerClickSlot(self.close)
+ self.addElement(btX)
+
+
+
+
btFF = Ibutton(self,[730,400],"ff.png")
btFF.registerPressedSlot(lst.increaseSpeed)
self.addElement(btFF)
More information about the Pychord-commits
mailing list