rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
self.builder.get_object('look_webster').set_sensitive(False) label = self.builder.get_object('label13') label.set_text('Searching...')
def _startthread(self): #print 'searching webster' self.builder.get_object('look_webster').set_sensitive(False) label = self.builder.get_object('label13') label.set_text('Searching...') word = self.tree_value dic = 'webster' if wordz_db.check_ws(win.tree_value): defs = wordz_db.get_dict_data(dic, win.tree_value)[0] else: d = online_dict() defs = d.get_def(word) wordz_db.save_webster(win.tree_value, defs) defs = '\n' + "webster:\n" + defs + '\n' #print defs label.set_text(defs.encode('utf-8')) self.builder.get_object('look_webster').set_sensitive(True)
label.set_text(defs.encode('utf-8'))
def _startthread(self): #print 'searching webster' self.builder.get_object('look_webster').set_sensitive(False) label = self.builder.get_object('label13') label.set_text('Searching...') word = self.tree_value dic = 'webster' if wordz_db.check_ws(win.tree_value): defs = wordz_db.get_dict_data(dic, win.tree_value)[0] else: d = online_dict() defs = d.get_def(word) wordz_db.save_webster(win.tree_value, defs) defs = '\n' + "webster:\n" + defs + '\n' #print defs label.set_text(defs.encode('utf-8')) self.builder.get_object('look_webster').set_sensitive(True)
th = get_def_thread()
def autolabel(rects): # attach some text labels for rect in rects: height = rect.get_height() ax.text(rect.get_x()+rect.get_width()/2., 1.05*height, '%d'%int(height), ha='center', va='bottom')
elif i[1] != '0:0' and i[0] in self.new_word: self.new_word.remove(i[0])
else: try: self.new_word.remove(i[0]) except: pass
def custom_tree_col_view(self, column, renderer, model, iter, data): word = model.get_value(iter, 0) for i in data: if i[0] == word and i[1] == '0:0' and word not in self.new_word: self.new_word.append(word) elif i[1] != '0:0' and i[0] in self.new_word: self.new_word.remove(i[0]) #print self.new_word if word in self.new_word: renderer.set_property('text', 'New') else: renderer.set_property('text', None)
self.window.show()
self.window.show()'''
def on_mcq_clicked(self, widget=None, event=None): self.window.hide() game = games.mcq() self.treestore.clear() conn = sqlite3.connect(db_file_path) c = conn.cursor() c.execute("""select word, accuracy from word_groups""") ls = c.fetchall() #print 'l', l c.close() self.acc_dict = {} for i in ls: if i[1] == u'0:0': self.acc_dict[i[0]] = 0 else: t = i[1].split(':') acc = float(t[0])/float(t[1])*100 acc = int(acc) self.acc_dict[i[0]] = acc #print self.acc_dict for group in wordz_db.list_groups(): l = wordz_db.list_words_per_group(group) t = 0 count = 0 for i in l: if i not in self.new_word: t = t + self.acc_dict[i] count = count + 1 if count!=0: t = t/count else: t = 0 #print self.acc_dict.keys() piter = self.treestore.append(None, [group,t]) for word in wordz_db.list_words_per_group(group): self.treestore.append(piter, [word,self.acc_dict[word]]) self.treeview.expand_all() self.window.show()
self.new_word.append(word)
def on_add_clicked(self, widget, data=None): word = self.get_word.get_text() if word not in self.new_word and word not in wordz_db.list_words(): self.new_word.append(word)
self.new_word = []
def on_back_clicked(self, widget=None, data=None): if self.search.get_text()!= '': self.frame2.hide() self.search.set_text('') self.welcome.show() self.note.set_alignment(0.5, 0.1) self.note.set_markup('<span foreground="white"><b>Nothing selected</b></span>') return self.treestore.clear() #self.search.set_text('') self.new_word = [] conn = sqlite3.connect(db_file_path) c = conn.cursor() c.execute("""select word, accuracy from word_groups""") ls = c.fetchall() #print 'l', ls c.close() self.acc_dict = {} for i in ls: if i[1] == u'0:0': self.acc_dict[i[0]] = 0 else: try: self.new_word.remove(i[0]) except: pass t = i[1].split(':') acc = float(t[0])/float(t[1])*100 acc = int(acc) self.acc_dict[i[0]] = acc
self.hbox2.pack_start(self.welcome)
def __init__(self): self.builder = gtk.Builder() self.builder.add_from_file("wordgroupz.glade") self.window = self.builder.get_object("MainWindow") self.window.set_icon_from_file("/usr/share/pixmaps/wordgroupz.png") self.window.set_title("wordGroupz") self.builder.connect_signals(self) self.get_word = self.builder.get_object("get_word") self.get_group = gtk.combo_box_entry_new_text() self.get_group.set_tooltip_text("Enter a group for your word") self.details = self.builder.get_object("textview1") self.eventbox1 = self.builder.get_object('eventbox1') self.eventbox1.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse('#444444')) self.get_group.child.connect('key-press-event',self.item_list_changed) #self.vpan = self.builder.get_object("vpaned1") self.output_txtview = self.builder.get_object("textview2") #pango self.fontdesc = pango.FontDescription("Purisa 10") #self.output_txtview.modify_font(self.fontdesc) for x in wordz_db.list_groups(): self.get_group.append_text(x) self.table1 = self.builder.get_object("table1") self.get_group.show() self.table1.attach(self.get_group, 1,2,1,2)
t = (grp,'', wn)
t = (grp,'', wn, '', '')
def add_to_db(self,word, grp, detail): conn = sqlite3.connect(db_file_path) c = conn.cursor() conn.text_factory = str if grp not in self.list_groups() and grp is not '': if word is '': wn = wordnet.get_definition(grp) t = (grp,detail,wn, '', '') else: wn = wordnet.get_definition(grp) t = (grp,'', wn) c.execute("""insert into groups values (?,?,?,?,?)""",t) conn.commit() #allow words with no groups to be added elif 'no-category' not in self.list_groups() and grp is '': c.execute("""insert into groups values ('no-category','Uncategorized words')""") if word is not '' and word not in self.list_words_per_group(grp): if grp == '': grp = 'no-category' wn = wordnet.get_definition(word) print wn t = (word, grp, detail, wn, '', '') c.execute('''insert into word_groups values(?,?,?,?,?,?)''', t) conn.commit() c.close()
c.execute("""select word, details from word_groups order by word""")
c.execute("""select word, wordnet from word_groups order by word""")
def get_details_for_flashcard(self): conn = sqlite3.connect(db_file_path) c = conn.cursor() c.execute("""select word, details from word_groups order by word""") data = c.fetchall() c.close() conn.close() return data
c.execute("""update word_groups set details='%s' where word=?"""% (details),t)
c.execute("""update word_groups set details="%s" where word=?"""% (details),t)
def update_details(self,tree_value, details): conn = sqlite3.connect(db_file_path) c = conn.cursor() t = (tree_value,) c.execute("""update word_groups set details='%s' where word=?"""% (details),t) conn.commit() c.close()
c.execute("""update groups set wiktionary='%s' where grp=?"""%(data), t)
c.execute("""update groups set wiktionary="%s" where grp=?"""%(data), t)
def save_wiktionary(self, word, data): conn = sqlite3.connect(db_file_path) c = conn.cursor() t = (word,) if word in self.list_groups(): c.execute("""update groups set wiktionary='%s' where grp=?"""%(data), t) else: c.execute("""update word_groups set wiktionary='%s' where word=?"""%(data), t) conn.commit() c.close() conn.close()
c.execute("""update word_groups set wiktionary='%s' where word=?"""%(data), t)
c.execute("""update word_groups set wiktionary="%s" where word=?"""%(data), t)
def save_wiktionary(self, word, data): conn = sqlite3.connect(db_file_path) c = conn.cursor() t = (word,) if word in self.list_groups(): c.execute("""update groups set wiktionary='%s' where grp=?"""%(data), t) else: c.execute("""update word_groups set wiktionary='%s' where word=?"""%(data), t) conn.commit() c.close() conn.close()
c.execute("""update groups set wordnet='%s' where grp=?"""%(data), t)
c.execute("""update groups set wordnet="%s" where grp=?"""%(data), t)
def save_wordnet(self, word, data): conn = sqlite3.connect(db_file_path) c = conn.cursor() t = (word,) if word in self.list_groups(): c.execute("""update groups set wordnet='%s' where grp=?"""%(data), t) else: c.execute("""update word_groups set wordnet='%s' where word=?"""%(data), t) conn.commit() c.close() conn.close()
c.execute("""update word_groups set wordnet='%s' where word=?"""%(data), t)
c.execute("""update word_groups set wordnet="%s" where word=?"""%(data), t)
def save_wordnet(self, word, data): conn = sqlite3.connect(db_file_path) c = conn.cursor() t = (word,) if word in self.list_groups(): c.execute("""update groups set wordnet='%s' where grp=?"""%(data), t) else: c.execute("""update word_groups set wordnet='%s' where word=?"""%(data), t) conn.commit() c.close() conn.close()
c.execute("""update groups set webster='%s' where grp=?"""%(data), t)
c.execute("""update groups set webster="%s" where grp=?"""%(data), t)
def save_webster(self, word, data): conn = sqlite3.connect(db_file_path) c = conn.cursor() t = (word,) if word in self.list_groups(): c.execute("""update groups set webster='%s' where grp=?"""%(data), t) else: c.execute("""update word_groups set webster='%s' where word=?"""%(data), t) conn.commit() c.close() conn.close()
c.execute("""update word_groups set webster='%s' where word=?"""%(data), t)
c.execute("""update word_groups set webster="%s" where word=?"""%(data), t)
def save_webster(self, word, data): conn = sqlite3.connect(db_file_path) c = conn.cursor() t = (word,) if word in self.list_groups(): c.execute("""update groups set webster='%s' where grp=?"""%(data), t) else: c.execute("""update word_groups set webster='%s' where word=?"""%(data), t) conn.commit() c.close() conn.close()
self.wiki_word = str(soup.html.title).split(' ')[0].split('>')[1] print 'wiki_word'+self.wiki_word
def load_finished(self, webview, frame): self.progress.set_visible(False) self.status_label.set_text('Content loaded.') self.status_label.hide() self.status_label.set_text('') self.browser_load_status = 'finished' if self.audio_found == True: self.save_audio.set_sensitive(True) else: pass if self.count == 0: self.count = 1 else: self.look_for_audio() return html = self.browser.get_html() self.head_file = open('wiktionary_header', 'r') self.head = self.head_file.read() self.head_file.close() self.head = self.head.replace('enter_title', self.tree_value) #self.status_label.set_text('Scrapping...') soup = BeautifulSoup(self.head+'<body>'+html+'</body></html>')
if self.selected_word is self.wiki_word and (self.browser_load_status is 'finished' or 'loading'):
if self.tree_value == self.wiki_word and (self.browser_load_status is 'finished' or 'loading'):
def on_notebook1_switch_page(self, notebook, page, page_num): #print 'page switched' #print page_num width, height = self.window.get_size() if page_num==1: self.window.resize(max(width, 800), max(height, 550)) #print self.tree_value, self.wiki_word, self.browser_load_status if self.selected_word is self.wiki_word and (self.browser_load_status is 'finished' or 'loading'): pass else: #self.url = 'http://en.wiktionary.org/wiki/' + self.tree_value #self.browser.open(self.url) self.on_lookup_wiki_clicked() elif page_num == 0: self.window.resize(min(width, 700), min(height, 550))
if wn is not None:
if wn != u'':
def show_details_tree(self): wn = wordz_db.get_dict_data('wordnet', self.tree_value)[0] #print wn ws = wordz_db.get_dict_data('webster', self.tree_value)[0] wik = wordz_db.get_dict_data('wiktionary', self.tree_value)[0] self.details_treestore.clear() if wn is not None: t = wn.split('\n') #print t piter = self.details_treestore.append(None, ['<span foreground="blue"><big><b>Wordnet</b></big></span>']) for x in t: if not x.startswith('\t') and x is not u'': sub_iter = self.details_treestore.append(piter, ['<b>'+x+'</b>']) elif x.startswith('\t') and not x.startswith('\tSynonyms:'): sub_sub_iter = self.details_treestore.append(sub_iter, [x.strip('\t')]) elif x.startswith('\tSynonyms:'): self.details_treestore.append(sub_sub_iter, [x.strip('\t').replace('Synonyms', '<span foreground="blue">Synonyms</span>')]) if wik is not None: t = wik.split('\n') piter = self.details_treestore.append(None,['<span foreground="blue"><big><b>Wiktionary</b></big></span>']) #sub_iter = self.details_treestore.append(piter, [wik]) print t for x in t: if x.startswith('#'): sub_iter = self.details_treestore.append(piter, ['<b>'+x.lstrip('#')+'</b>']) elif not x.startswith('\t') and not x.startswith('#'): self.details_treestore.append(sub_iter, [x]) elif x.startswith('\t#'): sub_sub_iter = self.details_treestore.append(sub_iter, ['<b>'+x.lstrip('\t#')+'</b>']) elif x.startswith('\t') and not x.startswith('\t#'): self.details_treestore.append(sub_sub_iter, [x.lstrip('\t')]) elif x.startswith('\t\t#'): sub_sub_sub_iter = self.details_treestore.append(sub_iter, ['<i>'+x.lstrip('\t\t#')+'</i>']) elif x.startswith('\t\t') and not x.startswith('\t\t#'): self.details_treestore.append(sub_sub_sub_iter, [x.lstrip('\t\t')]) #print self.details_cell.get_property('is-expander') self.details_treeview.expand_all()
if wik is not None:
if wik is not u'':
def show_details_tree(self): wn = wordz_db.get_dict_data('wordnet', self.tree_value)[0] #print wn ws = wordz_db.get_dict_data('webster', self.tree_value)[0] wik = wordz_db.get_dict_data('wiktionary', self.tree_value)[0] self.details_treestore.clear() if wn is not None: t = wn.split('\n') #print t piter = self.details_treestore.append(None, ['<span foreground="blue"><big><b>Wordnet</b></big></span>']) for x in t: if not x.startswith('\t') and x is not u'': sub_iter = self.details_treestore.append(piter, ['<b>'+x+'</b>']) elif x.startswith('\t') and not x.startswith('\tSynonyms:'): sub_sub_iter = self.details_treestore.append(sub_iter, [x.strip('\t')]) elif x.startswith('\tSynonyms:'): self.details_treestore.append(sub_sub_iter, [x.strip('\t').replace('Synonyms', '<span foreground="blue">Synonyms</span>')]) if wik is not None: t = wik.split('\n') piter = self.details_treestore.append(None,['<span foreground="blue"><big><b>Wiktionary</b></big></span>']) #sub_iter = self.details_treestore.append(piter, [wik]) print t for x in t: if x.startswith('#'): sub_iter = self.details_treestore.append(piter, ['<b>'+x.lstrip('#')+'</b>']) elif not x.startswith('\t') and not x.startswith('#'): self.details_treestore.append(sub_iter, [x]) elif x.startswith('\t#'): sub_sub_iter = self.details_treestore.append(sub_iter, ['<b>'+x.lstrip('\t#')+'</b>']) elif x.startswith('\t') and not x.startswith('\t#'): self.details_treestore.append(sub_sub_iter, [x.lstrip('\t')]) elif x.startswith('\t\t#'): sub_sub_sub_iter = self.details_treestore.append(sub_iter, ['<i>'+x.lstrip('\t\t#')+'</i>']) elif x.startswith('\t\t') and not x.startswith('\t\t#'): self.details_treestore.append(sub_sub_sub_iter, [x.lstrip('\t\t')]) #print self.details_cell.get_property('is-expander') self.details_treeview.expand_all()
print t
def show_details_tree(self): wn = wordz_db.get_dict_data('wordnet', self.tree_value)[0] #print wn ws = wordz_db.get_dict_data('webster', self.tree_value)[0] wik = wordz_db.get_dict_data('wiktionary', self.tree_value)[0] self.details_treestore.clear() if wn is not None: t = wn.split('\n') #print t piter = self.details_treestore.append(None, ['<span foreground="blue"><big><b>Wordnet</b></big></span>']) for x in t: if not x.startswith('\t') and x is not u'': sub_iter = self.details_treestore.append(piter, ['<b>'+x+'</b>']) elif x.startswith('\t') and not x.startswith('\tSynonyms:'): sub_sub_iter = self.details_treestore.append(sub_iter, [x.strip('\t')]) elif x.startswith('\tSynonyms:'): self.details_treestore.append(sub_sub_iter, [x.strip('\t').replace('Synonyms', '<span foreground="blue">Synonyms</span>')]) if wik is not None: t = wik.split('\n') piter = self.details_treestore.append(None,['<span foreground="blue"><big><b>Wiktionary</b></big></span>']) #sub_iter = self.details_treestore.append(piter, [wik]) print t for x in t: if x.startswith('#'): sub_iter = self.details_treestore.append(piter, ['<b>'+x.lstrip('#')+'</b>']) elif not x.startswith('\t') and not x.startswith('#'): self.details_treestore.append(sub_iter, [x]) elif x.startswith('\t#'): sub_sub_iter = self.details_treestore.append(sub_iter, ['<b>'+x.lstrip('\t#')+'</b>']) elif x.startswith('\t') and not x.startswith('\t#'): self.details_treestore.append(sub_sub_iter, [x.lstrip('\t')]) elif x.startswith('\t\t#'): sub_sub_sub_iter = self.details_treestore.append(sub_iter, ['<i>'+x.lstrip('\t\t#')+'</i>']) elif x.startswith('\t\t') and not x.startswith('\t\t#'): self.details_treestore.append(sub_sub_sub_iter, [x.lstrip('\t\t')]) #print self.details_cell.get_property('is-expander') self.details_treeview.expand_all()
self.scrolledwindow2 = self.builder.get_object("scrolledwindow2") self.scrolledwindow2.add_with_viewport(self.treeview)
self.scrolledwindow2 = gtk.ScrolledWindow() self.scrolledwindow2.add(self.treeview) self.scrolledwindow2.show() self.scrolledwindow2.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.vbox6 = self.builder.get_object('vbox6') self.vbox6.pack_start(self.scrolledwindow2)
def __init__(self): self.builder = gtk.Builder() self.builder.add_from_file("wordgroupz.glade") self.window = self.builder.get_object("MainWindow") self.window.set_icon_from_file("/usr/share/pixmaps/wordgroupz.png") self.window.set_title("wordGroupz") self.builder.connect_signals(self) self.get_word = self.builder.get_object("get_word") self.get_group = gtk.combo_box_entry_new_text() self.get_group.set_tooltip_text("Enter a group for your word") self.details = self.builder.get_object("textview1") self.eventbox1 = self.builder.get_object('eventbox1') self.eventbox1.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse('#444444')) self.get_group.child.connect('key-press-event',self.item_list_changed) #self.vpan = self.builder.get_object("vpaned1") self.output_txtview = self.builder.get_object("textview2") for x in wordz_db.list_groups(): self.get_group.append_text(x) self.table1 = self.builder.get_object("table1") self.get_group.show() self.table1.attach(self.get_group, 1,2,1,2)
return metadata.get("file_size")
if metadata: return metadata.get("file_size") return None
def get_torrent_size(self, torrent_url): """download torrent from the url and try to extract size""" try: import gzip import StringIO import hachoir_parser import hachoir_metadata except ImportError: return
client = transmission.transmission.Client(**args)
client = transmissionrpc.Client(**args)
def _send_command(self, torrent): args = {"address": str(self.host), "port": int(self.port)} if self.username: args["user"] = str(self.username) args["password"] = str(self.passwd) client = transmission.transmission.Client(**args)
except transmission.transmission.TransmissionError,e:
except transmissionrpc.TransmissionError,e:
def _send_command(self, torrent): args = {"address": str(self.host), "port": int(self.port)} if self.username: args["user"] = str(self.username) args["password"] = str(self.passwd) client = transmission.transmission.Client(**args)
return self.get_current_weather()
return self.get_random_weather()
def get_random_weather(self): """ Returns a random weather, never returns the previous weather. """ l = ["rainy", "sunny", "cold", "normal"] i = random.randint(0, 3) if i == self.p_i: return self.get_current_weather() else: self.p_i = i print "se genero el clima: ", l[i] return l[i]
"""
def draw(self, screen): if self.first: # First time blits the entire background self.first = False screen.blit(self.background, self.rect) return [self.rect] else: # Next blits only the changed areas changes = [] for win in self.windows: changes.extend(win.draw(screen)) return changes #[rect.move(self.rect.left, self.rect.top) for rect in changes]
self.overall_section = BarSection(windows_controller, _("Total"), bars_loader.get_overall_bar(), [] , (SECTION_WIDTH, SECTION_MIN_HEIGHT), (SECTION_OFFSET_X, 32), "assets/layout/icon_total.png") self.physica_section = BarSection(windows_controller, _("physica"), self.bars[0], self.bars[0].children_list, (SECTION_WIDTH, SECTION_MIN_HEIGHT), (SECTION_OFFSET_X, 60), "assets/layout/icon_physica.png")
self.overall_section = BarSection(windows_controller, _("Total"), bars_loader.get_overall_bar(), [] , (SECTION_WIDTH, SECTION_MIN_HEIGHT), (SECTION_OFFSET_X, 20), "assets/layout/icon_total.png") self.physica_section = BarSection(windows_controller, _("physica"), self.bars[0], self.bars[0].children_list, (SECTION_WIDTH, SECTION_MIN_HEIGHT), (SECTION_OFFSET_X, 50), "assets/layout/icon_physica.png")
def __init__(self, container, rect, frame_rate, windows_controller, bars_loader): Window.__init__(self, container, rect, frame_rate, windows_controller) # rect and surface: self.rect.size = (227, 590) # game bars self.bars = bars_loader.get_second_level_bars() # sections self.score_section = ScoreSection(StatusBar("score_bar", "score", None, bars_loader.get_overall_bar(), 100, 15), (SECTION_WIDTH, SECTION_MIN_HEIGHT), (SECTION_OFFSET_X, 0), 1) self.overall_section = BarSection(windows_controller, _("Total"), bars_loader.get_overall_bar(), [] , (SECTION_WIDTH, SECTION_MIN_HEIGHT), (SECTION_OFFSET_X, 32), "assets/layout/icon_total.png") self.physica_section = BarSection(windows_controller, _("physica"), self.bars[0], self.bars[0].children_list, (SECTION_WIDTH, SECTION_MIN_HEIGHT), (SECTION_OFFSET_X, 60), "assets/layout/icon_physica.png") self.hygiene_section = BarSection(windows_controller, _("hygiene"), self.bars[1], self.bars[1].children_list, (SECTION_WIDTH, SECTION_MIN_HEIGHT), (SECTION_OFFSET_X, 80), "assets/layout/icon_hygiene.png") self.nutrition_section = BarSection(windows_controller, _("nutrition"), self.bars[2], self.bars[2].children_list, (SECTION_WIDTH, SECTION_MIN_HEIGHT), (SECTION_OFFSET_X, 100), "assets/layout/icon_nutrition.png") self.spare_time_section = BarSection(windows_controller, _("spare time"), self.bars[3], self.bars[3].children_list, (SECTION_WIDTH, SECTION_MIN_HEIGHT), (SECTION_OFFSET_X, 120), "assets/layout/icon_spare_time.png") self.sections_list = [self.score_section, self.overall_section, self.physica_section, self.hygiene_section, self.nutrition_section, self.spare_time_section] self.accordeon = Accordeon([self.physica_section, self.hygiene_section, self.nutrition_section, self.spare_time_section]) self.set_bg_image("assets/layout/status.png") #self.score_section, self.windows += [section for section in self.sections_list if section != self.score_section] # Score section no va porque no está convertida a window
self.nutrition_section = BarSection(windows_controller, _("nutrition"), self.bars[2], self.bars[2].children_list, (SECTION_WIDTH, SECTION_MIN_HEIGHT), (SECTION_OFFSET_X, 100), "assets/layout/icon_nutrition.png") self.spare_time_section = BarSection(windows_controller, _("spare time"), self.bars[3], self.bars[3].children_list, (SECTION_WIDTH, SECTION_MIN_HEIGHT), (SECTION_OFFSET_X, 120), "assets/layout/icon_spare_time.png")
self.nutrition_section = BarSection(windows_controller, _("nutrition"), self.bars[2], self.bars[2].children_list, (SECTION_WIDTH, SECTION_MIN_HEIGHT), (SECTION_OFFSET_X, 110), "assets/layout/icon_nutrition.png") self.spare_time_section = BarSection(windows_controller, _("spare time"), self.bars[3], self.bars[3].children_list, (SECTION_WIDTH, SECTION_MIN_HEIGHT), (SECTION_OFFSET_X, 140), "assets/layout/icon_spare_time.png")
def __init__(self, container, rect, frame_rate, windows_controller, bars_loader): Window.__init__(self, container, rect, frame_rate, windows_controller) # rect and surface: self.rect.size = (227, 590) # game bars self.bars = bars_loader.get_second_level_bars() # sections self.score_section = ScoreSection(StatusBar("score_bar", "score", None, bars_loader.get_overall_bar(), 100, 15), (SECTION_WIDTH, SECTION_MIN_HEIGHT), (SECTION_OFFSET_X, 0), 1) self.overall_section = BarSection(windows_controller, _("Total"), bars_loader.get_overall_bar(), [] , (SECTION_WIDTH, SECTION_MIN_HEIGHT), (SECTION_OFFSET_X, 32), "assets/layout/icon_total.png") self.physica_section = BarSection(windows_controller, _("physica"), self.bars[0], self.bars[0].children_list, (SECTION_WIDTH, SECTION_MIN_HEIGHT), (SECTION_OFFSET_X, 60), "assets/layout/icon_physica.png") self.hygiene_section = BarSection(windows_controller, _("hygiene"), self.bars[1], self.bars[1].children_list, (SECTION_WIDTH, SECTION_MIN_HEIGHT), (SECTION_OFFSET_X, 80), "assets/layout/icon_hygiene.png") self.nutrition_section = BarSection(windows_controller, _("nutrition"), self.bars[2], self.bars[2].children_list, (SECTION_WIDTH, SECTION_MIN_HEIGHT), (SECTION_OFFSET_X, 100), "assets/layout/icon_nutrition.png") self.spare_time_section = BarSection(windows_controller, _("spare time"), self.bars[3], self.bars[3].children_list, (SECTION_WIDTH, SECTION_MIN_HEIGHT), (SECTION_OFFSET_X, 120), "assets/layout/icon_spare_time.png") self.sections_list = [self.score_section, self.overall_section, self.physica_section, self.hygiene_section, self.nutrition_section, self.spare_time_section] self.accordeon = Accordeon([self.physica_section, self.hygiene_section, self.nutrition_section, self.spare_time_section]) self.set_bg_image("assets/layout/status.png") #self.score_section, self.windows += [section for section in self.sections_list if section != self.score_section] # Score section no va porque no está convertida a window
self.root_bar_display = BarDisplay(BAR_HEIGHT, (size[0] - 2), (BAR_OFFSET_X, (size[1] / 2) - 13), self.root_bar, ROOT_BAR_COLOR)
self.root_bar_display = BarDisplay(BAR_HEIGHT, (size[0] - 2), (BAR_OFFSET_X, SECTION_TOP_PADDING), self.root_bar, ROOT_BAR_COLOR)
def __init__(self, windows_controller, name, root_bar, children_bar, size, position, icon_path): rect = pygame.Rect(position, size) Window.__init__(self, rect, rect, 1, windows_controller) # section attributes self.name = name self.root_bar = root_bar self.children_bar = children_bar # visuals self.root_bar_display = BarDisplay(BAR_HEIGHT, (size[0] - 2), (BAR_OFFSET_X, (size[1] / 2) - 13), self.root_bar, ROOT_BAR_COLOR) self.displays_list = self.__get_displays() # obtengo los displays para cada barra. self.fixed_widgets = [] if icon_path: icon = pygame.image.load(icon_path).convert_alpha() self.icon = Widget(self.rect, pygame.Rect((0, 0), icon.get_size()), 1, icon) self.fixed_widgets.append(self.icon) else: self.icon = None # visuals constant self.init_top = self.rect[1] self.init_height = size[1] self.max_expand = len(children_bar) * (BAR_HEIGHT + 1) self.expanded = False # Este flag se activa cuando se están mostrando las sub-barras self.__calculate() # calculo la posición de cada barra en la sección
y = 0
y = SECTION_TOP_PADDING
def __calculate(self): """ Calcula la posición de cada barra dependiendo de si está expandida o no la sección. """ # Refresh the absolute position of the root bar self.root_bar_display.container = self.rect self.root_bar_display.set_rect_in_container(self.root_bar_display.rect_in_container) self.widgets = [self.root_bar_display] if self.expanded: y = 0 for display in self.displays_list: y += (BAR_HEIGHT + 1) display.container = self.rect display.rect_in_container.top = y display.set_rect_in_container(display.rect_in_container) self.widgets.append(display) self.widgets.extend(self.fixed_widgets)
if(button.rect.top == 130):
if(button.rect_in_container.top == 130):
def _cb_button_click_choice(self, button): global FIN_MC if(button.rect.top == 130): self.s_correct.play() FIN_MC = True # Damos por finalizada la pregunta else: self.s_incorrect.play()
if isinstance(color, pygame.Color):
if isinstance(color, tuple): return color elif isinstance(color, pygame.Color):
def get_color_tuple(color): if isinstance(color, pygame.Color): return (color.r, color.g, color.b, color.a) elif isinstance(color, tuple): return color else: color = pygame.Color(color) return get_color_tuple(color)
elif isinstance(color, tuple): return color
def get_color_tuple(color): if isinstance(color, pygame.Color): return (color.r, color.g, color.b, color.a) elif isinstance(color, tuple): return color else: color = pygame.Color(color) return get_color_tuple(color)
<<<<<<< HEAD
def __init__(self, container, rect, frame_rate, clock, screen, windows_controller): Window.__init__(self, container, rect, frame_rate, (0, 0, 0), screen, windows_controller) self.name = "main" self.clock = clock self.windows = [] # Lista de ventanas que 'componen' la ventana principal
=======
def __init__(self, container, rect, frame_rate, clock, screen, windows_controller): Window.__init__(self, container, rect, frame_rate, (0, 0, 0), screen, windows_controller) self.name = "main" self.clock = clock self.windows = [] # Lista de ventanas que 'componen' la ventana principal
self.windows.append(self.status_bars) >>>>>>> 73f0d4ce24750887870a439c77676d1efa9d84a4
def __init__(self, container, rect, frame_rate, clock, screen, windows_controller): Window.__init__(self, container, rect, frame_rate, (0, 0, 0), screen, windows_controller) self.name = "main" self.clock = clock self.windows = [] # Lista de ventanas que 'componen' la ventana principal
self.active_char_action.time_left = time_span
self.active_char_action.time_left = self.active_char_action.time_span
def interrupt_active_action(self, action_id): """ Stops the active action if exist, and set as active the action with the 'action_id'. If the action_id is 'None', just stops the active action. """ self.active_char_action.time_left = time_span self.active_char_action = None if(action_id): action = self.get_action(action_id) if(action): self.active_char_action = action
self.remove_button(self.b_event_personal)
if self.b_event_personal in self.buttons: self.remove_button(self.b_event_personal)
def remove_personal_event(self, event): self.active_personal_events.remove(event) self.windows_controller.hide_active_tooltip() self.remove_button(self.b_event_personal) self.b_event_personal = None
self.game_manager.add_active_action(action_id)
self.game_manager.set_active_action(action_id)
def send_action(self, action_id): """ Send an action to the game_manager. The action was selected in one of the sub-items """ self.game_manager.add_active_action(action_id)
arrow_position = self.status_bar.value * (self.rect_in_container.width - 2.0) / self.status_bar.max
position = self.status_bar.value * (self.rect_in_container.width) / (BAR_WIDTH) arrow_position = min([position, BAR_WIDTH + BAR_OFFSET_X])
def draw(self, screen): if self.last_value != self.status_bar.value: if isinstance(self.status_bar, WeightBar): arrow_position = self.status_bar.value * (self.rect_in_container.width - 2.0) / self.status_bar.max self.surface.blit(self.background, (0, 0)) self.surface.blit(self.arrow, (arrow_position, 14)) elif isinstance(self.status_bar, StatusBar): rect = pygame.Rect((1, 2), (self.rect_in_container.width - 2, self.rect_in_container.height - 4)) charged_rect = pygame.Rect(rect) # create a copy charged_rect.width = self.status_bar.value * rect.width / self.status_bar.max color = self.get_color() self.surface.fill(BAR_BACK_COLOR, rect) self.surface.fill(color, charged_rect) self.surface.blit(self.background, (0, 0)) # Background blits over the charge, because it has the propper alpha if self.show_name: self.surface.blit(self.font.render(self.label, 1, pygame.Color(SUB_BAR_TEXT_COLOR)), (8, 4)) screen.blit(self.surface, self.rect_absolute) return self.rect_absolute
self.exit = Item(container, frame_rate, "salir", "assets/icons/icon_quit.png", CLOSE_MENU, [], self, font, True)
self.exit = Item(container, frame_rate, "salir", "assets/icons/icon_quit.png", CLOSE_MENU, [], self, font, None, None, True)
def __init__(self, frame_rate, container, windows_controller, item_list, center, radius, game_manager, font): rect = pygame.Rect((0, 0), SIZE) rect.center = center self.windows_controller = windows_controller self.game_manager = game_manager Window.__init__(self, container, rect, frame_rate, windows_controller, "menu_window")
self.back = Item(container, frame_rate, "back", "assets/icons/icon_quit.png", BACK_MENU, [], self, font, True)
self.back = Item(container, frame_rate, "back", "assets/icons/icon_quit.png", BACK_MENU, [], self, font, None, None, True)
def __init__(self, frame_rate, container, windows_controller, item_list, center, radius, game_manager, font): rect = pygame.Rect((0, 0), SIZE) rect.center = center self.windows_controller = windows_controller self.game_manager = game_manager Window.__init__(self, container, rect, frame_rate, windows_controller, "menu_window")
action.perform()
action.perform() self.windows_controller.show_action_animation(action)
def set_active_action(self, action_id): #place = get_place(self.character.actual_place) #if(place.allowed_action(action_id)): #continúa con la acción, solo si es permitida en el lugar if(not self.active_char_action): #Si existe una accion activa no la interrumpe if(True): #dont check char's place yet action = self.get_action(action_id) if(action): action.perform() self.active_char_action = action
action.perform() self.windows_controller.show_action_animation(action)
def interrupt_active_action(self, action_id): """ Stops the active action if exist, and set as active the action with the 'action_id'. If the action_id is 'None', just stops the active action. """ self.active_char_action.time_left = time_span self.active_char_action = None if(action_id): action = self.get_action(action_id) if(action): action.perform() self.windows_controller.show_action_animation(action) self.active_char_action = action
event = events.SocialEvent("unkown.png", "assets/characters/teacher.png", "health_check", _("Control médico"), 5.0, 30, probability, u"¿Este año fuiste al doctor?", 100)
event = events.SocialEvent("unkown.png", "assets/characters/teacher.png", "health_check", _("Control médico"), 5.0, 30, probability, u"¿Este año fuiste al doctor?", None, 100)
def __load_events(self, bars_controller): #Events constructor params: #picture, kid_animation_path, id, description, appereance_probability, time_span, kind, event_status, effect, kid_message, #preferred_mood=9, message_time_span = time_span) _events = [] # Personal Events # probabiliy configuration: (bar, type, threshold, probability_percentaje) probability = [("v_frutas", "indirect", 10.0, 30.0)] effect = effects.Effect(bars_controller, [("energy", -1.0), ("fun", -0.5)]) event = events.PersonalEvent("ill.jpg", None, "constipation", _("Constipation"), 5, 15, "personal", probability, effect, u"Me duele la panza y no \n puedo ir al baño", 2, 50) _events.append(event) probability = [("w_hands", "indirect", 25.0, 30.0)] effect = effects.Effect(bars_controller, [("energy", -1.0), ("fun", -0.5), ("agua", -1.0), ("defenses", -0.5)]) event = events.PersonalEvent("ill.jpg", None, "diarrhea", _("Diarrhea"), 5, 15, "personal", probability, effect, "Tengo diarrea", 2, 50) _events.append(event) probability = [("nutrition", "indirect", 100.0, 20.0), ("relaxing", "indirect", 100.0, 20.0)] effect = effects.Effect(bars_controller, [("energy", -1.0), ("fun", -0.5), ("relaxing", -0.5)]) event = events.PersonalEvent("ill.jpg", None, "headache", _("Headache"), 5, 15, "personal", probability, effect, "Me duele la cabeza", 2, 50) _events.append(event) probability = [("b_teeth", "indirect", 25.0, 50.0), ("dulces", "direct", 75.0, 20.0)] effect = effects.Effect(bars_controller, [("energy", -1.0), ("defenses", -1.0), ("fun", -1.0), ("relaxing", -1.0)]) event = events.PersonalEvent("caries.jpg", None, "caries", _("Caries"), 5, 15, "personal", probability, effect, "Me duele una muela", 5, 50) _events.append(event) probability = [("overall_bar", "constant", 100.0, 15.0)] effect = effects.Effect(bars_controller, [("nutrition", -0.3), ("energy", -1.0), ("resistencia", -0.9), ("fat", -0.5)]) event = events.PersonalEvent("ill.jpg", "assets/events/stomach_ache", "stomach_ache", _("Stomach ache"), 5, 15, "personal", probability, effect, "Me duele la panza! :(", 2, 50) _events.append(event) #Social events #(picture, person_path, name, description, appereance_probability, time_span, condicioned_bars, message, message_time_span) probability = [("b_teeth", "indirect", 50.0, 70.0), ("dulces", "direct", 75.0, 30.0)] #editar parametros: event = events.SocialEvent("caries.jpg", "assets/characters/teacher.png", "p_caries", _("Prevenir caries"), 5.0, 15, probability, u"Deberías lavarte los \ndientes", None, 100) _events.append(event)
window.Window.__init__(self, container, rect, frame_rate, windows_controller, pygame.Color("Gray"))
window.Window.__init__(self, container, rect, frame_rate, windows_controller, pygame.Color("gray"))
def __init__(self, container, rect, frame_rate, windows_controller, character): window.Window.__init__(self, container, rect, frame_rate, windows_controller, pygame.Color("Gray")) kid_rect = pygame.Rect((20, 20), (1,1)) self.kid = CustomizatedKid(self.rect, kid_rect, 1, character) self.add_child(self.kid) self.btn_close = utilities.TextButton(self.rect, pygame.Rect((770, 5), (30, 30)), 1, "X", 30, (0, 0, 0), self._cb_button_click_close) self.btn_hair = utilities.TextButton(self.rect, pygame.Rect((500, 150), (70, 30)), 1, _("Hair"), 30, (0, 0, 0), self._cb_button_hair) self.btn_skin = utilities.TextButton(self.rect, pygame.Rect((500, 200), (70, 30)), 1, _("Skin"), 30, (0, 0, 0), self._cb_button_skin) self.btn_socks = utilities.TextButton(self.rect, pygame.Rect((500, 250), (70, 30)), 1, _("Socks"), 30, (0, 0, 0), self._cb_button_socks) self.btn_shoes = utilities.TextButton(self.rect, pygame.Rect((500, 300), (70, 30)), 1, _("Shoes"), 30, (0, 0, 0), self._cb_button_shoes) self.buttons += [self.btn_close, self.btn_hair, self.btn_skin, self.btn_socks, self.btn_shoes] self.widgets += [self.btn_close, self.btn_hair, self.btn_skin, self.btn_socks, self.btn_shoes] self.hair_color_index = 0 self.skin_color_index = 0 self.socks_color_index = 0 self.shoes_color_index = 0
widget.Widget.__init__(self, container, rect, frame_rate, pygame.Color("Black"))
widget.Widget.__init__(self, container, rect, frame_rate, pygame.Color("black"))
def __init__(self, container, rect, frame_rate, character): widget.Widget.__init__(self, container, rect, frame_rate, pygame.Color("Black")) self.character = character self.mappings = CustomizatedKid.COLOR_MAP.copy() self.character.mappings = self.mappings self.set_gender("male") self.background = self.kid
def random_vec(xv, yv):
def random_vec(x, y):
def random_vec(xv, yv): return Vec2d( random.uniform(-xv, xv), random.uniform(-yv, yv))
random.uniform(-xv, xv), random.uniform(-yv, yv))
random.uniform(-x, x), random.uniform(-y, y))
def random_vec(xv, yv): return Vec2d( random.uniform(-xv, xv), random.uniform(-yv, yv))
if not self.score_changed: self.score_changed(score)
if self.score_changed: self.score_changed(score)
def score(self, score): if self.__score == score: return self.__score = score if not self.score_changed: self.score_changed(score)
self.vmw = game.Game(canvas, \ os.path.join(os.path.abspath('.'), \ 'images/'))
self.vmw = Game(canvas, os.path.join(os.path.abspath('.'), 'images/'))
def __init__(self): self.r = 0 self.tw = None # create a new window self.win = gtk.Window(gtk.WINDOW_TOPLEVEL) self.win.maximize() self.win.set_title("%s: %s" % (_("Visual Match"), _("Click on cards to create sets of three."))) self.win.connect("delete_event", lambda w, e: gtk.main_quit())
try:
if 1==1:
def load_score(self): try: f = file(os.path.join(os.path.abspath('.'), 'visualmatch.score'), "r") s = [f.read().split(":"), f.read().split(":")] f.close self.vmw.low_score = (int(s[0]), int(s[1])) print "low score is: %d" % (self.vmw.low_score) except: self.vmw.low_score = [-1, -1]
s = [f.read().split(":"), f.read().split(":")]
s = f.readlines()
def load_score(self): try: f = file(os.path.join(os.path.abspath('.'), 'visualmatch.score'), "r") s = [f.read().split(":"), f.read().split(":")] f.close self.vmw.low_score = (int(s[0]), int(s[1])) print "low score is: %d" % (self.vmw.low_score) except: self.vmw.low_score = [-1, -1]
self.vmw.low_score = (int(s[0]), int(s[1])) print "low score is: %d" % (self.vmw.low_score) except:
self.vmw.low_score = [int(s[0].split(':')[1].strip()), int(s[1].split(':')[1].strip())] print "low score is: %s" % (self.vmw.low_score) else:
def load_score(self): try: f = file(os.path.join(os.path.abspath('.'), 'visualmatch.score'), "r") s = [f.read().split(":"), f.read().split(":")] f.close self.vmw.low_score = (int(s[0]), int(s[1])) print "low score is: %d" % (self.vmw.low_score) except: self.vmw.low_score = [-1, -1]
f.write("low_score_beginner:%s" % str(int(self.vmw.low_score[0]))) f.write("low_score_expert:%s" % str(int(self.vmw.low_score[1])))
f.writelines(["low_score_beginner:%d\n" % int(self.vmw.low_score[0]), "low_score_expert:%d\n" % int(self.vmw.low_score[1])])
def save_score(self): f = file(os.path.join(os.path.abspath('.'), 'visualmatch.score'), "w") f.write("low_score_beginner:%s" % str(int(self.vmw.low_score[0]))) f.write("low_score_expert:%s" % str(int(self.vmw.low_score[1]))) f.close
basename = None
name = None
def _import_cb(self, button=None): """ Import custom cards from the Journal """ basename = None chooser = ObjectChooser(_('Choose custom card'), self, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, \ what_filter=mime.GENERIC_TYPE_IMAGE)
basename, suffix = name.split('.', 2)
def _import_cb(self, button=None): """ Import custom cards from the Journal """ basename = None chooser = ObjectChooser(_('Choose custom card'), self, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, \ what_filter=mime.GENERIC_TYPE_IMAGE)
if basename is not None: self._find_custom_paths(basename, mime_type) def _find_custom_paths(self, basename, mime_type):
if name is not None: self._find_custom_paths(name, mime_type) def _find_custom_paths(self, name, mime_type): parts = name.split('.') basename = parts[0] suffix = '' if len(parts) > 2: for i in range(2,len(name)): suffix += '.' suffix += parts[i]
def _import_cb(self, button=None): """ Import custom cards from the Journal """ basename = None chooser = ObjectChooser(_('Choose custom card'), self, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, \ what_filter=mime.GENERIC_TYPE_IMAGE)
basename + '.' + str(j+1):
basename + '.' + str(j+1) + suffix:
def _find_custom_paths(self, basename, mime_type): dsobjects, nobjects = datastore.find({'mime_type': str(mime_type)}) self.vmw.custom_paths = [] if nobjects > 0: for j in range(DECKSIZE): for i in range(nobjects): if dsobjects[i].metadata['title'] == \ basename + '.' + str(j+1): _logger.debug('result of find: %s' %\ dsobjects[i].metadata['title']) self.vmw.custom_paths.append(dsobjects[i].file_path) break self.vmw.card_type = 'custom' if len(self.vmw.custom_paths) < 9: self.vmw.card_type = 'pattern' elif len(self.vmw.custom_paths) < 27: self.vmw.level = DIFFICULTY_LEVEL.index(LOW) elif len(self.vmw.custom_paths) < 81: self.vmw.level = DIFFICULTY_LEVEL.index(MEDIUM) else: self.vmw.level = DIFFICULTY_LEVEL.index(HIGH) if self.vmw.card_type == 'custom': self.button_custom.set_icon('new-custom-game') self.button_custom.set_tooltip(_('New custom game')) self.metadata['custom_name'] = basename self.metadata['custom_mime_type'] = mime_type self.set_level_label() return
if 1==1:
try:
def load_score(self): if 1==1: f = file(os.path.join(os.path.abspath('.'), 'visualmatch.score'), "r") s = f.readlines() f.close self.vmw.low_score = [int(s[0].split(':')[1].strip()), int(s[1].split(':')[1].strip())] print "low score is: %s" % (self.vmw.low_score) else: self.vmw.low_score = [-1, -1]
else:
except:
def load_score(self): if 1==1: f = file(os.path.join(os.path.abspath('.'), 'visualmatch.score'), "r") s = f.readlines() f.close self.vmw.low_score = [int(s[0].split(':')[1].strip()), int(s[1].split(':')[1].strip())] print "low score is: %s" % (self.vmw.low_score) else: self.vmw.low_score = [-1, -1]
self._stroke_width = 1
self._stroke_width = 1.0
def __init__(self): self._scale = 1 self._stroke_width = 1 self._fill = RED_FILL self._stroke = RED_STROKE self._font = 'DejaVu'
self.set_stroke_width(2.0)
self._set_stroke_width(2.0)
def _svg_circle_of_dots(self, n, x, y): rtab = {5:9, 7:13, 11:17} r = rtab[n] ox = 0 oy = 32.5 da = pi * 2 / n a = 0 nx = ox + sin(a) * r ny = oy + cos(a) * r svg_string = "%s%f%s%f%s" % ("<g\n transform=\"translate(", x, ", ", y, ")\">\n") self.set_stroke_width(2.0) for i in range(n): svg_string += self._svg_circle(nx, ny, 3) a += da nx = ox + sin(a) * r ny = oy + cos(a) * r svg_string += "</g>\n" return svg_string
self.set_stroke_width(2.0)
self._set_stroke_width(2.0)
def _svg_line_of_dots(self, n, x, y): cxtab = {5:37.5, 7:27.5, 11:7.5, 10:37.5, 14:27.5, 22:7.5, 15:37.5, 21:27.5, 33:7.5} svg_string = "%s%f%s%f%s" % ("<g\n transform=\"translate(", x, ", ", y, ")\">\n") cx = cxtab[n] self.set_stroke_width(2.0) for i in range(n): svg_string += self._svg_circle(cx, 5, 3) cx += 10 svg_string += "</g>\n" return svg_string
self.set_stroke_width(2.0)
self._set_stroke_width(2.0)
def _svg_hash(self, n, x, y): cxtab = {5:42.5, 7:32.5, 11:22.5, 10:42.5, 14:32.5, 22:22.5, 15:42.5, 21:32.5, 33:22.5} cy = 5 x2 = cxtab[n] x1 = 7.5 + x2 svg_string = "%s%f%s%f%s" % ("<g\n transform=\"translate(", x, ", ", y, ")\">\n") self.set_stroke_width(2.0) for i in range(n): if (i + 1) % 5 == 0: svg_string += self._svg_line(x1-40, 7.5, x2, 7.5) else: svg_string += self._svg_line(x1, 0, x2, 15) x1 += 7.5 x2 += 7.5 svg_string += "</g>\n" return svg_string
print "quipu: %d %d %d" % (n, x, y)
def _svg_quipu(self, n, x, y): print "quipu: %d %d %d" % (n, x, y) svg_string = "%s%f%s%f%s" % ("<g\n transform=\"translate(", x, ", ", y, ")\">\n") x2 = x self.set_stroke_width(2.0) svg_string += self._svg_line(x2-40, 7.5, x2+40, 7.5) x2 -= 20 x1 = x2 + 7.5 for i in range(n): svg_string += self._svg_line(x1, 0, x2, 15) x1 += 7.5 x2 += 7.5 svg_string += "</g>\n" return svg_string
self.set_stroke_width(2.0)
self._set_stroke_width(2.0)
def _svg_quipu(self, n, x, y): print "quipu: %d %d %d" % (n, x, y) svg_string = "%s%f%s%f%s" % ("<g\n transform=\"translate(", x, ", ", y, ")\">\n") x2 = x self.set_stroke_width(2.0) svg_string += self._svg_line(x2-40, 7.5, x2+40, 7.5) x2 -= 20 x1 = x2 + 7.5 for i in range(n): svg_string += self._svg_line(x1, 0, x2, 15) x1 += 7.5 x2 += 7.5 svg_string += "</g>\n" return svg_string
svg_string = "%s%f%s%f%s" % ("<g\n transform=\"translate(", x, ", ", y, "\">\n") self.set_stroke_width(1.5) self.set_colors([self._stroke, "none"]) svg_string += self._svg_rect(25, 25, 2, 2, 0, 0) self.set_stroke_width(2) self.set_colors([self._stroke, self._stroke])
self._set_stroke_width(1.5) self._set_colors([self._stroke, "none"]) svg_string = self._svg_rect(25, 25, 2, 2, x, y) self._set_stroke_width(2) self._set_colors([self._stroke, self._stroke])
def _svg_die(self, n, x, y): svg_string = "%s%f%s%f%s" % ("<g\n transform=\"translate(", x, ", ", y, "\">\n") self.set_stroke_width(1.5) self.set_colors([self._stroke, "none"]) svg_string += self._svg_rect(25, 25, 2, 2, 0, 0) self.set_stroke_width(2) self.set_colors([self._stroke, self._stroke]) if n in [2, 3, 4, 5, 6]: svg_string += self._svg_circle(6, 6, 1.5) svg_string += self._svg_circle(19, 19, 1.5) if n in [1, 3, 5]: svg_string += self._svg_circle(12.5, 12.5, 1.5) if n in [4, 5, 6]: svg_string += self._svg_circle(19, 6, 1.5) svg_string += self._svg_circle(6, 19, 1.5) if n in [6]: svg_string += self._svg_circle(6, 12.5, 1.5) svg_string += self._svg_circle(19, 12.5, 1.5) svg_string += "</g>\n" return svg_string
svg_string += self._svg_circle(6, 6, 1.5) svg_string += self._svg_circle(19, 19, 1.5)
svg_string += self._svg_circle(6 + x, 6 + y, 1.5) svg_string += self._svg_circle(19 + x, 19 + y, 1.5)
def _svg_die(self, n, x, y): svg_string = "%s%f%s%f%s" % ("<g\n transform=\"translate(", x, ", ", y, "\">\n") self.set_stroke_width(1.5) self.set_colors([self._stroke, "none"]) svg_string += self._svg_rect(25, 25, 2, 2, 0, 0) self.set_stroke_width(2) self.set_colors([self._stroke, self._stroke]) if n in [2, 3, 4, 5, 6]: svg_string += self._svg_circle(6, 6, 1.5) svg_string += self._svg_circle(19, 19, 1.5) if n in [1, 3, 5]: svg_string += self._svg_circle(12.5, 12.5, 1.5) if n in [4, 5, 6]: svg_string += self._svg_circle(19, 6, 1.5) svg_string += self._svg_circle(6, 19, 1.5) if n in [6]: svg_string += self._svg_circle(6, 12.5, 1.5) svg_string += self._svg_circle(19, 12.5, 1.5) svg_string += "</g>\n" return svg_string
svg_string += self._svg_circle(12.5, 12.5, 1.5)
svg_string += self._svg_circle(12.5 + x, 12.5 + y, 1.5)
def _svg_die(self, n, x, y): svg_string = "%s%f%s%f%s" % ("<g\n transform=\"translate(", x, ", ", y, "\">\n") self.set_stroke_width(1.5) self.set_colors([self._stroke, "none"]) svg_string += self._svg_rect(25, 25, 2, 2, 0, 0) self.set_stroke_width(2) self.set_colors([self._stroke, self._stroke]) if n in [2, 3, 4, 5, 6]: svg_string += self._svg_circle(6, 6, 1.5) svg_string += self._svg_circle(19, 19, 1.5) if n in [1, 3, 5]: svg_string += self._svg_circle(12.5, 12.5, 1.5) if n in [4, 5, 6]: svg_string += self._svg_circle(19, 6, 1.5) svg_string += self._svg_circle(6, 19, 1.5) if n in [6]: svg_string += self._svg_circle(6, 12.5, 1.5) svg_string += self._svg_circle(19, 12.5, 1.5) svg_string += "</g>\n" return svg_string
svg_string += self._svg_circle(19, 6, 1.5) svg_string += self._svg_circle(6, 19, 1.5)
svg_string += self._svg_circle(19 + x, 6 + y, 1.5) svg_string += self._svg_circle(6 + x, 19 + y, 1.5)
def _svg_die(self, n, x, y): svg_string = "%s%f%s%f%s" % ("<g\n transform=\"translate(", x, ", ", y, "\">\n") self.set_stroke_width(1.5) self.set_colors([self._stroke, "none"]) svg_string += self._svg_rect(25, 25, 2, 2, 0, 0) self.set_stroke_width(2) self.set_colors([self._stroke, self._stroke]) if n in [2, 3, 4, 5, 6]: svg_string += self._svg_circle(6, 6, 1.5) svg_string += self._svg_circle(19, 19, 1.5) if n in [1, 3, 5]: svg_string += self._svg_circle(12.5, 12.5, 1.5) if n in [4, 5, 6]: svg_string += self._svg_circle(19, 6, 1.5) svg_string += self._svg_circle(6, 19, 1.5) if n in [6]: svg_string += self._svg_circle(6, 12.5, 1.5) svg_string += self._svg_circle(19, 12.5, 1.5) svg_string += "</g>\n" return svg_string
svg_string += self._svg_circle(6, 12.5, 1.5) svg_string += self._svg_circle(19, 12.5, 1.5) svg_string += "</g>\n"
svg_string += self._svg_circle(6 + x, 12.5 + y, 1.5) svg_string += self._svg_circle(19 + x, 12.5 + y, 1.5)
def _svg_die(self, n, x, y): svg_string = "%s%f%s%f%s" % ("<g\n transform=\"translate(", x, ", ", y, "\">\n") self.set_stroke_width(1.5) self.set_colors([self._stroke, "none"]) svg_string += self._svg_rect(25, 25, 2, 2, 0, 0) self.set_stroke_width(2) self.set_colors([self._stroke, self._stroke]) if n in [2, 3, 4, 5, 6]: svg_string += self._svg_circle(6, 6, 1.5) svg_string += self._svg_circle(19, 19, 1.5) if n in [1, 3, 5]: svg_string += self._svg_circle(12.5, 12.5, 1.5) if n in [4, 5, 6]: svg_string += self._svg_circle(19, 6, 1.5) svg_string += self._svg_circle(6, 19, 1.5) if n in [6]: svg_string += self._svg_circle(6, 12.5, 1.5) svg_string += self._svg_circle(19, 12.5, 1.5) svg_string += "</g>\n" return svg_string
self.set_stroke_width(1.8)
self._set_stroke_width(1.8)
def _svg_star(self, n, x, y): turntable = {5:3, 7:3, 11:5} turns = turntable[n] x1 = 0 y1 = 0 a = 0 svg_string = "%s%f%s%f%s" % ("<g\n transform=\"translate(", x, ", ", y, ")\">\n") self.set_stroke_width(1.8) for i in range(n * turns): x2 = x1 + sin(a) * 40 y2 = y1 + cos(a) * 40 svg_string += self._svg_line(x1, y1, x2, y2) x1 = x2 y1 = y2 a += turns * 2 * pi / n svg_string += "</g>\n" return svg_string
self.set_colors([stroke, WHITE])
self._set_colors([stroke, WHITE])
def _svg_donut(self, x, style, stroke, fill): svg_string = "" if style == "none": self.set_colors([stroke, WHITE]) elif style == "gradient": self.set_colors([stroke, fill]) else: self.set_colors([stroke, stroke]) svg_string += self._svg_circle(x + 17, 38, 16) self.set_colors([stroke, fill]) svg_string += self._svg_circle(x + 17, 38, 8) return svg_string
self.set_colors([stroke, fill]) else: self.set_colors([stroke, stroke])
self._set_colors([stroke, fill]) else: self._set_colors([stroke, stroke])
def _svg_donut(self, x, style, stroke, fill): svg_string = "" if style == "none": self.set_colors([stroke, WHITE]) elif style == "gradient": self.set_colors([stroke, fill]) else: self.set_colors([stroke, stroke]) svg_string += self._svg_circle(x + 17, 38, 16) self.set_colors([stroke, fill]) svg_string += self._svg_circle(x + 17, 38, 8) return svg_string
self.set_colors([stroke, fill])
self._set_colors([stroke, fill])
def _svg_donut(self, x, style, stroke, fill): svg_string = "" if style == "none": self.set_colors([stroke, WHITE]) elif style == "gradient": self.set_colors([stroke, fill]) else: self.set_colors([stroke, stroke]) svg_string += self._svg_circle(x + 17, 38, 16) self.set_colors([stroke, fill]) svg_string += self._svg_circle(x + 17, 38, 8) return svg_string
self.set_stroke_width(1.8)
self._set_stroke_width(1.8)
def _svg_bar(self, x, y): self.set_stroke_width(1.8) svg_string = " <rect\n" svg_string += " width=\"%f\"\n" % (40) svg_string += " height=\"%f\"\n" % (5) svg_string += " x=\"%f\"\n" % (x) svg_string += " y=\"%f\"\n" % (y) svg_string += self._svg_style() return svg_string
def header(self):
def _header(self):
def header(self): svg_string = "<?xml version=\"1.0\" encoding=\"UTF-8\"" svg_string += " standalone=\"no\"?>\n" svg_string += "<!-- Created with Emacs -->\n" svg_string += "<svg\n" svg_string += " xmlns:svg=\"http://www.w3.org/2000/svg\"\n" svg_string += " xmlns=\"http://www.w3.org/2000/svg\"\n" svg_string += " version=\"1.0\"\n" svg_string += "%s%f%s" % (" width=\"", 125 * self._scale, "\"\n") svg_string += "%s%f%s" % (" height=\"", 75 * self._scale, "\">\n") svg_string += "%s%f%s%f%s" % ("<g\n transform=\"matrix(", self._scale, ", 0, 0, ", self._scale, ", 0, 0)\">\n") svg_string += self._background() return svg_string
def footer(self):
def _footer(self):
def footer(self): svg_string = "</g>\n" svg_string += "</svg>\n" return svg_string
def set_font(self, font='DejaVu'):
def _set_font(self, font='DejaVu'):
def set_font(self, font='DejaVu'): self._font = font
def set_scale(self, scale=1.0):
def _set_scale(self, scale=1.0):
def set_scale(self, scale=1.0): self._scale = scale
def set_colors(self, colors):
def _set_colors(self, colors):
def set_colors(self, colors): self._stroke = colors[0] self._fill = colors[1]
def set_stroke_width(self, stroke_width=1.8):
def _set_stroke_width(self, stroke_width=1.8):
def set_stroke_width(self, stroke_width=1.8): self._stroke_width = stroke_width
def smiley(self): self.set_font("DejaVu")
def _smiley(self): self._set_font("DejaVu")
def smiley(self): self.set_font("DejaVu") return self._svg_text(63.5, 63.5, 72, "", '☻')
def number_incan(self, n):
def _number_incan(self, number):
def number_incan(self, n): x = 20 y = 30 # print "number incan: %d" % (n) svg_string = self._svg_quipu(int(n / 10), x, y) x = 40 svg_string += self._svg_quipu(n % 10, x, y) return svg_string
svg_string = self._svg_quipu(int(n / 10), x, y)
svg_string = self._svg_quipu(int(number / 10), x, y)
def number_incan(self, n): x = 20 y = 30 # print "number incan: %d" % (n) svg_string = self._svg_quipu(int(n / 10), x, y) x = 40 svg_string += self._svg_quipu(n % 10, x, y) return svg_string
svg_string += self._svg_quipu(n % 10, x, y) return svg_string def number_mayan(self, n):
svg_string += self._svg_quipu(number % 10, x, y) return svg_string def _number_mayan(self, number):
def number_incan(self, n): x = 20 y = 30 # print "number incan: %d" % (n) svg_string = self._svg_quipu(int(n / 10), x, y) x = 40 svg_string += self._svg_quipu(n % 10, x, y) return svg_string
if n == 5:
if number == 5:
def number_mayan(self, n): x = 42.5 x1, x2, xc, x3, x4 = x + 5, x + 15, x + 20, x + 25, x + 35 y = 60 y1s, y5s, y10s, y20s = y, y - 10, y - 20, y - 40 if n == 5: svg_string = self._svg_bar(x, y1s) elif n == 7: svg_string = self._svg_bar(x, y1s) svg_string += self._svg_circle(x2, y5s, 3) svg_string += self._svg_circle(x3, y5s, 3) elif n == 10: svg_string = self._svg_bar(x, y1s) svg_string += self._svg_bar(x, y5s) elif n == 11: svg_string = self._svg_bar(x, y1s) svg_string += self._svg_bar(x, y5s) svg_string += self._svg_circle(x+20, y10s, 3) elif n == 14: svg_string = self._svg_bar(x, y1s) svg_string += self._svg_bar(x, y5s) svg_string += self._svg_circle(x1, y10s, 3) svg_string += self._svg_circle(x2, y10s, 3) svg_string += self._svg_circle(x3, y10s, 3) svg_string += self._svg_circle(x4, y10s, 3) elif n == 15: svg_string = self._svg_bar(x, y1s) svg_string += self._svg_bar(x, y5s) svg_string += self._svg_bar(x, y10s) elif n == 21: svg_string = self._svg_circle(xc, y1s, 3) svg_string += self._svg_circle(xc, y20s, 3) elif n == 22: svg_string = self._svg_circle(x2, y1s, 3) svg_string += self._svg_circle(x3, y1s, 3) svg_string += self._svg_circle(xc, y20s, 3) elif n == 33: svg_string = self._svg_bar(x, y1s) svg_string += self._svg_bar(x, y5s) svg_string += self._svg_circle(x1, y10s, 3) svg_string += self._svg_circle(xc, y10s, 3) svg_string += self._svg_circle(x4, y10s, 3) svg_string += self._svg_circle(xc, y20s, 3) return svg_string
elif n == 7:
elif number == 7:
def number_mayan(self, n): x = 42.5 x1, x2, xc, x3, x4 = x + 5, x + 15, x + 20, x + 25, x + 35 y = 60 y1s, y5s, y10s, y20s = y, y - 10, y - 20, y - 40 if n == 5: svg_string = self._svg_bar(x, y1s) elif n == 7: svg_string = self._svg_bar(x, y1s) svg_string += self._svg_circle(x2, y5s, 3) svg_string += self._svg_circle(x3, y5s, 3) elif n == 10: svg_string = self._svg_bar(x, y1s) svg_string += self._svg_bar(x, y5s) elif n == 11: svg_string = self._svg_bar(x, y1s) svg_string += self._svg_bar(x, y5s) svg_string += self._svg_circle(x+20, y10s, 3) elif n == 14: svg_string = self._svg_bar(x, y1s) svg_string += self._svg_bar(x, y5s) svg_string += self._svg_circle(x1, y10s, 3) svg_string += self._svg_circle(x2, y10s, 3) svg_string += self._svg_circle(x3, y10s, 3) svg_string += self._svg_circle(x4, y10s, 3) elif n == 15: svg_string = self._svg_bar(x, y1s) svg_string += self._svg_bar(x, y5s) svg_string += self._svg_bar(x, y10s) elif n == 21: svg_string = self._svg_circle(xc, y1s, 3) svg_string += self._svg_circle(xc, y20s, 3) elif n == 22: svg_string = self._svg_circle(x2, y1s, 3) svg_string += self._svg_circle(x3, y1s, 3) svg_string += self._svg_circle(xc, y20s, 3) elif n == 33: svg_string = self._svg_bar(x, y1s) svg_string += self._svg_bar(x, y5s) svg_string += self._svg_circle(x1, y10s, 3) svg_string += self._svg_circle(xc, y10s, 3) svg_string += self._svg_circle(x4, y10s, 3) svg_string += self._svg_circle(xc, y20s, 3) return svg_string
elif n == 10:
elif number == 10:
def number_mayan(self, n): x = 42.5 x1, x2, xc, x3, x4 = x + 5, x + 15, x + 20, x + 25, x + 35 y = 60 y1s, y5s, y10s, y20s = y, y - 10, y - 20, y - 40 if n == 5: svg_string = self._svg_bar(x, y1s) elif n == 7: svg_string = self._svg_bar(x, y1s) svg_string += self._svg_circle(x2, y5s, 3) svg_string += self._svg_circle(x3, y5s, 3) elif n == 10: svg_string = self._svg_bar(x, y1s) svg_string += self._svg_bar(x, y5s) elif n == 11: svg_string = self._svg_bar(x, y1s) svg_string += self._svg_bar(x, y5s) svg_string += self._svg_circle(x+20, y10s, 3) elif n == 14: svg_string = self._svg_bar(x, y1s) svg_string += self._svg_bar(x, y5s) svg_string += self._svg_circle(x1, y10s, 3) svg_string += self._svg_circle(x2, y10s, 3) svg_string += self._svg_circle(x3, y10s, 3) svg_string += self._svg_circle(x4, y10s, 3) elif n == 15: svg_string = self._svg_bar(x, y1s) svg_string += self._svg_bar(x, y5s) svg_string += self._svg_bar(x, y10s) elif n == 21: svg_string = self._svg_circle(xc, y1s, 3) svg_string += self._svg_circle(xc, y20s, 3) elif n == 22: svg_string = self._svg_circle(x2, y1s, 3) svg_string += self._svg_circle(x3, y1s, 3) svg_string += self._svg_circle(xc, y20s, 3) elif n == 33: svg_string = self._svg_bar(x, y1s) svg_string += self._svg_bar(x, y5s) svg_string += self._svg_circle(x1, y10s, 3) svg_string += self._svg_circle(xc, y10s, 3) svg_string += self._svg_circle(x4, y10s, 3) svg_string += self._svg_circle(xc, y20s, 3) return svg_string
elif n == 11:
elif number == 11:
def number_mayan(self, n): x = 42.5 x1, x2, xc, x3, x4 = x + 5, x + 15, x + 20, x + 25, x + 35 y = 60 y1s, y5s, y10s, y20s = y, y - 10, y - 20, y - 40 if n == 5: svg_string = self._svg_bar(x, y1s) elif n == 7: svg_string = self._svg_bar(x, y1s) svg_string += self._svg_circle(x2, y5s, 3) svg_string += self._svg_circle(x3, y5s, 3) elif n == 10: svg_string = self._svg_bar(x, y1s) svg_string += self._svg_bar(x, y5s) elif n == 11: svg_string = self._svg_bar(x, y1s) svg_string += self._svg_bar(x, y5s) svg_string += self._svg_circle(x+20, y10s, 3) elif n == 14: svg_string = self._svg_bar(x, y1s) svg_string += self._svg_bar(x, y5s) svg_string += self._svg_circle(x1, y10s, 3) svg_string += self._svg_circle(x2, y10s, 3) svg_string += self._svg_circle(x3, y10s, 3) svg_string += self._svg_circle(x4, y10s, 3) elif n == 15: svg_string = self._svg_bar(x, y1s) svg_string += self._svg_bar(x, y5s) svg_string += self._svg_bar(x, y10s) elif n == 21: svg_string = self._svg_circle(xc, y1s, 3) svg_string += self._svg_circle(xc, y20s, 3) elif n == 22: svg_string = self._svg_circle(x2, y1s, 3) svg_string += self._svg_circle(x3, y1s, 3) svg_string += self._svg_circle(xc, y20s, 3) elif n == 33: svg_string = self._svg_bar(x, y1s) svg_string += self._svg_bar(x, y5s) svg_string += self._svg_circle(x1, y10s, 3) svg_string += self._svg_circle(xc, y10s, 3) svg_string += self._svg_circle(x4, y10s, 3) svg_string += self._svg_circle(xc, y20s, 3) return svg_string
elif n == 14:
elif number == 14:
def number_mayan(self, n): x = 42.5 x1, x2, xc, x3, x4 = x + 5, x + 15, x + 20, x + 25, x + 35 y = 60 y1s, y5s, y10s, y20s = y, y - 10, y - 20, y - 40 if n == 5: svg_string = self._svg_bar(x, y1s) elif n == 7: svg_string = self._svg_bar(x, y1s) svg_string += self._svg_circle(x2, y5s, 3) svg_string += self._svg_circle(x3, y5s, 3) elif n == 10: svg_string = self._svg_bar(x, y1s) svg_string += self._svg_bar(x, y5s) elif n == 11: svg_string = self._svg_bar(x, y1s) svg_string += self._svg_bar(x, y5s) svg_string += self._svg_circle(x+20, y10s, 3) elif n == 14: svg_string = self._svg_bar(x, y1s) svg_string += self._svg_bar(x, y5s) svg_string += self._svg_circle(x1, y10s, 3) svg_string += self._svg_circle(x2, y10s, 3) svg_string += self._svg_circle(x3, y10s, 3) svg_string += self._svg_circle(x4, y10s, 3) elif n == 15: svg_string = self._svg_bar(x, y1s) svg_string += self._svg_bar(x, y5s) svg_string += self._svg_bar(x, y10s) elif n == 21: svg_string = self._svg_circle(xc, y1s, 3) svg_string += self._svg_circle(xc, y20s, 3) elif n == 22: svg_string = self._svg_circle(x2, y1s, 3) svg_string += self._svg_circle(x3, y1s, 3) svg_string += self._svg_circle(xc, y20s, 3) elif n == 33: svg_string = self._svg_bar(x, y1s) svg_string += self._svg_bar(x, y5s) svg_string += self._svg_circle(x1, y10s, 3) svg_string += self._svg_circle(xc, y10s, 3) svg_string += self._svg_circle(x4, y10s, 3) svg_string += self._svg_circle(xc, y20s, 3) return svg_string
elif n == 15:
elif number == 15:
def number_mayan(self, n): x = 42.5 x1, x2, xc, x3, x4 = x + 5, x + 15, x + 20, x + 25, x + 35 y = 60 y1s, y5s, y10s, y20s = y, y - 10, y - 20, y - 40 if n == 5: svg_string = self._svg_bar(x, y1s) elif n == 7: svg_string = self._svg_bar(x, y1s) svg_string += self._svg_circle(x2, y5s, 3) svg_string += self._svg_circle(x3, y5s, 3) elif n == 10: svg_string = self._svg_bar(x, y1s) svg_string += self._svg_bar(x, y5s) elif n == 11: svg_string = self._svg_bar(x, y1s) svg_string += self._svg_bar(x, y5s) svg_string += self._svg_circle(x+20, y10s, 3) elif n == 14: svg_string = self._svg_bar(x, y1s) svg_string += self._svg_bar(x, y5s) svg_string += self._svg_circle(x1, y10s, 3) svg_string += self._svg_circle(x2, y10s, 3) svg_string += self._svg_circle(x3, y10s, 3) svg_string += self._svg_circle(x4, y10s, 3) elif n == 15: svg_string = self._svg_bar(x, y1s) svg_string += self._svg_bar(x, y5s) svg_string += self._svg_bar(x, y10s) elif n == 21: svg_string = self._svg_circle(xc, y1s, 3) svg_string += self._svg_circle(xc, y20s, 3) elif n == 22: svg_string = self._svg_circle(x2, y1s, 3) svg_string += self._svg_circle(x3, y1s, 3) svg_string += self._svg_circle(xc, y20s, 3) elif n == 33: svg_string = self._svg_bar(x, y1s) svg_string += self._svg_bar(x, y5s) svg_string += self._svg_circle(x1, y10s, 3) svg_string += self._svg_circle(xc, y10s, 3) svg_string += self._svg_circle(x4, y10s, 3) svg_string += self._svg_circle(xc, y20s, 3) return svg_string
elif n == 21:
elif number == 21:
def number_mayan(self, n): x = 42.5 x1, x2, xc, x3, x4 = x + 5, x + 15, x + 20, x + 25, x + 35 y = 60 y1s, y5s, y10s, y20s = y, y - 10, y - 20, y - 40 if n == 5: svg_string = self._svg_bar(x, y1s) elif n == 7: svg_string = self._svg_bar(x, y1s) svg_string += self._svg_circle(x2, y5s, 3) svg_string += self._svg_circle(x3, y5s, 3) elif n == 10: svg_string = self._svg_bar(x, y1s) svg_string += self._svg_bar(x, y5s) elif n == 11: svg_string = self._svg_bar(x, y1s) svg_string += self._svg_bar(x, y5s) svg_string += self._svg_circle(x+20, y10s, 3) elif n == 14: svg_string = self._svg_bar(x, y1s) svg_string += self._svg_bar(x, y5s) svg_string += self._svg_circle(x1, y10s, 3) svg_string += self._svg_circle(x2, y10s, 3) svg_string += self._svg_circle(x3, y10s, 3) svg_string += self._svg_circle(x4, y10s, 3) elif n == 15: svg_string = self._svg_bar(x, y1s) svg_string += self._svg_bar(x, y5s) svg_string += self._svg_bar(x, y10s) elif n == 21: svg_string = self._svg_circle(xc, y1s, 3) svg_string += self._svg_circle(xc, y20s, 3) elif n == 22: svg_string = self._svg_circle(x2, y1s, 3) svg_string += self._svg_circle(x3, y1s, 3) svg_string += self._svg_circle(xc, y20s, 3) elif n == 33: svg_string = self._svg_bar(x, y1s) svg_string += self._svg_bar(x, y5s) svg_string += self._svg_circle(x1, y10s, 3) svg_string += self._svg_circle(xc, y10s, 3) svg_string += self._svg_circle(x4, y10s, 3) svg_string += self._svg_circle(xc, y20s, 3) return svg_string
elif n == 22:
elif number == 22:
def number_mayan(self, n): x = 42.5 x1, x2, xc, x3, x4 = x + 5, x + 15, x + 20, x + 25, x + 35 y = 60 y1s, y5s, y10s, y20s = y, y - 10, y - 20, y - 40 if n == 5: svg_string = self._svg_bar(x, y1s) elif n == 7: svg_string = self._svg_bar(x, y1s) svg_string += self._svg_circle(x2, y5s, 3) svg_string += self._svg_circle(x3, y5s, 3) elif n == 10: svg_string = self._svg_bar(x, y1s) svg_string += self._svg_bar(x, y5s) elif n == 11: svg_string = self._svg_bar(x, y1s) svg_string += self._svg_bar(x, y5s) svg_string += self._svg_circle(x+20, y10s, 3) elif n == 14: svg_string = self._svg_bar(x, y1s) svg_string += self._svg_bar(x, y5s) svg_string += self._svg_circle(x1, y10s, 3) svg_string += self._svg_circle(x2, y10s, 3) svg_string += self._svg_circle(x3, y10s, 3) svg_string += self._svg_circle(x4, y10s, 3) elif n == 15: svg_string = self._svg_bar(x, y1s) svg_string += self._svg_bar(x, y5s) svg_string += self._svg_bar(x, y10s) elif n == 21: svg_string = self._svg_circle(xc, y1s, 3) svg_string += self._svg_circle(xc, y20s, 3) elif n == 22: svg_string = self._svg_circle(x2, y1s, 3) svg_string += self._svg_circle(x3, y1s, 3) svg_string += self._svg_circle(xc, y20s, 3) elif n == 33: svg_string = self._svg_bar(x, y1s) svg_string += self._svg_bar(x, y5s) svg_string += self._svg_circle(x1, y10s, 3) svg_string += self._svg_circle(xc, y10s, 3) svg_string += self._svg_circle(x4, y10s, 3) svg_string += self._svg_circle(xc, y20s, 3) return svg_string
elif n == 33:
elif number == 33:
def number_mayan(self, n): x = 42.5 x1, x2, xc, x3, x4 = x + 5, x + 15, x + 20, x + 25, x + 35 y = 60 y1s, y5s, y10s, y20s = y, y - 10, y - 20, y - 40 if n == 5: svg_string = self._svg_bar(x, y1s) elif n == 7: svg_string = self._svg_bar(x, y1s) svg_string += self._svg_circle(x2, y5s, 3) svg_string += self._svg_circle(x3, y5s, 3) elif n == 10: svg_string = self._svg_bar(x, y1s) svg_string += self._svg_bar(x, y5s) elif n == 11: svg_string = self._svg_bar(x, y1s) svg_string += self._svg_bar(x, y5s) svg_string += self._svg_circle(x+20, y10s, 3) elif n == 14: svg_string = self._svg_bar(x, y1s) svg_string += self._svg_bar(x, y5s) svg_string += self._svg_circle(x1, y10s, 3) svg_string += self._svg_circle(x2, y10s, 3) svg_string += self._svg_circle(x3, y10s, 3) svg_string += self._svg_circle(x4, y10s, 3) elif n == 15: svg_string = self._svg_bar(x, y1s) svg_string += self._svg_bar(x, y5s) svg_string += self._svg_bar(x, y10s) elif n == 21: svg_string = self._svg_circle(xc, y1s, 3) svg_string += self._svg_circle(xc, y20s, 3) elif n == 22: svg_string = self._svg_circle(x2, y1s, 3) svg_string += self._svg_circle(x3, y1s, 3) svg_string += self._svg_circle(xc, y20s, 3) elif n == 33: svg_string = self._svg_bar(x, y1s) svg_string += self._svg_bar(x, y5s) svg_string += self._svg_circle(x1, y10s, 3) svg_string += self._svg_circle(xc, y10s, 3) svg_string += self._svg_circle(x4, y10s, 3) svg_string += self._svg_circle(xc, y20s, 3) return svg_string
def dots_in_a_line(self, n): if n % 3 == 0:
def _dots_in_a_line(self, number): if number % 3 == 0:
def dots_in_a_line(self, n): if n % 3 == 0: y = 12.5 nn = n / 3 elif n % 2 == 0: y = 22.5 nn = n / 2 else: y = 32.5 nn = n if n % 5 == 0: n /= 5 elif n % 7 == 0: n /= 7 else: n /= 11 svg_string = "" for i in range(n): svg_string += self._svg_line_of_dots(nn, 5, y) y += 20 return svg_string
nn = n / 3 elif n % 2 == 0:
n = number / 3 elif number % 2 == 0:
def dots_in_a_line(self, n): if n % 3 == 0: y = 12.5 nn = n / 3 elif n % 2 == 0: y = 22.5 nn = n / 2 else: y = 32.5 nn = n if n % 5 == 0: n /= 5 elif n % 7 == 0: n /= 7 else: n /= 11 svg_string = "" for i in range(n): svg_string += self._svg_line_of_dots(nn, 5, y) y += 20 return svg_string