def show_main_menu(f1, f2, f3): global menu_title global menu_subti global menu_calls global menu_items global menu_titbg global menu_chars global menu_visib global menu_runan menu_runan = 0 menu_visib = True menu_titbg = shape.Shape(PATH_MENU_TIT_BG, "", "", 0, 235, 1, 1) menu_title = label.Label("TURTLE RACE", colors.get("title"), 0, 250, 48) menu_subti = label.Label("THE BEST BETTING GAME", colors.get("subti"), 150, 200, 18) menu_calls = [f1, f2, f3] menu_items = [ button.Button(" START ", 0, 30, callback1), button.Button(" SETTINGS ", 0, -30, callback2), button.Button(" ABOUT ", 0, -90, callback3), button.Button(" EXIT ", 0, -150, callback4) ] menu_chars = [ shape.Shape(PATH_MENU_CHAR1[0], "", "", 0, 350, 1, 1), shape.Shape(PATH_MENU_CHAR2[0], "", "", -400, 200, 1, 1), shape.Shape(PATH_MENU_CHAR3[0], "", "", 400, 0, 1, 1), shape.Shape(PATH_MENU_CHAR4[0], "", "", -300, -200, 1, 1), shape.Shape(PATH_MENU_CHAR5[0], "", "", 300, -200, 1, 1), ] menu_char_anim()
def set_colors(*colordef): l = list(colordef) defs = {} while len(l) > 0: key_target = l.pop(0).split(",") col = l.pop(0) for tgt in key_target: if tgt == '--': # special: applies color to all yet unused colors for keycode in keys.others(defs.keys()): defs[keycode] = colors.get(col) for keycode in keys.get(tgt): if keycode is None: continue defs[keycode] = colors.get(col) if len(defs) == 0: raise Exception("could not determine any color definitions") COLOR_PAYLOAD = [] for keycode, color in defs.items(): COLOR_PAYLOAD += [keycode] COLOR_PAYLOAD += color with device.Device() as dev: dev.send_colors(COLOR_PAYLOAD)
def show_about(): global about_title global about_text global about_btn about_title = label.Label("ABOUT", colors.get("subti"), 0, 150, 36) about_text = [] about_text.append( label.Label( "Turtle race is a betting game and designed for single player.", colors.get("fg"), 0, 100)) about_text.append( label.Label( "As long as posible, you can play this game for 1000 minutes, or 1000 years... ", colors.get("fg"), 0, about_text[0].get_y() - 30)) about_text.append( label.Label("The first, it was made for the mid-term project.", colors.get("fg"), 0, about_text[1].get_y() - 30)) about_text.append( label.Label( "You can download the source from github, don't worry about the license, it's FREE.", colors.get("fg"), 0, about_text[2].get_y() - 30)) about_text.append( label.Label( "Developer: Thai Chi Cuong, Tran Nguyen Quynh Anh, Dinh Le Trieu Duong, Phan Vo Minh Huy, Nguyen Hoang Huy.", colors.get("fg"), 0, about_text[3].get_y() - 30)) about_text.append( label.Label("Designer: Tran Nguyen Quynh Anh.", colors.get("fg"), 0, about_text[4].get_y() - 30)) about_btn = button.Button("BACK TO MAIN MENU", 0, -150, about_btn_callback) about_btn.use_enter()
def __init__(self, x, y, default_val, number_only = False): self.__selected = False self.__edited = False self.__default_val = default_val self.__string = str(self.__default_val) self.__entry = shape.Shape("square", colors.get("borders"), colors.get("borders"), x, y - 14, self.DEFAULT_WIDTH, 1, 0) self.__text = label.Label(self.__string, colors.get("fg"), x, y, self.DEFAULT_FONT_SIZE) self.__number_only = number_only self.__top_left = [ x - (self.DEFAULT_WIDTH / 2), y + (self.DEFAULT_HEIGHT / 2)] self.__bot_right = [ x + (self.DEFAULT_WIDTH / 2), y - (self.DEFAULT_HEIGHT / 2)] muievent.bind_click(self.__checkclick) muievent.bind_key(self.__checkkeypress)
def show_table(): global lead_table global lead_btn global list_char if (is_winner()): setup.play_music("res/ad/Winner.mp3") lead_table = board.Board("YOU WIN", 0, 9, 3) else: setup.play_music("res/ad/Loser.mp3") lead_table = board.Board("YOU LOSE", 0, 9, 3) list_char.sort(key=lambda k: k.time) lead_table.set_color(0, 0, colors.get("title")) lead_table.set_text(0, 0, "NAME", 24) lead_table.set_color(0, 1, colors.get("title")) lead_table.set_text(0, 1, "TIME", 24) lead_table.set_color(0, 2, colors.get("title")) lead_table.set_text(0, 2, "WIN/LOSE", 24) for i in range(1, 6): lead_table.set_color(i, 0, list_char[i - 1].color) lead_table.set_text(i, 0, list_char[i - 1].name) lead_table.set_color(i, 1, list_char[i - 1].color) lead_table.set_text(i, 1, list_char[i - 1].time) lead_table.set_color(i, 2, list_char[i - 1].color) lead_table.set_text( i, 2, str(list_char[i - 1].win) + "/" + str(list_char[i - 1].lose)) lead_table.update() lead_btn = button.Button("BACK TO MAIN MENU", 0, -200, lead_btn_callback) lead_btn.use_enter() show_piechart()
def show_settings(): global set_title global set_edname global set_edwid global set_edhei global set_savebtn set_title = label.Label("SETTINGS", colors.get("subti"), 0, 150, 36) set_edname = lineedit.LineEdit(0, 60, config.player_name) set_edwid = lineedit.LineEdit(0, 0, config.road_width, True) set_edhei = lineedit.LineEdit(0, -60, config.road_height, True) set_savebtn = button.Button("SAVE AND BACK", 0, -150, set_savebtn_callback) set_savebtn.use_enter()
def __init__(self, y, cols, width): self.__labels = [] self.__icons = [] self.__width = width self.__cols = cols self.__perx = self.__width / (self.__cols - 1) self.__x = -((self.__width) / 2) self.__y = y for i in range(self.__cols): self.__labels.append( label.Label("", colors.get("lead_fg"), self.__x, self.__y)) self.__labels[i].align("center") self.__x += self.__perx
def showPartitions(points, partitioning, image = None, output = "partitions.jpg") : max_x = numpy.max(points[:,0]) max_y = numpy.max(points[:,1]) cs = colors.get() pylab.gray() if image != None : pylab.imshow(image) pylab.xlim(0,image.shape[1]) pylab.ylim(image.shape[0],0) else : pylab.xlim(0,max_y*1.1) pylab.ylim(0,max_x*1.1) for pos,p in zip(points, partitioning) : pylab.plot(pos[0], pos[1], color=cs[p], marker='o') pylab.axis('off') pylab.savefig(output, bbox_inches='tight')
def parse(cls, color, alpha ): """ Color parsing """ if color is None: return if isinstance(color, str): # Named color if color[0] != '#': color = color.lower().strip() color = color.replace(' ','') color = color.replace('-','') color = _colors.get(color) if color[0] != '#': log.warn("Unknown color name : %s" % color) return 0,0,0,1 # Hexadecimal color color = color[1:] if len(color) == 3: color += 'f' if len(color) == 4: color = ''.join([color[i] for i in [0,0,1,1,2,2,3,3]]) if len(color) == 6: color += 'ff' r,g,b,a = [ord(c)/255.0 for c in color.decode('hex')] if alpha is not None: a = alpha return r,g,b,a # Tuple/list/array color elif isinstance(color, (list, tuple, np.ndarray)): color = np.clip(color, 0, 1) if alpha is not None: color[3] = alpha return color # Unknown format else: log.warn("Unknown color format : %s" % color) return 0,0,0,1
def parse(cls, color, alpha): """ Color parsing """ if color is None: return if isinstance(color, str): # Named color if color[0] != '#': color = color.lower().strip() color = color.replace(' ', '') color = color.replace('-', '') color = _colors.get(color) if color[0] != '#': log.warn("Unknown color name : %s" % color) return 0, 0, 0, 1 # Hexadecimal color color = color[1:] if len(color) == 3: color += 'f' if len(color) == 4: color = ''.join([color[i] for i in [0, 0, 1, 1, 2, 2, 3, 3]]) if len(color) == 6: color += 'ff' r, g, b, a = [ord(c) / 255.0 for c in color.decode('hex')] if alpha is not None: a = alpha return r, g, b, a # Tuple/list/array color elif isinstance(color, (list, tuple, np.ndarray)): color = np.clip(color, 0, 1) if alpha is not None: color[3] = alpha return color # Unknown format else: log.warn("Unknown color format : %s" % color) return 0, 0, 0, 1
def __init__(self, colors=[], count=0, alpha=None): """ Colors initialization Parameters ---------- colors : list List of color names or values count : int Number of colors alpha : float Alpha channels """ if isinstance(colors, str): if colors[0] != '#': colors = _colors.get(colors) if isinstance(colors, str): colors = [colors] if len(colors) > 0: n = len(colors) self._data = np.zeros((n, 4), dtype=np.float32) for i in range(n): self._data[i] = Color(colors[i]).rgba elif count > 0: self._data = np.zeros((count, 4), dtype=np.float32) else: log.warn("Colors must be declared with a list or a color count") self._data = np.zeros((1, 4), dtype=np.float32) if alpha is not None: self._data[:, 3] = alpha
def __init__(self, colors=[], count=0, alpha=None): """ Colors initialization Parameters ---------- colors : list List of color names or values count : int Number of colors alpha : float Alpha channels """ if isinstance(colors, str): if colors[0] != '#': colors = _colors.get(colors) if isinstance(colors, str): colors = [colors] if len(colors) > 0: n = len(colors) self._data = np.zeros((n,4),dtype=np.float32) for i in range(n): self._data[i] = Color(colors[i]).rgba elif count > 0: self._data = np.zeros((count,4),dtype=np.float32) else: log.warn("Colors must be declared with a list or a color count") self._data = np.zeros((1,4),dtype=np.float32) if alpha is not None: self._data[:,3] = alpha
def __checkclick(self, event): mouse_x = event.x - (turtle.window_width() / 2) mouse_y = (turtle.window_height() / 2) - event.y if (self.__is_hover(mouse_x, mouse_y)): if (not self.__selected): self.__selected = True if (not self.__edited): self.__string = "" self.__string += "|" self.__entry.set_color(colors.get("selected_bg"), colors.get("selected_bg")) self.__text.set_text(self.__string) self.__text.set_color(colors.get("selected_bg")) self.__text.update() elif (self.__selected): self.__selected = False if (not self.__edited): self.__string = self.__default_val else: self.__string = self.__string[:-1] self.__entry.set_color(colors.get("borders"), colors.get("borders")) self.__text.set_color(colors.get("fg")) self.__text.set_text(self.__string) self.__text.update()
def __color_by_state(self): self.__label.set_color(colors.get(self.__state + "_fg")) self.__label.update()
def set_icon(self, col, icon): self.__icons.append( shape.Shape(icon, colors.get("lead_border"), colors.get("lead_bg"), self.__labels[col].get_x() - 32, self.__y, 32, 32, 1))
def show_class(): #CONFIG DEFAULT VALUE config.player_class = "Fox" config.player_color = "Orange" path_icon = [ "res/img/Avt/Green/Cat.gif", #Cat "res/img/Avt/Blue/Dog.gif", #Dog "res/img/Avt/Pink/Chicken.gif", #Chicken "res/img/Avt/Orange/Fox.gif", #Fox "res/img/Avt/Gray/Pig.gif" ] #Pig for path in path_icon: turtle.Screen().addshape(path) ccolors = ["green", "blue", "pink", "orange", "gray"] global cclass_preview global cclass_title global cclass_items global cclass_colors cclass_title = label.Label("CHOOSE CLASS", colors.get("subti"), 0, 200, 36) cclass_items = [] cclass_colors = [] cclass_items.append( shape.Shape(path_icon[0], "", "white", 168, 100, 64, 64)) cclass_items.append(shape.Shape(path_icon[1], "", "white", 84, 100, 64, 64)) cclass_items.append(shape.Shape(path_icon[2], "", "white", 0, 100, 64, 64)) cclass_items.append( shape.Shape(path_icon[3], "", "white", -84, 100, 64, 64)) cclass_items.append( shape.Shape(path_icon[4], "", "white", -168, 100, 64, 64)) cclass_preview = shape.Shape(path_icon[0], "", ccolors[0], 0, 0, 64, 64) config.player_class = "Cat" config.player_color = "Green" cclass_items[0].onclick(click_cat) cclass_items[1].onclick(click_dog) cclass_items[2].onclick(click_chicken) cclass_items[3].onclick(click_fox) cclass_items[4].onclick(click_pig) cclass_colors.append( shape.Shape("square", "", ccolors[0], -168, -100, 64, 64)) cclass_colors.append( shape.Shape("square", "", ccolors[1], -84, -100, 64, 64)) cclass_colors.append(shape.Shape("square", "", ccolors[2], 0, -100, 64, 64)) cclass_colors.append( shape.Shape("square", "", ccolors[3], 84, -100, 64, 64)) cclass_colors.append( shape.Shape("square", "", ccolors[4], 168, -100, 64, 64)) cclass_colors[0].onclick(click_green) cclass_colors[1].onclick(click_blue) cclass_colors[2].onclick(click_pink) cclass_colors[3].onclick(click_orange) cclass_colors[4].onclick(click_gray)
# -*- coding: utf-8 -*- import dash import dash_core_components as dcc import dash_html_components as html import scraper as scrap import colors as colors colors = colors.get() # getting data from scraping module data = scrap.get_data() data['percentage D/C'] = data['Total Deaths']/data['Total Cases']*100 data_europe_est = data[data['Continent'] == "Europe de l'est"][:10] data_europe_ouest = data[data['Continent'] == "Europe de l'ouest"][:10] data_amerique = data[data['Continent'] == 'Amerique'][:10] data_oceanie = data[data['Continent'] == 'Oceanie'] data_afrique = data[data['Continent'] == 'Afrique'][:10] data_asie = data[data['Continent'] == 'Asie'][:10] data_asie_occ = data[data['Continent'] == 'Asie occidentale'][:10] data_autre = data[data['Continent'] == 'Autres'] def get_content(): return html.Div([ html.Div([ html.Div([ # Total Cases europe de l'est dcc.Graph( id='total-cases-europe-est', figure={ 'data': [
def __draw_title(self): title_color = colors.get("lead_title_fg") if (self.__title_text is "YOU WIN"): title_color = "#AAFF50" self.__title = label.Label(self.__title_text, title_color, 0, 250, 72)