[Pychord-commits] r44 - in trunk: pgui pychord2

danilo at garage.maemo.org danilo at garage.maemo.org
Wed Mar 5 04:48:24 EET 2008


Author: danilo
Date: 2008-03-05 04:48:22 +0200 (Wed, 05 Mar 2008)
New Revision: 44

Modified:
   trunk/pgui/button.py
   trunk/pgui/combo.py
   trunk/pgui/locale.py
   trunk/pgui/pguiobject.py
   trunk/pgui/widget.py
   trunk/pychord2/main_window.py
Log:
- Position move fixed
- Adding a Aling flag (default is centered)

Modified: trunk/pgui/button.py
===================================================================
--- trunk/pgui/button.py	2008-03-05 01:49:49 UTC (rev 43)
+++ trunk/pgui/button.py	2008-03-05 02:48:22 UTC (rev 44)
@@ -25,7 +25,7 @@
     
     def __init__(self, father, position, text = '', ptsize = pguiDefFontSize, width = None,
                  height = None, color=(0,0,0), bgcolor=(200,200,200),
-                 bsize = 1, padding = 2):
+                 bsize = 1, padding = 2, align = pguiAlignCenter):
         
         self.text = text
         self.bsize = bsize
@@ -36,9 +36,10 @@
         self.bgcolor = bgcolor
         
         # creating the label
-        lbl = label(self, [2,5], text, color, ptsize = ptsize)
+        
+        lbl = label(self, [padding+bsize,padding+bsize], text, color, ptsize = ptsize)
         self.label = lbl
-        
+                
         # Y_size
         if height == None:
             height = self.label.size[1] + bsize*2 + padding*2
@@ -47,6 +48,15 @@
         if width == None:
             width = self.label.size[0] + bsize*2 + padding*2
         
+        if align == pguiAlignCenter:
+            print self.label.size
+            print width, height
+            print bsize,padding
+            desX = (width - self.label.size[0]  - bsize*2 -padding*2)/2 
+            desY = (height - self.label.size[1] - bsize*2 -padding*2)/2 
+            print [desX,desY]
+            self.label.move([desX,desY])
+        
         # creating the box
         self.box = box(self,[0,0],(width,height),bgcolor,bsize,(150,150,150))
         

Modified: trunk/pgui/combo.py
===================================================================
--- trunk/pgui/combo.py	2008-03-05 01:49:49 UTC (rev 43)
+++ trunk/pgui/combo.py	2008-03-05 02:48:22 UTC (rev 44)
@@ -52,7 +52,7 @@
     
     def __init__(self, father, screen, options, selected, position, hOffset, width):
         
-        size = [width, len(options)*30+20]
+        size = [width, len(options)*pguiDefFontSize+20]
         position = [position[0],position[1]+hOffset]
 
         window.__init__(self, father, screen, [], position, size)

Modified: trunk/pgui/locale.py
===================================================================
--- trunk/pgui/locale.py	2008-03-05 01:49:49 UTC (rev 43)
+++ trunk/pgui/locale.py	2008-03-05 02:48:22 UTC (rev 44)
@@ -6,6 +6,12 @@
 pguiImageString = 2
 pguiImage = 3
 
+# Align Flags
+pguiAlignCenter = 1 # Default Align position
 
+
+
 #THEME OPTIONS
 pguiDefFontSize = 40 # Default FontSize
+
+

Modified: trunk/pgui/pguiobject.py
===================================================================
--- trunk/pgui/pguiobject.py	2008-03-05 01:49:49 UTC (rev 43)
+++ trunk/pgui/pguiobject.py	2008-03-05 02:48:22 UTC (rev 44)
@@ -107,9 +107,12 @@
     
     def click(self):
         for functionName,vars in self.onClickSlots:
-            functionName(vars)
+            if vars != None:
+                functionName(vars)
+            else:
+                functionName()
     
-    def registerClickSlot(self, functionName, vars = []):
+    def registerClickSlot(self, functionName, vars = None):
         self.onClickSlots.append([functionName,vars])
     
     def setPositionByRelative(self, position = [0,0]):

Modified: trunk/pgui/widget.py
===================================================================
--- trunk/pgui/widget.py	2008-03-05 01:49:49 UTC (rev 43)
+++ trunk/pgui/widget.py	2008-03-05 02:48:22 UTC (rev 44)
@@ -42,6 +42,7 @@
     def move(self, pos):
         if pos[0] != pos[1] or pos[1] != 0:
             self.position = (self.position[0] + pos[0], self.position[1] + pos[1])
+            self.rel_pos = (self.rel_pos[0] + pos[0], self.rel_pos[1] + pos[1])
             self.rect  =  Rect(self.position,self.img.get_size())
             self.father.dirty = True
             

Modified: trunk/pychord2/main_window.py
===================================================================
--- trunk/pychord2/main_window.py	2008-03-05 01:49:49 UTC (rev 43)
+++ trunk/pychord2/main_window.py	2008-03-05 02:48:22 UTC (rev 44)
@@ -16,36 +16,16 @@
 
 class main_window( window ):
     
-    # Another stuff
-    clicking = False
-    fps = 15
     
     def __init__(self, screen, pyc):
         
         self.pyc = pyc
-        
-        """
-        btX = pywibuttonI([730,10],"x.png")
-        btI = pywibuttonI([730,100],"i.png")
-        lblSearch = pywilabel([20,30],"Search", 50)
-        
-        #search box
-        boxSearch = pywiinput([20,80], [650,50],"")
-        self.sbox = boxSearch 
-        
-        #Combo Box
-        combo = pywicombo([20, 160],[450,50],{'tab':'By Word','artist':'By Artist','song':'By Music'})
-        combo.value = "tab"
-        self.combo = combo
-        
-        btS = pywibuttonI([537,160],"search.png")
-
-        """
+      
         window.__init__(self, None, screen )
         self.setBackground((0,0,0))
         
         btX = Ibutton(self,[730,10],"x.png")
-        btX.click = self.close
+        btX.registerClickSlot(self.close)
         self.addElement(btX)
         
         lbl = label(self, [10,70],"Search By:")
@@ -53,10 +33,12 @@
         
         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)



More information about the Pychord-commits mailing list