diff options
author | jmpc <jumapico@gmail.com> | 2010-03-21 13:30:37 (GMT) |
---|---|---|
committer | jmpc <jumapico@gmail.com> | 2010-03-21 13:30:37 (GMT) |
commit | ad6fb01d0e5ef44ceceea57e04256324023d2637 (patch) | |
tree | 9ed092b70e3e284d7048b2dd2fa7dc44c27cae0a | |
parent | d66a9d3827cd902beac757d2b278e847c1268114 (diff) |
diff --git a/fracciones.activity/fractionlogic.py b/fracciones.activity/fractionlogic.py
index 6c1fcf0..0acc7fe 100644
--- a/fracciones.activity/fractionlogic.py
+++ b/fracciones.activity/fractionlogic.py
@@ -20,7 +20,7 @@ class FractionLogic(object):
if DENOMINATOR_MIN < 1:
raise Exception("DENOMINATOR_MIN need be greather than 0")
self.denominator = random.randrange(DENOMINATOR_MIN, DENOMINATOR_MAX)
- self.numerator = random.randrange(0, self.denominator)
+ self.numerator = random.randrange(0, self.denominator+1)
def get_current(self):
-rw-r--r-- | fracciones.activity/fractionlogic.py | 2 | ||||
-rw-r--r-- | fracciones.activity/fractionpresentation.py | 27 |
2 files changed, 17 insertions, 12 deletions
diff --git a/fracciones.activity/fractionlogic.py b/fracciones.activity/fractionlogic.py index 6c1fcf0..0acc7fe 100644 --- a/fracciones.activity/fractionlogic.py +++ b/fracciones.activity/fractionlogic.py @@ -20,7 +20,7 @@ class FractionLogic(object): if DENOMINATOR_MIN < 1: raise Exception("DENOMINATOR_MIN need be greather than 0") self.denominator = random.randrange(DENOMINATOR_MIN, DENOMINATOR_MAX) - self.numerator = random.randrange(0, self.denominator) + self.numerator = random.randrange(0, self.denominator+1) def get_current(self): diff --git a/fracciones.activity/fractionpresentation.py b/fracciones.activity/fractionpresentation.py index 9e7deb2..ee98f14 100644 --- a/fracciones.activity/fractionpresentation.py +++ b/fracciones.activity/fractionpresentation.py @@ -19,8 +19,8 @@ class FractionPresentation(gtk.VBox): def __init__(self): super(FractionPresentation, self).__init__() # Change font size - settings = gtk.settings_get_default() - settings.set_string_property("gtk-font-name", "Sans 40", "FractionPresentation") + #settings = gtk.settings_get_default() + #settings.set_string_property("gtk-font-name", "Sans 40", "FractionPresentation") # instantiate logic self.logic = FractionLogic() @@ -37,7 +37,7 @@ class FractionPresentation(gtk.VBox): gamem.set_submenu(gamemenu) new = gtk.MenuItem("New") - new.connect("activate", self.new_game) + new.connect("activate", self.menu_game_new) gamemenu.append(new) exit = gtk.MenuItem("Exit") @@ -56,7 +56,7 @@ class FractionPresentation(gtk.VBox): mb.append(helpm) # 2. label - label = gtk.Label("""Select %i/%i"""%self.logic.get_current()) + label = gtk.Label("""Eat %i/%i"""%self.logic.get_current()) self.pack_start(label, False, True) self.label = label # 3. cake @@ -74,19 +74,18 @@ class FractionPresentation(gtk.VBox): self.show_all() - def new_game(self): + def menu_game_new(self, menuitem): log.debug("menu_game_new") - self.logic.generate() - self.label.set_text("""Select %i/%i"""%self.logic.get_current()) - self.cake.reset(self.logic.get_current()[1]) + self.new_game() - def menu_game_exit(self): + def menu_game_exit(self, menuitem): log.debug("menu_game_exit") gtk.main_quit() - def menu_help_about(self): + def menu_help_about(self, menuitem): + print menuitem log.debug("menu_help_about") about = gtk.AboutDialog() about.set_program_name("Fracciones") @@ -97,7 +96,7 @@ class FractionPresentation(gtk.VBox): def check_cake(self, widget): """Clicked button check""" log.debug("on_clicked_check") - if self.logic.is_equal(self.cake.get_current_fraction()): + if self.logic.is_equal(self.cake.current_fraction): md = gtk.MessageDialog(None, gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_INFO, gtk.BUTTONS_CLOSE, "GOOD!") md.run() md.destroy() @@ -108,6 +107,12 @@ class FractionPresentation(gtk.VBox): md.destroy() + def new_game(self): + self.logic.generate() + self.label.set_text("""Eat %i/%i"""%self.logic.get_current()) + self.cake.reset(self.logic.get_current()[1]) + + if __name__ == "__main__": class Main(gtk.Window): def __init__(self): |