[Pychord-commits] r13 - trunk/PyChord
danilo at garage.maemo.org
danilo at garage.maemo.org
Fri Sep 28 18:26:49 EEST 2007
Author: danilo
Date: 2007-09-28 18:26:47 +0300 (Fri, 28 Sep 2007)
New Revision: 13
Modified:
trunk/PyChord/Chstrings.py
trunk/PyChord/window_show.py
Log:
Font size change by pressing F7 and F8 buttons
Modified: trunk/PyChord/Chstrings.py
===================================================================
--- trunk/PyChord/Chstrings.py 2007-09-27 21:22:07 UTC (rev 12)
+++ trunk/PyChord/Chstrings.py 2007-09-28 15:26:47 UTC (rev 13)
@@ -24,8 +24,18 @@
def __init__( self, text, pos=None, font=None, ptsize=30,
fgcolor="0xFFFFFF", bgcolor=None ):
+ """
+ This function create a new Chstring.
+ We need to set a lot of attributes like font, position, and
+ some another things
+ Here, we need to know that self.images will not be a image anymore.
+ Here, it is a list, with text images
+ """
+
self.text = text
+ self.ptsize = ptsize
+ self.tfont = font
self.fgcolor = pygame.color.Color( fgcolor )
if bgcolor:
@@ -38,9 +48,54 @@
self.image.append(self.font.render( t[:-1], True, self.fgcolor,self.bgcolor ))
else:
self.image.append(self.font.render( t[:-1], True, self.fgcolor ))
+
# __init__()
-
+ def sizeup(self):
+ """
+ Increase font size by 5 points
+ """
+ self.ptsize += 5
+
+ # Cleaning text images
+ for i in range(1,len(self.image)):
+ self.image.pop()
+
+ # Recreating font object
+ self.font = pygame.font.Font( self.tfont, self.ptsize )
+
+ for t in self.text:
+ if self.bgcolor:
+ self.image.append(self.font.render( t[:-1], True, self.fgcolor,self.bgcolor ))
+ else:
+ self.image.append(self.font.render( t[:-1], True, self.fgcolor ))
+
+ # Setting world dirty = true. Screen need to be repainted
+ self.wdirty = True
+
+ def sizedown(self):
+ """
+ Decrease font size by 5 points
+ """
+ self.ptsize -= 5
+
+ for i in range(1,len(self.image)):
+ self.image.pop()
+
+ self.font = pygame.font.Font( self.tfont, self.ptsize )
+
+ for t in self.text:
+ if self.bgcolor:
+ self.image.append(self.font.render( t[:-1], True, self.fgcolor,self.bgcolor ))
+ else:
+ self.image.append(self.font.render( t[:-1], True, self.fgcolor ))
+
+ self.wdirty = True
+
def update( self):
+ """
+ Object update
+ Here, we need to control speed of the strings
+ """
if self.speedT != 0:
self.speed = self.speedT
@@ -70,6 +125,7 @@
return True
# update()
+ # Draw only images that need to be drawed
def draw( self, screen ):
i = 0
@@ -83,6 +139,7 @@
# draw()
def click(self, screen):
+ # We don't need to control clicks anymore
pass
# Chstrings
Modified: trunk/PyChord/window_show.py
===================================================================
--- trunk/PyChord/window_show.py 2007-09-27 21:22:07 UTC (rev 12)
+++ trunk/PyChord/window_show.py 2007-09-28 15:26:47 UTC (rev 13)
@@ -81,9 +81,16 @@
for event in events:
t = event.type
- if t == QUIT or t == KEYDOWN:
+ if t == QUIT:
self.run = False
-
+
+ # Here we control size of the text
+ if t == KEYDOWN:
+ if event.key == K_F7:
+ self.line.sizeup()
+ if event.key == K_F8:
+ self.line.sizedown()
+
elif t == MOUSEBUTTONDOWN:
self.dirty = True
More information about the Pychord-commits
mailing list