[gcompris] music activities, changed textBox API
- From: Bruno Coudoin <bcoudoin src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gcompris] music activities, changed textBox API
- Date: Mon, 10 Sep 2012 20:44:34 +0000 (UTC)
commit f9f9f9fe0926ef1507c78b5d5b297c2ae3df3422
Author: Bruno Coudoin <bruno coudoin free fr>
Date: Mon Sep 10 21:46:25 2012 +0200
music activities, changed textBox API
We no more expect the caller to have a self.rootitem variable.
src/piano_composition-activity/gcomprismusic.py | 30 ++++++++++---------
.../piano_composition.py | 6 ++--
src/play_piano-activity/play_piano.py | 3 +-
src/play_rhythm-activity/play_rhythm.py | 12 +++++--
4 files changed, 29 insertions(+), 22 deletions(-)
---
diff --git a/src/piano_composition-activity/gcomprismusic.py b/src/piano_composition-activity/gcomprismusic.py
index 4e5a2f7..8054439 100644
--- a/src/piano_composition-activity/gcomprismusic.py
+++ b/src/piano_composition-activity/gcomprismusic.py
@@ -1297,14 +1297,16 @@ def textButton(x, y, text, self, color='gray', width=100000, includeText=False):
else:
return img
-def textBox(text, x, y , self, width=10000, fill_color=None, stroke_color=None, noRect=False, text_color="black"):
+def textBox(text, x, y , rootitem, width=10000,
+ fill_color=None, stroke_color=None,
+ noRect=False, text_color="black"):
'''
write a textbox with text to the screen. By default the text is surrounded with a rectangle.
Customize with the following parameters:
text: the text to write
x: the x position of the text
y: the y position of the text
- self: the self object this text is to be written to (just pass 'self')
+ rootitem: the rootitem do draw the textBox in
width: the width limit of the text
fill_color: the color to fill the rectangle
stroke_color: the color to make the rectangle lines
@@ -1313,16 +1315,16 @@ def textBox(text, x, y , self, width=10000, fill_color=None, stroke_color=None,
accepted colors include string html color tags or english names
- textBox('Hello World!', 200, 300, self)
- textBox('Hola', 350, 300, self, fill_color='green')
- textBox('Ciao', 500, 300, self, stroke_color='pink')
- textBox('Bonjour', 650, 300, self, noRect=True)
- textBox('Nei Ho', 350, 400, self, text_color='red')
- textBox('Guten Tag', 200, 400, self, width=10)
- textBox('Zdravstvuyte', 500, 400, self, fill_color='#FF00FF')
+ textBox('Hello World!', 200, 300, rootitem)
+ textBox('Hola', 350, 300, rootitem, fill_color='green')
+ textBox('Ciao', 500, 300, rootitem, stroke_color='pink')
+ textBox('Bonjour', 650, 300, rootitem, noRect=True)
+ textBox('Nei Ho', 350, 400, rootitem, text_color='red')
+ textBox('Guten Tag', 200, 400, rootitem, width=10)
+ textBox('Zdravstvuyte', 500, 400, rootitem, fill_color='#FF00FF')
'''
text = goocanvas.Text(
- parent=self.rootitem, x=x, y=y, width=width,
+ parent = rootitem, x=x, y=y, width=width,
text=text,
fill_color=text_color, anchor=gtk.ANCHOR_CENTER,
alignment=pango.ALIGN_CENTER,
@@ -1331,7 +1333,7 @@ def textBox(text, x, y , self, width=10000, fill_color=None, stroke_color=None,
TG = 10
bounds = text.get_bounds()
if not noRect:
- rect = goocanvas.Rect(parent=self.rootitem,
+ rect = goocanvas.Rect(parent = rootitem,
x=bounds.x1 - TG,
y=bounds.y1 - TG,
width=bounds.x2 - bounds.x1 + TG * 2,
@@ -1441,9 +1443,9 @@ def drawBasicPlayHomePagePart1(self):
if hasattr(self, 'staff'):
self.staff.clear()
- self.playText, self.playRect = textBox(_('Play'), 220, 30, self, fill_color='gray')
+ self.playText, self.playRect = textBox(_('Play'), 220, 30, self.rootitem, fill_color='gray')
- self.okText, self.okRect = textBox(_('Okay'), 550, 30, self, fill_color='gray')
+ self.okText, self.okRect = textBox(_('Okay'), 550, 30, self.rootitem, fill_color='gray')
# ---------------------
# NOT DOCUMENTED ONLINE
@@ -1476,7 +1478,7 @@ def drawBasicPlayHomePagePart2(self):
gcompris.utils.item_focus_init(self.okButton, None)
# ERASE BUTTON
- self.eraseText, self.eraseRect = textBox(_("Erase Attempt"), 700, 150, self, fill_color='gray')
+ self.eraseText, self.eraseRect = textBox(_("Erase Attempt"), 700, 150, self.rootitem, fill_color='gray')
self.eraseButton = goocanvas.Image(
parent=self.rootitem,
diff --git a/src/piano_composition-activity/piano_composition.py b/src/piano_composition-activity/piano_composition.py
index e14ea22..78e3ef3 100644
--- a/src/piano_composition-activity/piano_composition.py
+++ b/src/piano_composition-activity/piano_composition.py
@@ -129,11 +129,11 @@ class Gcompris_piano_composition:
# CLEF DESCRIPTION
if clefDescription:
- textBox(clefText, 550, 67, self, 240, stroke_color='purple')
+ textBox(clefText, 550, 67, self.rootitem, 240, stroke_color='purple')
# KEYBOARD DESCRIPTION
if keyboardDescription:
- textBox(keyboardText, 200, 430, self, 225, stroke_color='purple')
+ textBox(keyboardText, 200, 430, self.rootitem, 225, stroke_color='purple')
# ADD BUTTONS
@@ -235,7 +235,7 @@ class Gcompris_piano_composition:
self.makeSharpButton.props.visibility = goocanvas.ITEM_INVISIBLE
self.loadSongsButton = textButton(280, 430, _("Load Music"), self, 'red', 100)
- textBox(_("Change Accidental Style:"), 100, 430, self, width=150, noRect=True)
+ textBox(_("Change Accidental Style:"), 100, 430, self.rootitem, width=150, noRect=True)
if (level == 7):
self.loadButton = goocanvas.Image(
diff --git a/src/play_piano-activity/play_piano.py b/src/play_piano-activity/play_piano.py
index aaada81..89fbf54 100644
--- a/src/play_piano-activity/play_piano.py
+++ b/src/play_piano-activity/play_piano.py
@@ -111,7 +111,8 @@ class Gcompris_play_piano:
self.piano.draw(300, 175, self.keyboard_click)
- textBox(_("Click the piano keys that match the written notes."), 388, 60, self, fill_color='gray', width=200)
+ textBox(_("Click the piano keys that match the written notes."),
+ 388, 60, self.rootitem, fill_color='gray', width=200)
drawBasicPlayHomePagePart2(self)
diff --git a/src/play_rhythm-activity/play_rhythm.py b/src/play_rhythm-activity/play_rhythm.py
index 7366b5b..dd49312 100644
--- a/src/play_rhythm-activity/play_rhythm.py
+++ b/src/play_rhythm-activity/play_rhythm.py
@@ -82,7 +82,7 @@ class Gcompris_play_rhythm:
x=200, y=160, width=400, height=30,
stroke_color="black", fill_color='white',
line_width=3.0)
- textBox(_("Beat Count:"), 260, 175, self, noRect=True)
+ textBox(_("Beat Count:"), 260, 175, self.rootitem, noRect=True)
gcompris.bar_set(gcompris.BAR_LEVEL)
gcompris.bar_set_level(self.gcomprisBoard)
gcompris.bar_location(20, -1, 0.6)
@@ -100,7 +100,8 @@ class Gcompris_play_rhythm:
self.givenOption = []
- self.drumText, self.drumRect = textBox(_('Drum'), 390, 30, self, fill_color='gray')
+ self.drumText, self.drumRect = \
+ textBox(_('Drum'), 390, 30, self.rootitem, fill_color='gray')
# RECORD BUTTON
self.drum = goocanvas.Image(
@@ -113,7 +114,9 @@ class Gcompris_play_rhythm:
gcompris.utils.item_focus_init(self.drum, None)
- self.metronomeText, self.metronomeRect = textBox(_('For a little help, click the metronome to hear the tempo'), 90, 100, self, fill_color='gray', width=150)
+ self.metronomeText, self.metronomeRect = \
+ textBox( _('For a little help, click the metronome to hear the tempo'),
+ 90, 100, self.rootitem, fill_color='gray', width=150 )
# METRONOME BUTTON
self.metronomeButton = goocanvas.Image(
parent=self.rootitem,
@@ -311,7 +314,8 @@ class Gcompris_play_rhythm:
if hasattr(self, 'text'):
self.text.remove()
self.rect.remove()
- self.text, self.rect = textBox(text, 400, 400, self, fill_color='gray', width=200)
+ self.text, self.rect = \
+ textBox(text, 400, 400, self.rootitem, fill_color='gray', width=200)
def convert(self, visible):
if visible:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]