diff options
author | Roberto Cristaldo <rcristal@gmail.com> | 2013-01-24 20:53:57 (GMT) |
---|---|---|
committer | Roberto Cristaldo <rcristal@gmail.com> | 2013-01-24 20:53:57 (GMT) |
commit | b0f97c8510d446afec7a8a09e4f50c09d96564f8 (patch) | |
tree | 2ca68bb66330aae6f3ac39f4742543d2e9a9a8ec /elephant.py | |
parent | ecb5d99eb721b99b6b8198b47684168c07544df3 (diff) |
Funciona el random de palabras y letras. Falta integrar
Diffstat (limited to 'elephant.py')
-rwxr-xr-x | elephant.py | 123 |
1 files changed, 64 insertions, 59 deletions
diff --git a/elephant.py b/elephant.py index 3cde126..5f680e7 100755 --- a/elephant.py +++ b/elephant.py @@ -1,69 +1,74 @@ #!/usr/bin/python -import gtk +import ConfigParser -class ElephantApp(): +from random import choice - def __init__ (self): - # Main windows definition - window_main = gtk.Window() +# Global definition +CONF_FILE='elephant.conf' +CAT_SECTION='Categories' +WORDS_SECTION='Words' - # Vertical box conteinter definition - vbox_main = gtk.VBox() +# Class +# Return the word list from config file and numbers of word +class word_list: + + def __init__(self): + # Number of words + self.number_of_words = len(self.get_word_list()) - # Horizontal boxes conteiners definition - hbox_01 = gtk.HBox() - hbox_02 = gtk.HBox() - hbox_03 = gtk.HBox() + # Get all categories from config file + def get_categories(self): + parser = ConfigParser.SafeConfigParser() + parser.read(CONF_FILE) - # Buttons definitions - button_repeat = gtk.Button() - button_repeat.set_label('Repetir') - - button_option1 = gtk.Button() - button_option1.set_label('Opcion 1:') + full_list = parser.items(CAT_SECTION) + category_list = [row[1] for row in full_list] + + return category_list + + # Get all words from a specifir category + #def get_words_in_category(self, category): + # parser = ConfigParser.SafeConfigParser() + # parser.read(CONF_FILE) + # + # word_list = parser.options(category) + # + # return word_list + + # Get all words form config file + def get_word_list(self): + parser = ConfigParser.SafeConfigParser() + parser.read(CONF_FILE) - button_option2 = gtk.Button() - button_option2.set_label('Opcion 2:') + full_list = parser.items(WORDS_SECTION) + word_list = [row[0] for row in full_list] + + return word_list + + # Get path of choosen image + def get_word_image_path(self, word): + parser = ConfigParser.SafeConfigParser() + parser.read(CONF_FILE) + + image_path = parser.get(WORDS_SECTION, word) + + return image_path + +class letters: + + def __init__(self): + pass + + def get_letter(self, word): + letter = choice (word) + + return letter + - button_option3 = gtk.Button() - button_option3.set_label('Opcion 3:') - - # Label and image area - image_word = gtk.Image() - pixbuf = gtk.gdk.pixbuf_new_from_file("images/elephant.jpg") - scaled_pixbuf = pixbuf.scale_simple(150,150,gtk.gdk.INTERP_BILINEAR) - image_word.set_from_pixbuf(scaled_pixbuf) - label_word = gtk.Label() - label_word.set_text('Elefante') - - # Connect to destructor - window_main.connect('destroy', self.destroy) - - # Create layout - window_main.add(vbox_main) - vbox_main.add(hbox_01) - vbox_main.add(hbox_02) - vbox_main.add(hbox_03) - - # Put label and label on layout - hbox_02.add(image_word) - hbox_02.add(label_word) - - # Put buttons on layout - hbox_01.add(button_repeat) - hbox_03.add(button_option1) - hbox_03.add(button_option2) - hbox_03.add(button_option3) - - # ShowMeTheMoney - window_main.show_all() - - # Kaaabbbuummm!! - def destroy(self, elephant_window, data=None): - gtk.main_quit() - -if __name__ == "__main__": - elephant = ElephantApp() - gtk.main()
\ No newline at end of file + + + + +
\ No newline at end of file |