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

danilo at garage.maemo.org danilo at garage.maemo.org
Mon Mar 3 03:09:05 EET 2008


Author: danilo
Date: 2008-03-03 03:09:02 +0200 (Mon, 03 Mar 2008)
New Revision: 40

Added:
   trunk/pgui/input.py
   trunk/pgui/label.py
Modified:
   trunk/pgui/__init__.py
   trunk/pgui/box.py
   trunk/pgui/pguiobject.py
   trunk/pgui/widget.py
   trunk/pychord2/main_window.py
Log:
Input/Label

Modified: trunk/pgui/__init__.py
===================================================================
--- trunk/pgui/__init__.py	2008-03-02 18:05:24 UTC (rev 39)
+++ trunk/pgui/__init__.py	2008-03-03 01:09:02 UTC (rev 40)
@@ -2,5 +2,7 @@
 from window import *
 from pguiobject import *
 from box import *
+from label import *
+from input import *
 
 from locale import *
\ No newline at end of file

Modified: trunk/pgui/box.py
===================================================================
--- trunk/pgui/box.py	2008-03-02 18:05:24 UTC (rev 39)
+++ trunk/pgui/box.py	2008-03-03 01:09:02 UTC (rev 40)
@@ -26,16 +26,17 @@
         
         
         
-    def update(self):
-        
-        if self.clicked:   
-            pos = pygame.mouse.get_rel()
-            self.move(pos)
-            
-    def onClick(self):
-        self.setBackground((0,0,0))
-        widget.onClick(self)
-        
-    def onClickRelease(self):
-        self.setBackground(self.bcolor)
-        widget.onClickRelease(self)
\ No newline at end of file
+#    def update(self):
+#        pass
+#        
+#        if self.clicked:   
+#            pos = pygame.mouse.get_rel()
+#            self.move(pos)
+#            
+#    def onClick(self):
+#        self.setBackground((0,255,0))
+#        widget.onClick(self)
+#        
+#    def onClickRelease(self):
+#        self.setBackground(self.bcolor)
+#        widget.onClickRelease(self)
\ No newline at end of file

Added: trunk/pgui/input.py
===================================================================
--- trunk/pgui/input.py	                        (rev 0)
+++ trunk/pgui/input.py	2008-03-03 01:09:02 UTC (rev 40)
@@ -0,0 +1,56 @@
+from box import *
+from label import *
+from container import *
+
+class input (container):
+
+
+    def __init__(self, father, position, text = '', ptsize = 30, width = 300, height = None, bsize = 1):
+        """
+
+        @param string text : default text
+        @param List pos : Posicao inicial onde o widget vai
+aparecer, relativo a janela
+        @return  :
+        @author
+        """
+        #Saving the text
+        self.text = text
+        self.bsize = bsize
+        self.position = position
+        self.screen = father.screen
+
+        # label
+        lbl = label(self, [2,2], text, (50,50,50))
+        self.label = lbl
+        
+        if height == None:
+            height = lbl.size[1]+10
+        
+        self.input = box(self,[0,0],(width,height),(255,255,255),1,(100,100,100))
+        
+        container.__init__(self, father,[self.input,self.label],position,self.input.size)
+        
+        pass
+    
+    def click(self):
+        
+        import virtkeyboard
+        mykb = virtkeyboard.VirtualKeyboard()
+        text = mykb.run(self.father.screen, self.text)
+        
+        self.modify(text) 
+
+    
+    def modify(self, text):
+        """
+            This function modifies the text of a input
+        """
+        self.text = text
+        self.label.modify(text)
+        self.dirty = True
+        pass
+        
+        
+        
+    
\ No newline at end of file

Added: trunk/pgui/label.py
===================================================================
--- trunk/pgui/label.py	                        (rev 0)
+++ trunk/pgui/label.py	2008-03-03 01:09:02 UTC (rev 40)
@@ -0,0 +1,38 @@
+# -*- coding: utf-8 -*-
+
+from pgui import widget
+
+from pygame import Surface
+from pygame.locals import *
+import pygame
+
+
+class label (widget):
+    
+    """
+     Classe de todos os elemento grafico
+
+    :version: 2.0
+    :author:
+    """
+        
+    def __init__(self, father, position , text, color = (255,255,255),
+              bgcolor = None, fontfile = None, ptsize = 30):
+    
+        self.text = text
+        self.color = color
+        self.bgcolor = bgcolor
+        self.fontfile = fontfile
+        self.ptsize = ptsize
+        self.font = pygame.font.Font( fontfile, ptsize )
+        
+        img  = self.font.render( self.text, True, self.color)
+        size = img.get_size()
+        widget.__init__(self, father, position, size, img)
+        
+        if bgcolor != None:
+            self.setBackground(bgcolor)
+        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

Modified: trunk/pgui/pguiobject.py
===================================================================
--- trunk/pgui/pguiobject.py	2008-03-02 18:05:24 UTC (rev 39)
+++ trunk/pgui/pguiobject.py	2008-03-03 01:09:02 UTC (rev 40)
@@ -36,11 +36,17 @@
         
     def setBackground(self, bg, flag = pguiColor):
         
-        if flag == pguiColor:
+        if bg == None:
+            self.background = None
+            
+        elif flag == pguiColor:
             self.background = Surface(self.size)
             self.background.fill(bg)
-            
-        self.dirty = True
+        
+        if self.father != None:    
+            self.father.dirty = True
+        else:
+            self.dirty = True
     
     
     def draw(self, screen):

Modified: trunk/pgui/widget.py
===================================================================
--- trunk/pgui/widget.py	2008-03-02 18:05:24 UTC (rev 39)
+++ trunk/pgui/widget.py	2008-03-03 01:09:02 UTC (rev 40)
@@ -22,7 +22,7 @@
         # We need to do this verification, because a father widget can
         # create a image before call widget.__init__
         if img == None:    
-            img = Surface(size,pygame.SRCALPHA)
+            img = Surface(size,pygame.SRCALPHA,32)
         self.img = img 
         
         # Image's rectangle

Modified: trunk/pychord2/main_window.py
===================================================================
--- trunk/pychord2/main_window.py	2008-03-02 18:05:24 UTC (rev 39)
+++ trunk/pychord2/main_window.py	2008-03-03 01:09:02 UTC (rev 40)
@@ -1,6 +1,8 @@
 # -*- coding: utf-8 -*-
 from pgui import window
 from pgui import box
+from pgui import label
+from pgui import input
 from pgui import locale
 
 
@@ -39,8 +41,14 @@
         window.__init__(self, None, screen )
         self.setBackground((200,200,200))
         
-        bx = box(self,[8,8],(50,50),(100,100,100),10)
+        bx = box(self,[8,8],(100,90),(100,100,100),10)
         self.addElement(bx)
         
-        #bx = box(self,[50,20],(50,50),(100,100,100),10)
-        #self.addElement(bx)
\ No newline at end of file
+        lbl = label(self, [20,20],"Danilo Cesar",(255,0,0))
+        self.addElement(lbl)
+        
+        inp = input(self, [50,50],"Primeiro INPUT")
+        self.addElement(inp)
+        
+        bx = box(self,[200,8],(150,40),(100,100,100),10)
+        self.addElement(bx)



More information about the Pychord-commits mailing list