[gcompris] music activities, textButton now requires rootitem
- From: Bruno Coudoin <bcoudoin src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gcompris] music activities, textButton now requires rootitem
- Date: Tue, 11 Sep 2012 21:06:31 +0000 (UTC)
commit 425f2facc4a247eb2c1a4c36c8821d13abe26256
Author: Bruno Coudoin <bruno coudoin free fr>
Date: Tue Sep 11 20:03:38 2012 +0200
music activities, textButton now requires rootitem
It is better to pass a rootitem instead of relying on the
caller to have a self.rootitem defined.
src/note_names-activity/note_names.py | 6 ++++--
src/piano_composition-activity/gcomprismusic.py | 8 ++++----
.../piano_composition.py | 17 +++++++++++------
src/play_piano-activity/play_piano.py | 3 ++-
4 files changed, 21 insertions(+), 13 deletions(-)
---
diff --git a/src/note_names-activity/note_names.py b/src/note_names-activity/note_names.py
index 510207c..0052728 100644
--- a/src/note_names-activity/note_names.py
+++ b/src/note_names-activity/note_names.py
@@ -138,7 +138,8 @@ They also form the C Major Scale. Notice that the note positions are different t
alignment=pango.ALIGN_CENTER
)
- self.playScaleButton = textButton(400, 136, _("Play Scale"), self, 'teal')
+ self.playScaleButton = textButton(400, 136, _("Play Scale"),
+ self.rootitem, 'teal')
self.playScaleButton.connect("button_press_event", self.staff.playComposition)
gcompris.utils.item_focus_init(self.playScaleButton, None)
@@ -148,7 +149,8 @@ They also form the C Major Scale. Notice that the note positions are different t
elif level == 5:
text = _("Play Bass Clef Game")
if level in [1, 5]:
- self.playScaleGameButton = textButton(400, 410, text, self, 'green')
+ self.playScaleGameButton = textButton(400, 410, text,
+ self.rootitem, 'green')
self.playScaleGameButton.connect("button_press_event", self.play_scale_game)
gcompris.utils.item_focus_init(self.playScaleGameButton, None)
diff --git a/src/piano_composition-activity/gcomprismusic.py b/src/piano_composition-activity/gcomprismusic.py
index 750d0af..125039c 100644
--- a/src/piano_composition-activity/gcomprismusic.py
+++ b/src/piano_composition-activity/gcomprismusic.py
@@ -1249,13 +1249,13 @@ class PianoKeyboard():
#
# ---------------------------------------------------------------------------
-def textButton(x, y, text, self, color='gray', width=100000, includeText=False):
+def textButton(x, y, text, rootitem, color='gray', width=100000, includeText=False):
'''
Add a text button to the screen with the following parameters:
1. x: the x position of the button
2. y: the y position of the button
3. text: the text of the button
- 4. self: the self object this button is to be written to (just pass 'self')
+ 4. rootitem: the item to draw the button in
5. color: the color of button you'd like to use. Unfortunately there
are limited button colors available. I am not a designer, so you are welcome
to improve this method, but the current colors available are listed below in the examples
@@ -1270,7 +1270,7 @@ def textButton(x, y, text, self, color='gray', width=100000, includeText=False):
textButton(500, 400, 'Zdravstvuyte', self, color='teal', width=70)
'''
textbox = goocanvas.Text(
- parent=self.rootitem,
+ parent = rootitem,
x=x, y=y,
width=width,
text=text,
@@ -1282,7 +1282,7 @@ def textButton(x, y, text, self, color='gray', width=100000, includeText=False):
bounds = textbox.get_bounds()
img = goocanvas.Image(
- parent=self.rootitem,
+ parent = rootitem,
x=bounds.x1 - TG,
y=bounds.y1 - TG,
height=bounds.y2 - bounds.y1 + TG * 2,
diff --git a/src/piano_composition-activity/piano_composition.py b/src/piano_composition-activity/piano_composition.py
index b02647b..f594043 100644
--- a/src/piano_composition-activity/piano_composition.py
+++ b/src/piano_composition-activity/piano_composition.py
@@ -139,15 +139,19 @@ class Gcompris_piano_composition:
# ADD BUTTONS
- self.eraseAllButton = textButton(100, 70, _("Erase All Notes"), self, 'purple', 80)
+ self.eraseAllButton = textButton(100, 70, _("Erase All Notes"),
+ self.rootitem, 'purple', 80)
- self.eraseNotesButton = textButton(220, 70, _("Erase Last Note"), self, 'teal', 100)
+ self.eraseNotesButton = textButton(220, 70, _("Erase Last Note"),
+ self.rootitem, 'teal', 100)
- self.playCompositionButton = textButton(350, 70, _("Play Composition"), self, 'green', 100)
+ self.playCompositionButton = textButton(350, 70, _("Play Composition"),
+ self.rootitem, 'green', 100)
if (level > 2):
- self.changeClefButton = textButton(100, 140, _("Erase and Change Clef"), self, 'gray', 100)
+ self.changeClefButton = textButton(100, 140, _("Erase and Change Clef"),
+ self.rootitem, 'gray', 100)
if (level >= 3):
goocanvas.Text(
@@ -236,7 +240,8 @@ class Gcompris_piano_composition:
)
self.makeSharpButton.props.visibility = goocanvas.ITEM_INVISIBLE
- self.loadSongsButton = textButton(280, 430, _("Load Music"), self, 'red', 100)
+ self.loadSongsButton = textButton(280, 430, _("Load Music"),
+ self.rootitem, 'red', 100)
textBox(_("Change Accidental Style:"), 100, 430, self.rootitem, width=150, noRect=True)
if (level == 7):
@@ -364,7 +369,7 @@ dialogue to\nenable the sound."), stop_board)
txt = _("Next Page")
else:
txt = _("Previous Page")
- self.nextMelodiesButton = textButton(700,475,txt, self)
+ self.nextMelodiesButton = textButton(700,475,txt, self.rootitem)
self.nextMelodiesButton.connect("button_press_event", self.nextMelodyPage)
gcompris.utils.item_focus_init(self.nextMelodiesButton, None)
diff --git a/src/play_piano-activity/play_piano.py b/src/play_piano-activity/play_piano.py
index a484e84..2d79d7b 100644
--- a/src/play_piano-activity/play_piano.py
+++ b/src/play_piano-activity/play_piano.py
@@ -92,7 +92,8 @@ class Gcompris_play_piano:
self.staff.endx = 200
if level not in [6, 12]:
- self.colorCodeNotesButton = textButton(100, 215, _("Color code notes?"), self, 'green')
+ self.colorCodeNotesButton = textButton(100, 215, _("Color code notes?"),
+ self.rootitem, 'green')
self.colorCodeNotesButton.connect("button_press_event", self.color_code_notes)
gcompris.utils.item_focus_init(self.colorCodeNotesButton, None)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]