[Pychord-commits] r55 - tags/0.0.3 trunk/pgui trunk/pychord2
danilo at garage.maemo.org
danilo at garage.maemo.org
Sat Mar 15 02:15:18 EET 2008
Author: danilo
Date: 2008-03-15 02:15:15 +0200 (Sat, 15 Mar 2008)
New Revision: 55
Modified:
tags/0.0.3/pychord.py
trunk/pgui/window.py
trunk/pychord2/main_window.py
trunk/pychord2/pysql.py
trunk/pychord2/window_info.py
trunk/pychord2/window_search.py
Log:
- A lot of things... I Can't remember all
Modified: tags/0.0.3/pychord.py
===================================================================
--- tags/0.0.3/pychord.py 2008-03-11 20:35:18 UTC (rev 54)
+++ tags/0.0.3/pychord.py 2008-03-15 00:15:15 UTC (rev 55)
@@ -89,7 +89,7 @@
if not os.path.isfile(file):
f = open (file, 'w')
- f.write('db='+ os.path.join( home, '.pychord.db' )+'\n')
+ f.write('db='+ os.path.join( home, 'pychord.db' )+'\n')
f.write('datadir='+ os.path.join( home, 'pychord', 'data' ))
# if directory don't exist
if not os.path.isdir(os.path.join( home, 'pychord', 'data' )):
Modified: trunk/pgui/window.py
===================================================================
--- trunk/pgui/window.py 2008-03-11 20:35:18 UTC (rev 54)
+++ trunk/pgui/window.py 2008-03-15 00:15:15 UTC (rev 55)
@@ -18,6 +18,7 @@
# SuperClass initialization
container.__init__(self, father, elementList, position, size)
+
# MainLoop ON
self.loop = True
@@ -31,6 +32,8 @@
self.mousePressed = False
+
+ self.setBackground((0,0,0))
def event_handler(self):
Modified: trunk/pychord2/main_window.py
===================================================================
--- trunk/pychord2/main_window.py 2008-03-11 20:35:18 UTC (rev 54)
+++ trunk/pychord2/main_window.py 2008-03-15 00:15:15 UTC (rev 55)
@@ -40,13 +40,15 @@
self.addElement(btS)
def search(self):
- print self.comboBox.selected
- window = window_searching(self.screen, self.comboBox.value, self.sbox.text, self.pyc )
+ from window_search import window_search
+ window = window_search(self.screen, self.comboBox.selected, self.sbox.text, self.pyc )
window.show()
+ del window
+ self.repaint()
def ShowInfo(self):
from window_info import window_info
window = window_info(self.screen, self.pyc)
window.show()
- self.dirty = True
+ self.repaint()
\ No newline at end of file
Modified: trunk/pychord2/pysql.py
===================================================================
--- trunk/pychord2/pysql.py 2008-03-11 20:35:18 UTC (rev 54)
+++ trunk/pychord2/pysql.py 2008-03-15 00:15:15 UTC (rev 55)
@@ -46,17 +46,33 @@
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()
+
+ artist,name,tab = self.getMusicOldFormat(file)
+ cont = (artist,name,tab,)
cur = self.connection.cursor()
- sql = 'INSERT INTO tabs ( id, artist, song, tab) VALUES (null, %s, %s, %s)'
- cur.execute(sql,(artist,name,tab))
+ sql = 'INSERT INTO tabs ( id, artist, song, tab) VALUES (null, ?, ?, ?)'
+ cur.execute(sql,cont)
self.connection.commit()
+ def getMusicOldFormat(self, filename):
+ f = open(filename)
+ headers = 0
+
+ while headers < 2:
+ headers += 1
+ info = f.readline().strip()
+ info = info.split(":")
+ if info[0].lower() == "artist":
+ artist = info[1]
+ if info[0].lower() == "name":
+ music = info[1]
+
+ tab = f.read()
+ f.close()
+
+ return artist, music, tab
+
def create(self):
import os
os.unlink(self.dbFileName)
@@ -74,6 +90,6 @@
def get (self, id):
cur = self.connection.cursor()
- sql = 'select tab from tabs where id=%s LIMIT 10'
+ sql = 'select tab from tabs where id=%s LIMIT 1'
cur.execute(sql,(id))
return cur.fetchall()
\ No newline at end of file
Modified: trunk/pychord2/window_info.py
===================================================================
--- trunk/pychord2/window_info.py 2008-03-11 20:35:18 UTC (rev 54)
+++ trunk/pychord2/window_info.py 2008-03-15 00:15:15 UTC (rev 55)
@@ -92,7 +92,7 @@
from pysql import pysql
p = pysql(self.pyc.opt['db'],self.pyc.opt['datadir'])
#if self.cmbopt.value == 'replace':
- # p.create()
+ p.create()
uplabel = label(self,[300,200],"Updating", ptsize = 40, bgcolor = (255,0,0))
uplabel.draw(self.screen)
Modified: trunk/pychord2/window_search.py
===================================================================
--- trunk/pychord2/window_search.py 2008-03-11 20:35:18 UTC (rev 54)
+++ trunk/pychord2/window_search.py 2008-03-15 00:15:15 UTC (rev 55)
@@ -1,49 +1,54 @@
from pgui import window
from pgui import label
from pgui import input
+from pgui import Ibutton
from pysql import *
+import pygame
-
class window_search( window ):
def __init__(self, screen, sby, keyw, pyc):
+ # creating window
+ window.__init__(self, None, screen )
+
# Put something in the screen
# while sqlite search by the keyword
# When it finish, clean the event list
- lbls = label([250,250],"Searching...", ptsize=60, bgcolor = (0,0,255))
+ lbls = label(self, [250,250],"Searching...", 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(sby,keyw)
# clear event list
pygame.event.clear()
+
+ btX = Ibutton(self,[730,10],"x.png")
+ btX.registerClickSlot(self.close)
+ self.addElement(btX)
- btX = BbuttonI([730,10],"x.png")
- lblSearch = pywilabel([10,10],"Searching", 40)
-
- pywiwindow.__init__(self, screen, [ btX, lblSearch] )
+ lblSearch = label(self, [10,10],"Searching", ptsize = 40)
+ self.addElement(lblSearch)
+
+
i = 0
for l in res:
- j = pywilabel([20, 80 + 50*i],l[2] + ' by ' + l[1] + '.',25)
- j.click = self.lbl_onclick
+ j = label(self, [20, 80 + 50*i],l[2] + ' by ' + l[1] + '.',ptsize = 25)
j.value = l[0]
- self.labels.append(j)
- self.addobj(j)
+ self.addElement(j)
i += 1
# If there ae no results
if i == 0:
noresult = pywilabel([20, 200],'No result found',35)
- self.addobj(noresult)
+ self.addElement(noresult)
- btX.click = self.btX_onClick
-
\ No newline at end of file
More information about the Pychord-commits
mailing list