[Pychord-commits] r36 - in trunk: . pgui

danilo at garage.maemo.org danilo at garage.maemo.org
Sun Mar 2 04:49:42 EET 2008


Author: danilo
Date: 2008-03-02 04:49:23 +0200 (Sun, 02 Mar 2008)
New Revision: 36

Added:
   trunk/pgui/
   trunk/pgui/__init__.py
   trunk/pgui/background.py
   trunk/pgui/container.py
   trunk/pgui/pguiobject.py
   trunk/pgui/widget.py
Removed:
   trunk/pgui/__init__.py
   trunk/pgui/pyw_box.py
   trunk/pgui/pyw_button.py
   trunk/pgui/pyw_combo.py
   trunk/pgui/pyw_combo_options.py
   trunk/pgui/pyw_input.py
   trunk/pgui/pyw_label.py
   trunk/pgui/pyw_list.py
   trunk/pgui/pyw_object.py
   trunk/pgui/pyw_widget.py
   trunk/pgui/pyw_window.py
   trunk/pgui/pyw_window_dialog.py
Log:
Changing the name of the library

Copied: trunk/pgui (from rev 34, trunk/pyw)

Deleted: trunk/pgui/__init__.py
===================================================================
--- trunk/pyw/__init__.py	2008-03-02 01:16:07 UTC (rev 34)
+++ trunk/pgui/__init__.py	2008-03-02 02:49:23 UTC (rev 36)
@@ -1,12 +0,0 @@
-from pyw_widget import *
-from pyw_window import *
-from pyw_window_dialog import *
-from pyw_button import *
-from pyw_label import *
-from pyw_input import *
-from pyw_box import *
-
-class pyw_defines:
-        
-    MAX_X = 800
-    MAX_Y = 420
\ No newline at end of file

Copied: trunk/pgui/__init__.py (from rev 35, trunk/pyw/__init__.py)
===================================================================
--- trunk/pgui/__init__.py	                        (rev 0)
+++ trunk/pgui/__init__.py	2008-03-02 02:49:23 UTC (rev 36)
@@ -0,0 +1,7 @@
+import widget
+
+
+class pyw_defines:
+        
+    MAX_X = 800
+    MAX_Y = 420
\ No newline at end of file

Copied: trunk/pgui/background.py (from rev 35, trunk/pyw/background.py)
===================================================================
--- trunk/pgui/background.py	                        (rev 0)
+++ trunk/pgui/background.py	2008-03-02 02:49:23 UTC (rev 36)
@@ -0,0 +1,23 @@
+# -*- coding: utf-8 -*-
+
+from pgui import widget
+
+import pygame
+from pygame.locals import *
+
+
+class background (widget):
+    
+    # All widgets needs to know: father, position and size.
+    # background needs to know too the color, the bordersize and
+    # the background color
+    def __init__(self, father, size, color, bsize = 0, bcolor = (200,200,200)):
+        
+        img = pygame.Surface(size)
+        if bsize > 0:
+            img.fill(bcolor)
+        
+        pygame.draw.rect(img, color, Rect(bsize, bsize, size[0]-2*bsize, size[1]-2*bsize))
+        
+        # Creating a new widget
+        pyw_widget.__init__(self, father, position, size, img)

Copied: trunk/pgui/container.py (from rev 35, trunk/pyw/container.py)
===================================================================
--- trunk/pgui/container.py	                        (rev 0)
+++ trunk/pgui/container.py	2008-03-02 02:49:23 UTC (rev 36)
@@ -0,0 +1,49 @@
+# -*- coding: utf-8 -*-
+
+from pygame import Surface
+from pygame.locals import *
+
+
+class container (pguiobject):
+    
+    def __init__(self, father, objlst = [], position = [0,0], size = [800,420] ):
+
+        pguiobject.__init__()
+        self.objects = []
+        self.elements_reverted = []
+
+        
+        
+    def addElement(self, obj):
+        self.elements.append(obj)
+        self.elements_reverted.insert(0,obj)
+        
+        
+    def delElement(self, obj):
+        self.elements.remove(obj)
+        self.elements_reverted.remove(obj)
+        
+    def draw(self, screen):
+        """
+            Simple draw of the screen
+            and draw the elements
+        """
+
+        if self.dirty:
+            # if we paint the window
+            # we need to pain all the widgets of this window too 
+            self.draw(self.screen)
+            self.dirty = False
+            
+            for obj in self.elements:
+                    obj.draw(self.screen)
+                    
+
+        else:
+            # If window is not dirty, we need to
+            # paint only dirtys widgets
+            for obj in self.elements:
+                if obj.dirty:
+                    obj.draw(self.screen)
+                    
+        pygame.display.flip()
\ No newline at end of file

Copied: trunk/pgui/pguiobject.py (from rev 35, trunk/pyw/pguiobject.py)
===================================================================
--- trunk/pgui/pguiobject.py	                        (rev 0)
+++ trunk/pgui/pguiobject.py	2008-03-02 02:49:23 UTC (rev 36)
@@ -0,0 +1,18 @@
+# -*- coding: utf-8 -*-
+
+from pygame import Surface
+from pygame.locals import *
+
+
+class pguiobject ():
+    
+    """
+     Classe de todos os elemento grafico
+
+    :version: 2.0
+    :author:
+    """
+    def __init__(self):
+        self.dirty = True
+        
+        
\ No newline at end of file

Deleted: trunk/pgui/pyw_box.py
===================================================================
--- trunk/pyw/pyw_box.py	2008-03-02 01:16:07 UTC (rev 34)
+++ trunk/pgui/pyw_box.py	2008-03-02 02:49:23 UTC (rev 36)
@@ -1,21 +0,0 @@
-from pyw_widget import *
-
-import pygame
-from pygame.locals import *
-
-
-class pyw_box (pyw_widget):
-    
-    def __init__(self, father, position, size, color, bsize = 0, bcolor = (200,200,200)):
-        
-        img = pygame.Surface(size)
-        if bsize > 0:
-            img.fill(bcolor)
-            
-        pygame.draw.rect(img, color, Rect(bsize, bsize, size[0]-2*bsize, size[1]-2*bsize))
-        
-        # Creating a new widget
-        pyw_widget.__init__(self, father, position, size, img)
-        
-        
-        

Deleted: trunk/pgui/pyw_button.py
===================================================================
--- trunk/pyw/pyw_button.py	2008-03-02 01:16:07 UTC (rev 34)
+++ trunk/pgui/pyw_button.py	2008-03-02 02:49:23 UTC (rev 36)
@@ -1,67 +0,0 @@
-from pyw_widget import *
-from pygame.locals import *
-import pygame
-import os
-
-
-from pyw_box import *
-from pyw_label import *
-
-images_dir = os.path.join( "img" )
-
-
-class pyw_button (pyw_widget):
-
-    def __init__(self, father, relative_position, size, img):
-        # Widget creating
-        pyw_widget.__init__(self, father, relative_position, size, img)
-        
-
-
-class pyw_Tbutton (pyw_button, pyw_box):
-    
-    def __init__(self, father, position, text = '', ptsize = 30, width = None, height = None, color=(200,200,200), textcolor=(0,0,0), bsize = 1, padding = 2):
-        
-        self.text = text
-        self.bsize = bsize
-        self.padding = padding
-        self.position = position
-        
-        
-        # Defining the label, couse the input is a mix of a colorbox and a label 
-        label_position = [position[0] + bsize + padding + 10, position[1] + bsize + padding]
-        print 
-        self.label = pyw_label(self, label_position, text, color = textcolor, bgcolor=color, ptsize = ptsize)
-        
-        # Y_size
-        if height == None:
-            height = self.label.size[1] + bsize*2 + padding*2
-            
-        # X_size
-        if width == None:
-            width = self.label.size[0] + bsize*2 + padding*2
-        
-        # creating the box
-        pyw_box.__init__(self, father, position, [width, height], color, bsize, (120,120,120))
-        
-        #puting the label into the box image
-        self.img.blit(self.label.img, (self.bsize + self.padding, self.bsize + self.padding))
-
-
-class pyw_Ibutton (pyw_button):
-
-    def __init__(self, father, relative_position, image_file):
-        """
-
-        @param string img_local : Endereco da imagem
-        @return  :
-        @author
-        """        
-        
-        path  = os.path.join( images_dir, image_file )
-        img   = pygame.image.load( path )
-        size  = img.get_size()
-        
-        pyw_button.__init__(self, father, relative_position, size, img)
-
-

Deleted: trunk/pgui/pyw_combo.py
===================================================================
--- trunk/pyw/pyw_combo.py	2008-03-02 01:16:07 UTC (rev 34)
+++ trunk/pgui/pyw_combo.py	2008-03-02 02:49:23 UTC (rev 36)
@@ -1,18 +0,0 @@
-from pyw_widget import *
-
-from pyw_window import *
-from pyw_combo_options import *
-
-class pyw_combo (pyw_widget):
-
-    def open(self):
-        """
-         Abrir a aba de elementos
-
-        @return  :
-        @author
-        """
-        pass
-
-    def __init__(self):
-        pass
\ No newline at end of file

Deleted: trunk/pgui/pyw_combo_options.py
===================================================================
--- trunk/pyw/pyw_combo_options.py	2008-03-02 01:16:07 UTC (rev 34)
+++ trunk/pgui/pyw_combo_options.py	2008-03-02 02:49:23 UTC (rev 36)
@@ -1,8 +0,0 @@
-from pyw_window import *
-
-
-class pyw_combo_options (pyw_window):
-
-    pass
-
-

Deleted: trunk/pgui/pyw_input.py
===================================================================
--- trunk/pyw/pyw_input.py	2008-03-02 01:16:07 UTC (rev 34)
+++ trunk/pgui/pyw_input.py	2008-03-02 02:49:23 UTC (rev 36)
@@ -1,55 +0,0 @@
-from pyw_box import *
-from pyw_label import *
-
-class pyw_input (pyw_box):
-
-
-    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
-
-        # Defining the label, couse the input is a mix of a colorbox and a label 
-        label_position = [position[0] + bsize, position[1] + bsize]
-        self.label = pyw_label(self, label_position, text, color = (0,0,0), bgcolor=(255,255,255), ptsize = ptsize)
-        
-        # Y_size
-        if height == None:
-            height = self.label.size[1] + bsize*2
-     
-        # creating the box
-        pyw_box.__init__(self, father, position, [width, height], (255,255,255), bsize, (120,120,120))
-        
-        #puting the label into the box image
-        self.img.blit(self.label.img, (self.bsize, self.bsize))
-        pass
-    
-    def click(self):
-        
-        import virtkeyboard
-        mykb = virtkeyboard.VirtualKeyboard()
-        text = mykb.run(self.father.screen, self.text)
-        
-        self.modify(text) 
-        self.dirty = True
-    
-    def modify(self, text):
-        """
-            This function modifies the text of a input
-        """
-        self.label.modify(text)
-        pyw_box.__init__(self, self.father, self.position, self.size, (255,255,255), self.bsize, (120,120,120) )
-        self.img.blit(self.label.img, (self.bsize, self.bsize))
-        
-        
-        
-    
\ No newline at end of file

Deleted: trunk/pgui/pyw_label.py
===================================================================
--- trunk/pyw/pyw_label.py	2008-03-02 01:16:07 UTC (rev 34)
+++ trunk/pgui/pyw_label.py	2008-03-02 02:49:23 UTC (rev 36)
@@ -1,32 +0,0 @@
-from pyw_widget import *
-from pygame.locals import *
-import pygame
-
-
-
-class pyw_label (pyw_widget):
-
-    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 )
-        
-        if bgcolor != None:
-            img  = self.font.render( self.text, True, self.color, bgcolor )
-        else:
-            img  = self.font.render( self.text, True, self.color)
-        size = img.get_size()
-        pyw_widget.__init__(self, father, position, size, img)
-        
-        
-        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

Deleted: trunk/pgui/pyw_list.py
===================================================================
--- trunk/pyw/pyw_list.py	2008-03-02 01:16:07 UTC (rev 34)
+++ trunk/pgui/pyw_list.py	2008-03-02 02:49:23 UTC (rev 36)
@@ -1,7 +0,0 @@
-from pyw_widget import *
-
-class pyw_list (pyw_widget):
-
-    pass
-
-

Deleted: trunk/pgui/pyw_object.py
===================================================================
--- trunk/pyw/pyw_object.py	2008-03-02 01:16:07 UTC (rev 34)
+++ trunk/pgui/pyw_object.py	2008-03-02 02:49:23 UTC (rev 36)
@@ -1,29 +0,0 @@
-from pygame import Surface
-
-
-class pyw_object(object):
-
-    """
-     Implementacao generica a qual todos os objetos deverao implementar
-
-    :version:
-    :author:
-    """
-
-    def __init__(self):
-        
-        pass
-
-    def update(self):
-        """
-         Metodo para atualizar o estado de um objeto.
-
-        @return  :
-        @author
-        """
-        pass
-    def click(self):
-        pass
-
-
-

Deleted: trunk/pgui/pyw_widget.py
===================================================================
--- trunk/pyw/pyw_widget.py	2008-03-02 01:16:07 UTC (rev 34)
+++ trunk/pgui/pyw_widget.py	2008-03-02 02:49:23 UTC (rev 36)
@@ -1,68 +0,0 @@
-# -*- coding: utf-8 -*-
-
-from pyw_object import *
-from pygame import Surface
-from pygame.locals import *
-
-
-class pyw_widget (pyw_object):
-
-    """
-     Classe de todos os elemento grafico
-
-    :version: 2.0
-    :author:
-    """
-    
-    def __init__(self, father, position = [0,0], size = [0,0], img = None):
-        """
-            Class init
-        """
-        
-        pyw_object.__init__(self)
-        
-        self.father = father # father widget in hiearquy
-        self.rel_pos = position  # Defining relative position
-        self.size = size     # Defining widget size
-        self.dirty = True    # it need to starts dirty,
-                             # to be repainted
-        
-        # Calculating absolute position on screen
-        if self.father != None:                   
-            self.position = (self.father.position[0] + position[0],
-                             self.father.position[1] + position[1]  ) 
-        else:
-            print  self.__class__, self.father
-            self.position = position
-        
-        # Image of this widget
-        # We need to do this verification, because a father widget can
-        # create a image before call widget.__init__
-        if img == None:    
-            img = Surface(size)
-        self.img = img 
-        
-        # Image retangle
-        self.rect  =  Rect(self.position,self.img.get_size())
-        
-    def __del__(self):
-        del(self.rel_pos)
-        del(self.size)
-        del(self.img)
-
-    
-    def draw(self, screen):
-        """
-         Desenha o objeto na tela
-
-        @return  :
-        @author
-        """
-        
-        # Verifing if the image realy need to be painted
-        if self.position[1] < 420 and self.position[1] > 0:
-
-            screen.blit(self.img, self.position)
-        
-        self.dirty = False
-        
\ No newline at end of file

Deleted: trunk/pgui/pyw_window.py
===================================================================
--- trunk/pyw/pyw_window.py	2008-03-02 01:16:07 UTC (rev 34)
+++ trunk/pgui/pyw_window.py	2008-03-02 02:49:23 UTC (rev 36)
@@ -1,167 +0,0 @@
-from pyw_widget import *
-from pyw_button import *
-
-
-import pygame
-from pygame.time   import Clock
-from pygame.locals import *
-
-
-class pyw_window (pyw_widget):
-
-    """
-     Implementacao de janela
-
-    :version:
-    :author:
-    """
-
-    def __init__(self, screen, objlst = [], position = [0,0], size = [800,420] ):
-        
-        # SuperClass initialization
-        pyw_widget.__init__(self, None, position, size)
-        # MainLoop ON
-        self.loop = True
-        
-        self.ret_val = None
-        
-        self.elements = []
-        self.elements_reverted = []
-        
-        self.screen = screen
-        
-        self.draw(screen)
-        
-        self.clock = Clock()
-        
-        self.fps = 20
-        
-        # saving the objects
-        for obj in objlst:
-            self.addobj(obj)
-            #print 'appending'
-        
-        # Adding a "Close" Button
-        btX = pyw_Ibutton(self, [730,10], "x.png")
-        btX.click = self.bt_close
-        self.addobj(btX)
-
-    def addobj(self, obj):
-        """
-            _addobj (self, obj, pos), where obj is the object referer
-        """
-        self.elements.append(obj)
-        self.elements_reverted.insert(0,obj)
-        
-    def rmobj(self, obj):
-        self.elements.remove(obj)
-        self.elements_reverted.remove(obj)
-
-
-    def event_handler(self):
-        """
-         Recebe os eventos do pygame
-
-        @return  :
-        @author
-        """
-        events = pygame.event.get()
-        
-        for e in events:
-            if (e.type == MOUSEBUTTONUP):
-                self.sendclick()
-        
-    def show(self):
-        """
-         Abrir a janela
-
-        @return  :
-        @author
-        """
-        self.dirty = True
-        self.__Loop = True
-        
-        while self.__Loop:
-
-            #updating the elements
-            self.update()
-            
-            self.event_handler()
-            
-            # drawning the elements if necessary
-            self.drawall(self.screen)
-            
-            
-            self.clock.tick(self.fps)
-   
-    
-    def drawall(self, screen):
-        """
-            Simple draw of the screen
-            and draw the elements
-        """
-
-        if self.dirty:
-            # if we paint the window
-            # we need to pain all the widgets of this window too 
-            self.draw(self.screen)
-            self.dirty = False
-            
-            for obj in self.elements:
-                    obj.draw(self.screen)
-                    
-
-        else:
-            # If window is not dirty, we need to
-            # paint only dirtys widgets
-            for obj in self.elements:
-                if obj.dirty:
-                    obj.draw(self.screen)
-                    
-        pygame.display.flip()    
-    
-    def sendclick(self):
-        
-        for obj in self.elements_reverted:
-            if obj.rect.collidepoint(pygame.mouse.get_pos()):
-                obj.click()
-                return
-                
-    
-    def close(self):
-        """
-         Fechar a janela
-
-        @return  :
-        @author
-        """
-        self.stop()
-
-        
-    
-    def bt_close(self):
-        from pyw_window_dialog import *
-        conf = pyw_window_dialog(self.screen, u"Do you really want to quit?")
-        if conf.show():
-            self.close()
-        self.repaint()
-
-    
-    def update(self):
-        
-        for obj in self.elements:
-            obj.update()
-
-    def stop(self):
-        
-        self.dirty = True
-        self.__Loop = False
-        
-        
-    def repaint(self):
-        
-        self.dirty = True
-        self.screen.fill((0,0,0), self.rect)
-
-
-

Deleted: trunk/pgui/pyw_window_dialog.py
===================================================================
--- trunk/pyw/pyw_window_dialog.py	2008-03-02 01:16:07 UTC (rev 34)
+++ trunk/pgui/pyw_window_dialog.py	2008-03-02 02:49:23 UTC (rev 36)
@@ -1,50 +0,0 @@
-from pyw_window import *
-from pyw_label import *
-from pyw_button import *
-from pyw_box import *
-
-class pyw_window_dialog (pyw_window):
-
-    def __init__(self, screen, message, position = [100,80], size = [600,300] ):
-        """
-
-        @param string message : Mensagem para a criação do label
-        @return  :
-        @author
-        
-        """
-        
-        
-        pyw_window.__init__(self, screen, [], position, size)
-        
-        background = pyw_box(self, [0,0], size, (200,200,200), bsize = 1)
-        self.addobj(background)
-        
-        background = pyw_box(self, [1,1], [size[0] -2, 30], (30,30,255))
-        self.addobj(background)
-        title = pyw_label(self, [10,10], "Dialog", color = (0,0,0) )
-        self.addobj(title)
-        
-        label = pyw_label(self, [10,40], message , color = (0,0,0))
-        self.addobj(label)
-        
-        btok = pyw_Tbutton(self, [230,220], "Ok", width = 60, color = (0,255,0), textcolor = (0,0,0), padding = 5)
-        btok.click = self.btok_onclick
-        self.addobj(btok)
-        
-        btfalse = pyw_Tbutton(self, [300,220], "Cancel", color = (255,0,0), textcolor = (0,0,0), padding = 5)
-        btfalse.click = self.btfalse_onclick
-        self.addobj(btfalse)
-      
-    def show(self):
-        pyw_window.show(self)
-        return self.ret_window  
-
-    def btfalse_onclick(self):
-        self.ret_window = False
-        self.close()
-    
-    def btok_onclick(self):
-        self.ret_window = True
-        self.close()
-

Copied: trunk/pgui/widget.py (from rev 35, trunk/pyw/widget.py)
===================================================================
--- trunk/pgui/widget.py	                        (rev 0)
+++ trunk/pgui/widget.py	2008-03-02 02:49:23 UTC (rev 36)
@@ -0,0 +1,61 @@
+# -*- coding: utf-8 -*-
+
+from pygame import Surface
+from pygame.locals import *
+
+
+class widget (pguiobject):
+    
+    """
+     Classe de todos os elemento grafico
+
+    :version: 2.0
+    :author:
+    """
+    def __init__(self, father, position = [0,0], size = [0,0], img = None):
+        
+        pguiobject.__init__()
+        
+        self.father  = father     # father widget in hiearquy
+        self.rel_pos = position   # Defining relative position
+        self.size = size          # Defining widget size
+
+                   
+        # Calculating absolute position on screen
+        if self.father != None:                   
+            self.position = (self.father.position[0] + position[0],
+                             self.father.position[1] + position[1]  ) 
+        else:
+            print  self.__class__, self.father
+            self.position = position
+            
+        # Image of this widget
+        # We need to do this verification, because a father widget can
+        # create a image before call widget.__init__
+        if img == None:    
+            img = Surface(size)
+        self.img = img 
+        
+        # Image's rectangle
+        self.rect  =  Rect(self.position,self.img.get_size())
+        
+    def __del__(self):
+        del(self.rel_pos)
+        del(self.size)
+        del(self.img)
+
+    
+    def draw(self, screen):
+        """
+         Desenha o objeto na tela
+
+        @return  :
+        @author
+        """
+        
+        # Verifing if the image realy need to be painted
+        if self.position[1] < 420 and self.position[1] > 0:
+
+            screen.blit(self.img, self.position)
+        
+        self.dirty = False
\ No newline at end of file



More information about the Pychord-commits mailing list