def set_password(self): """Set the master password used to encrypt the mailbox config files.""" def ok(event=None): pwd = getpwd.get() pwd2 = confpwd.get() if pwd == pwd2: # passwords match cryptedpwd = crypt.crypt(pwd, crypt.mksalt(crypt.METHOD_SHA512)) with open(os.path.join(LOCAL_PATH, '.pwd'), "w") as fich: fich.write(cryptedpwd) top.destroy() self.pwd = pwd logging.info('New password set') else: showerror(_('Error'), _('Passwords do not match!')) top = Toplevel(self, class_="CheckMails") top.iconphoto(True, self.im_icon) top.title(_("Set password")) top.resizable(False, False) Label(top, text=_("Enter master password")).pack(padx=10, pady=(4, 10)) getpwd = Entry(top, show='*', justify='center') getpwd.pack(padx=10, pady=4) Label(top, text=_("Confirm master password")).pack(padx=10, pady=4) confpwd = Entry(top, show='*', justify='center') confpwd.pack(padx=10, pady=4) Button(top, text="Ok", command=ok).pack(padx=10, pady=(4, 10)) confpwd.bind("<Key-Return>", ok) getpwd.focus_set() self.wait_window(top)
def parameters(Liste_ecussons): DW = int((fenetremain.winfo_screenwidth())) DH = int((fenetremain.winfo_screenheight())) fenetre_parameters = Toplevel(fenetremain) fenetre_parameters.title("Paramètres") fenetre_parameters.geometry(f'1280x720+{DW//6}+{DH//6}') fenetre_parameters.resizable(0, 0) fenetre_parameters.transient(fenetremain) fenetre_parameters.iconphoto(False, PhotoImage(file='images/icones/root_icone.png')) background_image_param = PhotoImage(file = r"images/backgrounds/settings.png") canparam= Canvas(fenetre_parameters, width = 1280, height = 720) canparam.pack() canparam.create_image(0,0, image = background_image_param, anchor = tk.NW) # But_pic = hover_button(fenetre_parameters, text = "Download Players Pictures", font = main_menu_font,command = lambda:download_pic(Teams), width = 25, activebackground="#E8FFFF", activeforeground = "blue") # But_ecu = hover_button(fenetre_parameters, text = "Download Ecussons", font = main_menu_font,command = lambda: download_ecu(Liste_ecussons), width = 25, activebackground="#E8FFFF", activeforeground = "blue") # But_posi = hover_button(fenetre_parameters, text = "Update Players Positions", font = main_menu_font,command = updatePOS, width = 25, activebackground="#E8FFFF", activeforeground = "blue") But_data = hover_button(fenetre_parameters, text = "Update DATA FILES", font = main_menu_font,command = DataUpdate, width = 25, activebackground="#E8FFFF", activeforeground = "blue") But_data.place(relx=0.5, rely=0.4, anchor='center') But_learn = hover_button(fenetre_parameters, text = "Update Learning Model", font = main_menu_font,command = update_predic_model, width = 25, activebackground="#E8FFFF", activeforeground = "blue") But_learn.place(relx=0.5, rely=0.5, anchor='center') But_set_fav = hover_button(fenetre_parameters, text = "Actual Team to Fav Team", font = main_menu_font,command = set_new_fav, width = 25, activebackground="#E8FFFF", activeforeground = "blue") But_set_fav.place(relx=0.5, rely=0.6, anchor='center') fenetre_parameters.mainloop()
def onDisplayAuthorInfo(): def copy(widget): self.app.clipboard_clear() self.app.clipboard_append(widget.get(1.0, END)) self.app.update() def onCopyEmail(): return copy(email) def onCopyERC20(): return copy(erc20) def onCopyTRC20(): return copy(trc20) window_author_info = Toplevel(self.app) window_author_info.title("聯絡/贊助作者") window_author_info.geometry('400x300') try: window_author_info.iconphoto( False, PhotoImage(file='icon/doge_icon.png')) except: pass setUIToCenter(window_author_info, 400, 300) Label(window_author_info, text='Jason Huang', fg='blue').place(x=10, y=10) Label(window_author_info, text='立志轉職軟體工程師,熱衷研究幣圈投資', fg='blue').place(x=10, y=40) Label(window_author_info, text='若您覺得本軟體對您有幫助,歡迎小額贊助支持作者').place(x=10, y=70) ybase = 100 Label(window_author_info, text='聯絡信箱:', fg='red').place(x=10, y=ybase) email = Text(window_author_info, height=1, borderwidth=0) email.insert(1.0, EMAIL) email.place(x=10, y=ybase + 30) email.configure(state="disabled", bg=self.app.cget('bg')) Button(window_author_info, text='複製', command=onCopyEmail).place(x=120, y=ybase - 2) Label(window_author_info, text='USDT ERC20地址:', fg='red').place(x=10, y=ybase + 60) erc20 = Text(window_author_info, height=1, borderwidth=0) erc20.insert(1.0, ERC20) erc20.place(x=10, y=ybase + 90) erc20.configure(state="disabled", bg=self.app.cget('bg')) Button(window_author_info, text='複製', command=onCopyERC20).place(x=120, y=ybase + 58) Label(window_author_info, text='USDT TRC20地址:', fg='red').place(x=10, y=ybase + 120) trc20 = Text(window_author_info, height=1, borderwidth=0) trc20.insert(1.0, TRC20) trc20.place(x=10, y=ybase + 150) trc20.configure(state="disabled", bg=self.app.cget('bg')) Button(window_author_info, text='複製', command=onCopyTRC20).place(x=120, y=ybase + 118)
def change_password(self): """ Change the master password: decrypt all the mailbox config files using the old password and encrypt them with the new. """ def ok(event=None): with open(os.path.join(LOCAL_PATH, '.pwd')) as fich: cryptedpwd = fich.read() old = oldpwd.get() pwd = newpwd.get() pwd2 = confpwd.get() if crypt.crypt(old, cryptedpwd) == cryptedpwd: # passwords match if pwd == pwd2: # new passwords match cryptedpwd = crypt.crypt(pwd, crypt.mksalt(crypt.METHOD_SHA512)) with open(os.path.join(LOCAL_PATH, '.pwd'), "w") as fich: fich.write(cryptedpwd) mailboxes = CONFIG.get( "Mailboxes", "active").split(", ") + CONFIG.get( "Mailboxes", "inactive").split(", ") while "" in mailboxes: mailboxes.remove("") for mailbox in mailboxes: server, login, password, folder = decrypt(mailbox, old) if server is not None: encrypt(mailbox, pwd, server, login, password, folder) self.pwd = pwd top.destroy() logging.info('Password changed') return pwd else: showerror(_('Error'), _('Passwords do not match!')) else: showerror(_('Error'), _('Incorrect password!')) top = Toplevel(self, class_="CheckMails") top.iconphoto(True, self.im_icon) top.resizable(False, False) Label(top, text=_("Old password")).pack(padx=10, pady=(10, 4)) oldpwd = Entry(top, show='*', justify='center') oldpwd.pack(padx=10, pady=4) Label(top, text=_("New password")).pack(padx=10, pady=4) newpwd = Entry(top, show='*', justify='center') newpwd.pack(padx=10, pady=4) Label(top, text=_("Confirm password")).pack(padx=10, pady=4) confpwd = Entry(top, show='*', justify='center') confpwd.pack(padx=10, pady=4) Button(top, text="Ok", command=ok).pack(padx=10, pady=(4, 10)) confpwd.bind("<Key-Return>", ok) oldpwd.focus_set() self.wait_window(top)
class About: """Show about window.""" def __init__(self, parent): self.parent = parent self._setup_ui() self._setup_widgets() def _setup_ui(self): """About window toplevel.""" self.about = Toplevel() self.about.resizable(False, False) self.about.title(_("About")) self.about.transient(self.parent) # Set position TopLevel pos_x = self.parent.winfo_x() pos_y = self.parent.winfo_y() self.about.geometry("+%d+%d" % (pos_x + 200, pos_y + 200)) if sys.platform == "win32": self.about.iconbitmap(r"./assets/icon.ico") else: self.about.iconphoto(True, PhotoImage(file=r"./assets/icon.png")) def _setup_widgets(self): frame = Frame(self.about) frame.pack(pady=20, padx=40) title = Label(frame, text="Multiple Renaming", font=("sans-serif", 16)) title.pack() subtitle = Label(frame, text="File renaming utility.", font=("sans-serif", 12)) subtitle.pack() version_text = f"Version {versions.__version__}" version = Label(frame, text=version_text) version.pack() link_lbl = Label(frame, text="Website", fg="blue", cursor="hand2") link_lbl.pack() link_lbl.bind("<Button-1>", lambda e: webbrowser.open_new(versions.__website__)) ttk.Separator(frame, orient="horizontal").pack(fill="x", pady=10) _license = Label(frame, text="Copyright© 2020 - Vincent Houillon", font=("sans-serif", 8)) _license.pack()
def Findtext(event=None): searchtoplevel = Toplevel(root) toplevel_icon = PhotoImage(file='icons/Findtext.png') searchtoplevel.title('Find Text') searchtoplevel.iconphoto(False, toplevel_icon) searchtoplevel.transient(root) Label(searchtoplevel, text="Find All:").grid(row=0, column=0, sticky='e') search_entry_widget = Entry(searchtoplevel, relief=GROOVE, width=25) search_entry_widget.grid(row=0, column=1, padx=2, pady=2, sticky='we') search_entry_widget.focus_set() ignore_case_value = IntVar() Checkbutton(searchtoplevel, text='Ignore Case', variable=ignore_case_value).grid(row=1, column=1, sticky='e', padx=2, pady=2) Button(searchtoplevel, text="Find All", relief=GROOVE, command=lambda: Searchoutput( search_entry_widget.get(), ignore_case_value.get(), contenttext, searchtoplevel, search_entry_widget)).grid(row=0, column=2, sticky='e' + 'w', padx=2, pady=2) def Closesearchwindow(): contenttext.tag_remove('match', '1.0', END) searchtoplevel.destroy() searchtoplevel.protocol('WM_DELETE_WINDOW', Closesearchwindow) return "break"
def startPassGen(): global root root = Toplevel() root.attributes('-topmost', True) root.title(" Password Generator") root.geometry("350x380") # root.resizable(0,0) root.configure(bg="white") root.iconphoto(True, PhotoImage(file=assetpath + 'padlock.png')) root.tk.call('tk', 'scaling', 1.6) style = Style() style.configure("TLabel", background="white") style.configure('TCheckbutton', background='white') mainf = Frame(root, bg="white") mainf.pack(pady=20, padx=20, ipadx=10, ipady=10) f1 = Frame(mainf, bg="white") f1.pack() icon = ImageTk.PhotoImage( Image.open(assetpath + 'key.png').resize((45, 45))) Label(f1, image=icon, bg="white").grid(row=0, column=0, rowspan=2, padx=2, pady=5) Label(f1, text="Pass-Gen", font=('ARIAL', 15, 'bold'), bg="white").grid(row=0, column=2) Label(f1, text="Password Generator", bg="white").grid(row=1, column=2) f2 = Frame(mainf, bg="white") f2.pack(padx=10, pady=(30, 15)) global passe passe = Entry(f2, width=30) passe.pack(side=LEFT) copyi = ImageTk.PhotoImage( Image.open(assetpath + 'copy.png').resize((25, 25))) copyb = Button(f2, image=copyi, bg="white", bd=0, activebackground="white", command=lambda: copy2clip(passe.get())) copyb.pack(side=LEFT, padx=2) global length length = 8 lenf = Frame(mainf) lenf.pack() Label(lenf, text="Length ", bg="white").pack(side=LEFT) s = Spinbox(lenf, from_=4, to=25, width=5, command=lambda: setlength(s.get())) s.set(8) s.pack(side=LEFT) upper = BooleanVar() digit = BooleanVar() special = BooleanVar() upper.set(True) digit.set(True) special.set(True) f3 = Frame(mainf, bg="white") f3.pack(padx=10, pady=10) capb = Checkbutton(f3, text="Include Capitals", variable=upper, offvalue=False, onvalue=True) capb.pack(anchor=W, pady=5) digitb = Checkbutton(f3, text="Include Digits", variable=digit, offvalue=False, onvalue=True) digitb.pack(anchor=W, pady=5) specialb = Checkbutton(f3, text="Include Special Symbols", variable=special, offvalue=False, onvalue=True) specialb.pack(anchor=W, pady=5) genb = Button(mainf, text="Generate", command=lambda: passGen(length, upper.get(), digit.get(), special.get()), bg="turquoise3", activebackground="turquoise3", bd=0) genb.pack(pady=10, ipadx=20, padx=(43, 10), side=LEFT) exitb = Button(mainf, text="Exit", command=exitPassGen, bg="firebrick1", activebackground="firebrick1", bd=0, width=37) exitb.pack(pady=10, ipadx=20, padx=(10, 30), side=LEFT) root.mainloop()
def team_global(team, fenetremain, imEcusson, selected_players, main_menu_font, dic_clubs_id, blason_path): def pronoGUI(team, chp): fixtures, nbmatchs = dicfixtures(team, chp) Team1 = fixtures[f'{len(fixtures)}'][2] Team2 = fixtures[f'{len(fixtures)}'][3] if Team1 != Team2: # if selected_model != str('') : # # print('pas de modele selectionne') path = os.path.dirname(os.path.abspath(__file__)) model = tf.keras.models.load_model( os.path.join(path, f"models/prediction/all_model.h5")) # model.summary() probability_model = tf.keras.Sequential( [model, tf.keras.layers.Softmax()]) one_input = build_match_features(chp, Team1, Team2).values one_prediction = probability_model.predict(one_input) prediction = one_prediction[0] HP = prediction[0] * 100 DP = prediction[1] * 100 AP = prediction[2] * 100 betadvice = '' if AP > 38 or HP + DP <= 60: betadvice = f'Victoire {Team2}' elif HP >= 45 or AP + DP <= 60: betadvice = f'Victoire {Team1}' elif HP - AP <= 5 or AP - HP <= 5: if AP - HP > 3: betadvice = f'{Team2} ou Nul' elif HP - AP <= 3: betadvice = 'Match Nul' else: betadvice = f'{Team1} ou Nul' pygame.mixer.Channel(2).play( pygame.mixer.Sound("Sounds/referee whistle.wav")) titre = ("Pronostic de : " + Team1 + " vs " + Team2) fenetre_prono = Toplevel(fenetre_stats) fenetre_prono.title(titre) # fenetre_prono.iconphoto(False, PhotoImage(file='Images/icones/icone.png')) fenetre_prono.resizable(0, 0) prono_bg = PhotoImage( file=r'images/backgrounds/Football_pitch.png') prono_cadran = PhotoImage(file=r"images/backgrounds/pronoBG.png") can = Canvas(fenetre_prono, width=1280, height=877) can.pack() can.create_image(0, 0, image=prono_bg, anchor=tk.NW) can.create_image(105, 100, image=l_fixt[0]) can.create_image(1175, 100, image=l_fixt[1]) can.create_image(630, 430, image=prono_cadran) #x0, y0, x1, y1 can.create_rectangle(400, 600, 440, 600 - HP * 6, fill='#99CC00') can.create_text(420, 620, text=f"{HP:.2f}%") can.create_rectangle(620, 600, 660, 600 - DP * 6, fill='#FF9900') can.create_text(640, 620, text=f"{DP:.2f}%") can.create_rectangle(840, 600, 880, 600 - AP * 6, fill='#FF3800') can.create_text(860, 620, text=f"{AP:.2f}%") can.create_text(630, 250, text='Résultat le plus probable :', fill='snow', font=("Purisa", 24)) can.create_text(630, 300, text=betadvice, fill='blue', font=("Purisa", 36, 'bold')) fenetre_prono.mainloop() else: err = messagebox.showerror( "Selections Invalides", "L'une des deux équipes (ou les 2) n'ont pas joué suffisament de matchs." ) return def sort_player(poste): if poste == 'Attaquant': attaquants.append(infojoueur) elif poste == 'Milieu': milieux.append(infojoueur) elif poste == 'Défenseur': défenseurs.append(infojoueur) else: gardiens.append(infojoueur) l_fixt = [] l_ecu = [] def find_ecu(club_name, size, liste): pre_list = [] if club_name == 'Spal': liste.append( ImageTk.PhotoImage( Image.open(rf"images/ecussons/112791.png").resize( (size, size)))) elif club_name == 'Los Angeles Galaxy': liste.append( ImageTk.PhotoImage( Image.open(rf"images/ecussons/697.png").resize( (size, size)))) elif club_name == 'Ath Madrid': liste.append( ImageTk.PhotoImage( Image.open(rf"images/ecussons/240.png").resize( (size, size)))) elif club_name == 'Ath Bilbao': liste.append( ImageTk.PhotoImage( Image.open(rf"images/ecussons/448.png").resize( (size, size)))) elif club_name == 'FC Steaua Bucuresti': liste.append( ImageTk.PhotoImage( Image.open(rf"images/ecussons/100761.png").resize( (size, size)))) elif club_name == 'FC Copenhagen': liste.append( ImageTk.PhotoImage( Image.open(rf"images/ecussons/819.png").resize( (size, size)))) elif club_name == 'Sp Lisbon': liste.append( ImageTk.PhotoImage( Image.open(rf"images/ecussons/237.png").resize( (size, size)))) elif club_name == 'Milan': liste.append( ImageTk.PhotoImage( Image.open(rf"images/ecussons/47.png").resize( (size, size)))) else: for clubs in lteams: best = fuzz.partial_ratio(club_name, clubs) pre_list.append([clubs, best]) tmplist = sorted(pre_list, key=lambda x: (int(x[1])), reverse=True) if tmplist[0][1] > 70: club = tmplist[0][0] club_idx = dic_clubs_id[f'{club}'] liste.append( ImageTk.PhotoImage( Image.open(rf"images/ecussons/{club_idx}.png").resize( (size, size)))) else: liste.append( ImageTk.PhotoImage( Image.open( rf"images/icones/ecusson_default.png").resize( (size, size)))) def pre_donut(Liste, colorletter): m = 0.5 for typesub in Liste: if dictlensubp[f'{typesub}'] > 0: subgroup_names.append(f'{typesub}') subgroup_size.append(dictlensubp[f'{typesub}']) colors.append(colorletter(m)) m -= 0.1 def next_matchday(): actual_matchday = int(lab_mselect.cget('text')) if actual_matchday == 1: PrevMatch.place(x=570, y=305) if actual_matchday > nbmatchs: pronoGUI(team, chp) return elif actual_matchday == nbmatchs: if len(fixtures) > nbmatchs: actual_matchday += 1 lab_mselect['text'] = str(actual_matchday) NextMatch['image'] = predicbut else: return elif actual_matchday < nbmatchs: actual_matchday += +1 lab_mselect['text'] = str(actual_matchday) disp_fixture(team, actual_matchday) def prev_matchday(): actual_matchday = int(lab_mselect.cget('text')) NextMatch['image'] = nextbut if actual_matchday == 1: return else: actual_matchday -= 1 if actual_matchday == 1: PrevMatch.place_forget() disp_fixture(team, actual_matchday) lab_mselect['text'] = str(actual_matchday) def disp_fixture(team, match_select): def disp_nfixture(team): Team1 = fixtures[f'{len(fixtures)}'][2] Team2 = fixtures[f'{len(fixtures)}'][3] can.create_text(x + 225, y - 85, width=550, text=f'Journée {match_select}', font=main_menu_font, fill='white', tags='fixture') HeureGMT = fixtures[f'{len(fixtures)}'][1] for team in Team1, Team2: find_ecu(team, 145, l_fixt) try: can.create_image(x, y, image=l_fixt[0], tags='fixture') can.create_image(x + 450, y, image=l_fixt[1], tags='fixture') can.create_text(x, y + 90, width=550, text=Team1, font=main_menu_font, fill='white', tags='fixture') can.create_text(x + 450, y + 90, width=550, text=Team2, font=main_menu_font, fill='white', tags='fixture') except: can.create_text(x, y, width=550, text=Team1, font=dis_fixture_font, fill='white', tags='fixture') can.create_text(x + 450, y, width=550, text=Team2, font=dis_fixture_font, fill='white', tags='fixture') can.create_text(x + 235, y + 20, width=550, text='VS', font=(dis_fixture_font, 30), fill='white', tags='fixture') can.create_text(x + 225, y + 110, width=550, text=fixtures[f'{len(fixtures)}'][0], font=dis_fixture_font, fill='white', tags='fixture') can.create_text(x + 225, y + 150, width=550, text=HeureGMT, font=main_menu_font, fill='white', tags='fixture') def selected_fixtures(team, i): Team1 = fixtures[f'{i}'][2] Team2 = fixtures[f'{i}'][3] can.create_text(x + 225, y - 85, width=550, text=f'Journée {match_select}', font=main_menu_font, fill='white', tags='fixture') HeureGMT = fixtures[f'{i}'][1] for team in Team1, Team2: find_ecu(team, 145, l_fixt) try: can.create_image(x, y, image=l_fixt[0], tags='fixture') can.create_image(x + 450, y, image=l_fixt[1], tags='fixture') can.create_text(x, y + 90, width=550, text=Team1, font=main_menu_font, fill='white', tags='fixture') can.create_text(x + 450, y + 90, width=550, text=Team2, font=main_menu_font, fill='white', tags='fixture') except: can.create_text(x, y, width=550, text=Team1, font=dis_fixture_font, fill='white', tags='fixture') can.create_text(x + 450, y, width=550, text=Team2, font=dis_fixture_font, fill='white', tags='fixture') can.create_text(x + 185, y + 20, width=550, text=int(fixtures[f'{i}'][4]), font=(dis_fixture_font, 30), fill='white', tags='fixture') can.create_text(x + 235, y + 20, width=550, text='-', font=(dis_fixture_font, 30), fill='white', tags='fixture') can.create_text(x + 285, y + 20, width=550, text=int(fixtures[f'{i}'][5]), font=(dis_fixture_font, 30), fill='white', tags='fixture') can.create_text(x + 225, y + 110, width=550, text=fixtures[f'{i}'][0], font=(dis_fixture_font, 20), fill='white', tags='fixture') can.create_text(x + 225, y + 150, width=550, text=HeureGMT, font=main_menu_font, fill='white', tags='fixture') x = 725 y = 200 fixtures, nbmatchs = dicfixtures(team, chp) can.delete('fixture') l_fixt.clear() if match_select > nbmatchs: disp_nfixture(team) else: selected_fixtures(team, match_select) dictpostes = { 'Attaquant': (['LS', 'ST', 'RS', 'LW', 'LF', 'CF', 'RF', 'RW']), 'Milieu': ([ 'LAM', 'CAM', 'RAM', 'LM', 'LCM', 'CM', 'RCM', 'RM', 'LDM', 'CDM', 'RDM' ]), 'Défenseur': (['LWB', 'RWB', 'LB', 'LCB', 'CB', 'RCB', 'RB']), 'Gardien': (['GK']), 'Remplaçant': (['SUB']), 'Réserviste': (['RES']) } dictlenpostes = { 'LS': 0, 'ST': 0, 'RS': 0, 'LW': 0, 'LF': 0, 'CF': 0, 'RF': 0, 'RW': 0, 'LAM': 0, 'CAM': 0, 'RAM': 0, 'LM': 0, 'LCM': 0, 'CM': 0, 'RCM': 0, 'RM': 0, 'LDM': 0, 'CDM': 0, 'RDM': 0, 'LWB': 0, 'RWB': 0, 'LB': 0, 'LCB': 0, 'CB': 0, 'RCB': 0, 'RB': 0, 'GK': 0 } dictsubpost = { 'Buteurs': (['LS', 'ST', 'RS']), 'Ailiers': (['LW', 'RW']), 'Forwards': (['LF', 'CF', 'RF']), 'Off.': (['LAM', 'CAM', 'RAM']), 'Equi.': (['LM', 'LCM', 'CM', 'RCM', 'RM']), 'Déf.': (['LDM', 'CDM', 'RDM']), 'Latéraux': (['LWB', 'RWB', 'LB', 'RB']), 'Centraux': (['LCB', 'CB', 'RCB']), ' ': (['GK']) } dictlensubp = { 'Buteurs': 0, 'Ailiers': 0, 'Forwards': 0, 'Off.': 0, 'Equi.': 0, 'Déf.': 0, 'Latéraux': 0, 'Centraux': 0, ' ': 0 } attaquants, milieux, défenseurs, gardiens = [], [], [], [] chp = '' conn = sqlite3.connect(f'databases/alldata.db') c = conn.cursor() joueurs = c.execute( f"SELECT ID,Name,OVA,POT,TITU,BP,championnat FROM Players WHERE Club = ? AND TITU IS NOT NULL {selected_players}", (team, )) try: for j in joueurs.fetchall(): nom = j[1] note = j[2] potentiel = j[3] - note infojoueur = [nom, note, potentiel] titu = j[4] chp = j[6] if titu == 'SUB' or titu == 'RES': bpost = j[5] dictlenpostes[f'{bpost}'] += 1 poste = testpost(dictpostes, bpost) testsubposte(dictsubpost, dictlensubp, bpost) sort_player(poste) else: dictlenpostes[f'{titu}'] += 1 poste = testpost(dictpostes, titu) testsubposte(dictsubpost, dictlensubp, titu) sort_player(poste) except: pass conn.close() global_team = prepair_global_team(attaquants, milieux, défenseurs, gardiens) # Datas et couleurs nba, nbm, nbd, nbg = len(attaquants), len(milieux), len(défenseurs), len( gardiens) nbtot = nba + nbm + nbd + nbg group_names = [ f'Attaquants\n{nba*100//nbtot} %', f'Milieux\n{nbm*100//nbtot} %', f'Défenseurs\n{nbd*100//nbtot} %', f'Gardiens\n{nbg*100//nbtot} %' ] group_size = [nba, nbm, nbd, nbg] subgroup_names = [] subgroup_size = [] colors = [] a, b, c, d = [plt.cm.Reds, plt.cm.Oranges, plt.cm.Greens, plt.cm.Blues] pre_donut(['Buteurs', 'Ailiers', 'Forwards'], a) pre_donut(['Off.', 'Equi.', 'Déf.'], b) pre_donut(['Latéraux', 'Centraux'], c) subgroup_names.append(' ') subgroup_size.append(dictlensubp[' ']) colors.append(d(0.0)) # Premier Donut (extérieur) fig, ax = plt.subplots() ax.axis('equal') mypie, texts = ax.pie(group_size, labels=group_names, labeldistance=1.2, radius=1.3, colors=[a(0.7), b(0.7), c(0.7), d(0.6)]) for t in texts: t.set_horizontalalignment('center') t.font = ("helvetica", 12) t.set_color('white') #Ajout cercle blanc plt.setp(mypie, width=0.3, edgecolor='white') # Second Donut (intérieur) mypie2, _ = ax.pie(subgroup_size, radius=1.3 - 0.3, labels=subgroup_names, labeldistance=0.7, colors=colors) #Ajout cercle blanc plt.setp(mypie2, width=0.4, edgecolor='white') plt.margins(0, 0) ax.set_title('Répartition Effectif', color='white', fontsize=14, pad=24) if not os.path.exists('temp'): os.makedirs('temp') plotsavepatheffectif = f"temp/effectif_{team}.png" plt.savefig(plotsavepatheffectif, transparent=True, dpi=224) for squad in global_team: dicdata = {'group': ['Notes', 'Potentiel']} somme = 0 if squad[0][0] != 0: dicdata['ATT'] = squad[0][0], squad[0][0] + squad[0][1] somme = somme + squad[0][0] if squad[1][0] != 0: dicdata['MIL'] = squad[1][0], squad[1][0] + squad[1][1] somme = somme + squad[1][0] if squad[3][0] != 0: dicdata['GAR'] = squad[3][0], squad[3][0] + squad[3][1] somme = somme + squad[3][0] if squad[2][0] != 0: dicdata['DEF'] = squad[2][0], squad[2][0] + squad[2][1] somme = somme + squad[2][0] df = pd.DataFrame(dicdata) if len(dicdata) > 3: squadmean = somme // (len(dicdata) - 1) color = levelcolor(squadmean) categories = list(df)[1:] N = len(categories) # What will be the angle of each axis in the plot? (we divide the plot / number of variable) angles = [n / float(N) * 2 * pi for n in range(N)] angles += angles[:1] # Initialise the spider plot ax = plt.subplot(111, polar=True) # If you want the first axis to be on top: ax.set_theta_offset(pi / 2) ax.set_theta_direction(-1) # Draw one axe per variable + add labels labels yet plt.xticks(angles[:-1], categories, color='white', size=8) # Ylabels ax.set_rlabel_position(0) plt.yticks([20, 40, 60, 80], ["20", "40", "60", "80"], color='white', size=7) plt.ylim(0, 100) # Ind1 values = df.loc[0].drop('group').values.flatten().tolist() values += values[:1] ax.plot(angles, values, linewidth=1, linestyle='solid', color=color, label='Niveau Actuel') ax.fill(angles, values, alpha=0.25, facecolor=color) # Ind2 values = df.loc[1].drop('group').values.flatten().tolist() values += values[:1] ax.plot(angles, values, linewidth=1, linestyle='dashed', color='grey', label="Marge de Progression") ax.fill(angles, values, facecolor=None, alpha=0) # Add legend ax.set_title(squad[-1], color='white') plt.legend(loc='upper right', bbox_to_anchor=(0.395, 0.011)) plotsavepathspider = f"temp/{team}_{squad[-1]}.png" plt.savefig(plotsavepathspider, transparent=True, dpi=224) # plt.show() plt.close() # print(team,chp) data = focus_ranking(team, chp) lteams = [] conn = sqlite3.connect(f'databases/alldata.db') c = conn.cursor() clubs = c.execute( f"SELECT Club FROM Players WHERE championnat = ? AND TITU IS NOT NULL", (chp, )) for c in clubs.fetchall(): locequipe = c[0] if locequipe not in lteams: lteams.append(locequipe) conn.close() lteams = sorted(lteams, reverse=False) # ### fenetre_stats = Toplevel(fenetremain) fenetre_stats.title(f"Statistiques de {team}") fenetre_stats.iconphoto(True, PhotoImage(file='images/icones/root_icone.png')) width = 1920 height = 1080 fenetre_stats.geometry(f'{width}x{height}+0+0') fenetre_stats.minsize(width // 2, height // 2) fenetre_stats.resizable(0, 0) fenetre_stats.bind( "<F11>", lambda event: fenetre_stats.attributes( "-fullscreen", not fenetre_stats.attributes("-fullscreen"))) fenetre_stats.bind( "<Escape>", lambda event: fenetre_stats.attributes("-fullscreen", False)) background_image = PhotoImage(file=r"images/backgrounds/pitch.png") can = Canvas(fenetre_stats, width=width, height=height) can.pack() can.create_image(0, 0, image=background_image, anchor=tk.NW) can.create_image(160, 220, image=imEcusson) effectifchart = ImageTk.PhotoImage( Image.open(rf"{plotsavepatheffectif}").resize((720, 520))) can.create_image(width - 330, 730, image=effectifchart) # teamAchart = ImageTk.PhotoImage(Image.open(rf"temp/{team}_Equipe Type.png").resize((784,522))) # can.create_image(width*(1/3)-330,775, image = teamAchart) # teamBchart = ImageTk.PhotoImage(Image.open(rf"temp/{team}_Equipe Remplaçants.png").resize((784,522))) # can.create_image(width*(2/3)-330,775, image = teamBchart) try: teamAchart = ImageTk.PhotoImage( Image.open(rf"temp/{team}_Equipe Type.png").resize((784, 580))) can.create_image(width * (1 / 3) - 330, 730, image=teamAchart) except: pass try: teamBchart = ImageTk.PhotoImage( Image.open(rf"temp/{team}_Equipe Remplaçants.png").resize( (784, 580))) # teamCchart = ImageTk.PhotoImage(Image.open(rf"temp/{team}_Equipe Réserve.png").resize((784,522))) except: pass try: can.create_image(width * (2 / 3) - 330, 730, image=teamBchart) # can.create_image(width-330,775, image = teamCchart) except: pass dis_fixture_font = tkFont.Font(family='Helvetica', size=24, weight=tkFont.BOLD) x = 1480 y = 105 can.create_rectangle(x - 80, 130, x + 385, 170, fill='#6A21B4') can.create_rectangle(x - 80, 128 + 90, x + 385, 170 + 90, fill='#6A21B4') can.create_rectangle(x - 80, 128 + 180, x + 385, 170 + 180, fill='#6A21B4') can.create_text(x - 30, y, width=550, text='P', font=main_menu_font, fill='white', tags='data', anchor=tk.W) can.create_text(x, y, width=550, text='Equipe', font=main_menu_font, fill='white', tags='data', anchor=tk.W) can.create_text(x + 150, y, width=550, text='Pts', font=main_menu_font, fill='white', tags='data') can.create_text(x + 180, y, width=550, text='J', font=main_menu_font, fill='white', tags='data') can.create_text(x + 210, y, width=550, text='V', font=main_menu_font, fill='white', tags='data') can.create_text(x + 240, y, width=550, text='N', font=main_menu_font, fill='white', tags='data') can.create_text(x + 270, y, width=550, text='D', font=main_menu_font, fill='white', tags='data') can.create_text(x + 300, y, width=550, text='BP', font=main_menu_font, fill='white', tags='data') can.create_text(x + 330, y, width=550, text='BC', font=main_menu_font, fill='white', tags='data') can.create_text(x + 360, y, width=550, text='+/-', font=main_menu_font, fill='white', tags='data') for t in data: find_ecu(t[0], 31, l_ecu) y = 150 i = 0 for d in range(len(data)): try: ecurank = l_ecu[i] except: ecurank = ImageTk.PhotoImage( Image.open(rf"images/icones/ecusson_default.png").resize( (31, 31))) can.create_image(x - 55, y, image=ecurank) can.create_text(x - 30, y, width=550, text=f'{data[d][9]}', font=main_menu_font, fill='white', tags='data', anchor=tk.W) cname = data[d][0][:13] + (data[d][0][13:] and '..') can.create_text(x, y, width=550, text=f'{cname}', font=main_menu_font, fill='white', tags='data', anchor=tk.W) can.create_text(x + 150, y, width=550, text=f'{data[d][1]}', font=main_menu_font, fill='white', tags='data') can.create_text(x + 180, y, width=550, text=f'{data[d][2]}', font=main_menu_font, fill='white', tags='data') can.create_text(x + 210, y, width=550, text=f'{data[d][3]}', font=main_menu_font, fill='white', tags='data') can.create_text(x + 240, y, width=550, text=f'{data[d][4]}', font=main_menu_font, fill='white', tags='data') can.create_text(x + 270, y, width=550, text=f'{data[d][5]}', font=main_menu_font, fill='white', tags='data') can.create_text(x + 300, y, width=550, text=f'{data[d][6]}', font=main_menu_font, fill='white', tags='data') can.create_text(x + 330, y, width=550, text=f'{data[d][7]}', font=main_menu_font, fill='white', tags='data') can.create_text(x + 360, y, width=550, text=f'{data[d][8]}', font=main_menu_font, fill='white', tags='data') i += 1 y += 45 fixtures, nbmatchs = dicfixtures(team, chp) lab_mselect = Label(fenetre_stats, text=str(nbmatchs)) # lab_nbmatch = Label(fenetre_stats, text = str(nbmatchs)) disp_fixture(team, nbmatchs) nextbut = PhotoImage(file=r'images/icones/nbutton.png') prevbut = PhotoImage(file=r'images/icones/pbutton.png') predicbut = PhotoImage(file=r'images/icones/sifflet.png') season_stats = ImageTk.PhotoImage( Image.open(r'images/icones/contrat_default.png').resize((110, 110))) x = 725 y = 185 NextMatch = Button(fenetre_stats, text='Match Suivant', command=next_matchday, image=nextbut, relief=tk.FLAT, bg="#2B0C47", activebackground="#2B0C47") NextMatch.place(x=x + 425, y=y + 120) PrevMatch = Button(fenetre_stats, text='Match Précédent', command=prev_matchday, image=prevbut, relief=tk.FLAT, bg="#2B0C47", activebackground="#2B0C47") PrevMatch.place(x=x - 30, y=y + 120) GlobSeason = Button( fenetre_stats, command=lambda: results_season(team, blason_path, chp, fenetre_stats), image=season_stats, relief=tk.FLAT, bg="#2B0C47", activebackground="#2B0C47") GlobSeason.place(x=380, y=170) fenetre_stats.mainloop()
functions.dbCreated = pickle.load(f) city, temp,quote = functions.getCityTempQuote() txtCityTemp.insert(INSERT, "".join([city, ":\t\t\t\t", str(temp), "\u2103"])) txtQuoteOfTheDay.insert(INSERT, "".join(["Quote of the day:\n", quote])) txtCityTemp.configure(state="disabled") txtQuoteOfTheDay.configure(state="disabled") print("Program started...") #Add Window addWindow = Toplevel(mainWindow) addWindow.title("Add a Student's Record") addWindow.configure(background="Light Blue") addWindow.geometry("450x450+400+150") addWindow.iconphoto(False, PhotoImage(file="icon.png")) addWindow.resizable(0, 0) addWindow.protocol("WM_DELETE_WINDOW", functions.windowCloseAction) lblAddRollNumber = Label(addWindow, text="Enter the roll number:", background="Light Blue", font=("Calibri", 16, "bold"), width=22) lblAddRollNumber.pack(pady=10) entAddRollNumber = Entry(addWindow, font=("Calibri", 16, "bold"), width=24) entAddRollNumber.pack(pady=10) lblAddName = Label(addWindow, text="Enter the name:", background="Light Blue", font=("Calibri", 16, "bold"), width=22) lblAddName.pack(pady=10) entAddName = Entry(addWindow, font=("Calibri", 16, "bold"), width=24) entAddName.pack(pady=10)
def best_tactic(fenetremain, teamdata, selected_players): def updatetactic(event): tactique = combodispo.get() disp_compo(tactique) players, team, imEcusson, imJersey_home, imJersey_away, jersey_home = teamdata( ) fenetre_team_maker = Toplevel(fenetremain) fenetre_team_maker.title("Créateur") fenetre_team_maker.geometry('1920x1080') fenetre_team_maker.resizable(0, 0) fenetre_team_maker.iconphoto( True, PhotoImage(file='images/icones/root_icone.png')) fenetre_team_maker.bind( "<F11>", lambda event: fenetre_team_maker.attributes( "-fullscreen", not fenetre_team_maker.attributes("-fullscreen"))) fenetre_team_maker.bind( "<Escape>", lambda event: fenetre_team_maker.attributes("-fullscreen", False)) can = Canvas(fenetre_team_maker, width=1920, height=1080, bg='#370F58') pitch = PhotoImage(file=r"images/backgrounds/pitch_vertical.png") can.create_image(1920 / 2, 1080 / 2, image=pitch) cote = 130 recotex = 135 recotey = 150 x1 = 625 x2 = x1 + cote y1 = 40 y2 = y1 + cote jersey_H = jersey_home.resize((int(78 / 100 * cote), int(78 / 100 * cote))) jerseyH = ImageTk.PhotoImage(jersey_H) dispos = [] conn = sqlite3.connect(f'databases/alldata.db') c = conn.cursor() tactics = c.execute("SELECT * FROM Dispositifs") for col in tactics.fetchall(): dispositif = col[0] GK = col[1] LB = col[2] LCB = col[3] CB = col[4] RCB = col[5] RB = col[6] LWB = col[7] LDM = col[8] CDM = col[9] RDM = col[10] RWB = col[11] LM = col[12] LCM = col[13] CM = col[14] RCM = col[15] RM = col[16] LAM = col[17] CAM = col[18] RAM = col[19] LW = col[20] LF = col[21] CF = col[22] RF = col[23] RW = col[24] LS = col[25] ST = col[26] RS = col[27] dispo = [ dispositif, GK, LB, LCB, CB, RCB, RB, LWB, LDM, CDM, RDM, RWB, LM, LCM, CM, RCM, RM, LAM, CAM, RAM, LW, LF, CF, RF, RW, LS, ST, RS ] dispos.append(dispo) dftactic = pd.DataFrame(dispos, columns=[ 'dispositif', 'GK', 'LB', 'LCB', 'CB', 'RCB', 'RB', 'LWB', 'LDM', 'CDM', 'RDM', 'RWB', 'LM', 'LCM', 'CM', 'RCM', 'RM', 'LAM', 'CAM', 'RAM', 'LW', 'LF', 'CF', 'RF', 'RW', 'LS', 'ST', 'RS' ]) dftactic = dftactic.set_index('dispositif') compo = dftactic.index.values.tolist() ids = [] for j in players: ids.append(j[-1]) joueurs_notes = [] for i in ids: conn = sqlite3.connect(f'databases/alldata.db') c = conn.cursor() stats = c.execute( f'''SELECT LS,ST,RS,LW,LF,CF,RF,RW,LAM,CAM,RAM,LM,LCM,CM,RCM,RM,LWB,LDM,CDM,RDM,RWB,LB,LCB,CB,RCB,RB,GK, Name,OVA,BP FROM Players WHERE ID = ? {selected_players}''', (i, )) for row in stats.fetchall(): LS = row[0].rsplit('+', 1)[0] ST = row[1].rsplit('+', 1)[0] RS = row[2].rsplit('+', 1)[0] LW = row[3].rsplit('+', 1)[0] LF = row[4].rsplit('+', 1)[0] CF = row[5].rsplit('+', 1)[0] RF = row[6].rsplit('+', 1)[0] RW = row[7].rsplit('+', 1)[0] LAM = row[8].rsplit('+', 1)[0] CAM = row[9].rsplit('+', 1)[0] RAM = row[10].rsplit('+', 1)[0] LM = row[11].rsplit('+', 1)[0] LCM = row[12].rsplit('+', 1)[0] CM = row[13].rsplit('+', 1)[0] RCM = row[14].rsplit('+', 1)[0] RM = row[15].rsplit('+', 1)[0] LWB = row[16].rsplit('+', 1)[0] LDM = row[17].rsplit('+', 1)[0] CDM = row[18].rsplit('+', 1)[0] RDM = row[19].rsplit('+', 1)[0] RWB = row[20].rsplit('+', 1)[0] LB = row[21].rsplit('+', 1)[0] LCB = row[22].rsplit('+', 1)[0] CB = row[23].rsplit('+', 1)[0] RCB = row[24].rsplit('+', 1)[0] RB = row[25].rsplit('+', 1)[0] GK = row[26].rsplit('+', 1)[0] Name, OVA, BP = row[27], row[28], row[29] joueurdetail = [ Name, OVA, BP, LS, ST, RS, LW, LF, CF, RF, RW, LAM, CAM, RAM, LM, LCM, CM, RCM, RM, LWB, LDM, CDM, RDM, RWB, LB, LCB, CB, RCB, RB, GK ] joueurs_notes.append(joueurdetail) conn.close() dfpostes = pd.DataFrame(joueurs_notes, columns=[ 'Name', 'OVA', 'BP', 'LS', 'ST', 'RS', 'LW', 'LF', 'CF', 'RF', 'RW', 'LAM', 'CAM', 'RAM', 'LM', 'LCM', 'CM', 'RCM', 'RM', 'LWB', 'LDM', 'CDM', 'RDM', 'RWB', 'LB', 'LCB', 'CB', 'RCB', 'RB', 'GK' ]) print(dfpostes) # titus = [] # postes_titus = [] # subs = [] # n = 0 # for i in dfpostes.index: # maxValueBP = pd.to_numeric(dfpostes['OVA']).argmax() # jname, pbp, pova = dfpostes.iloc[maxValueBP]['Name'],dfpostes.iloc[maxValueBP]['BP'],dfpostes.iloc[maxValueBP]['OVA'] # joueur =[jname,pbp,pova] # dfpostes=dfpostes.drop([dfpostes.index[maxValueBP]]) # if n<=11 and ('j'+joueur[1]) not in postes_titus: # titus.append(joueur) # postes_titus.append('j'+joueur[1]) # n = n+1 # else: # subs.append(joueur) x, y = 50, 50 for p in players: can.create_text(x, y, text=p[0], fill='white') y = y + 50 if y > 900: x, y = 150, 50 def disp_compo(tactique): tactinfo = dftactic.loc[tactique] can.delete("jersey") if tactinfo[26] == 1.0: rs = can.create_image((x1 + 2 * recotex + x2) // 2 - 45, (y1 + y2) // 2 + 30, image=jerseyH, tags='jersey') if tactinfo[25] == 1.0: st = can.create_image((x1 + 2 * recotex + x2 + 2 * recotex) // 2, (y1 + y2) // 2 + 20, image=jerseyH, tags='jersey') if tactinfo[24] == 1.0: ls = can.create_image( (x1 + 3 * recotex + x2 + 3 * recotex) // 2 + 45, (y1 + y2) // 2 + 30, image=jerseyH, tags='jersey') if tactinfo[23] == 1.0: rw = can.create_image((x1 + x2) // 2, (y1 + recotey + y2 + recotey) // 2 + 30, image=jerseyH, tags='jersey') if tactinfo[22] == 1.0: rf = can.create_image((x1 + recotex + x2 + recotex) // 2 + 10, (y1 + recotey + y2 + recotey) // 2 - 18, image=jerseyH, tags='jersey') if tactinfo[21] == 1.0: cf = can.create_image((x1 + 2 * recotex + x2 + 2 * recotex) // 2, (y1 + recotey + y2 + recotey) // 2 - 35, image=jerseyH, tags='jersey') if tactinfo[20] == 1.0: lf = can.create_image( (x1 + 3 * recotex + x2 + 3 * recotex) // 2 - 10, (y1 + recotey + y2 + recotey) // 2 - 18, image=jerseyH, tags='jersey') if tactinfo[19] == 1.0: lw = can.create_image((x1 + 4 * recotex + x2 + 4 * recotex) // 2, (y1 + recotey + y2 + recotey) // 2 + 30, image=jerseyH, tags='jersey') if tactinfo[18] == 1.0: ram = can.create_image( (x1 + recotex + x2 + recotex) // 2, (y1 + 2 * recotey + y2 + 2 * recotey) // 2 - 10, image=jerseyH, tags='jersey') if tactinfo[17] == 1.0: cam = can.create_image( (x1 + 2 * recotex + x2 + 2 * recotex) // 2, (y1 + 2 * recotey + y2 + 2 * recotey) // 2 - 10, image=jerseyH, tags='jersey') if tactinfo[16] == 1.0: lam = can.create_image( (x1 + 3 * recotex + x2 + 3 * recotex) // 2, (y1 + 2 * recotey + y2 + 2 * recotey) // 2 - 10, image=jerseyH, tags='jersey') if tactinfo[15] == 1.0: rm = can.create_image( (x1 + x2) // 2 - 10, (y1 + 3 * recotey + y2 + 3 * recotey) // 2 - 15, image=jerseyH, tags='jersey') if tactinfo[14] == 1.0: rcm = can.create_image((x1 + recotex + x2 + recotex) // 2 - 9, (y1 + 3 * recotey + y2 + 3 * recotey) // 2, image=jerseyH, tags='jersey') if tactinfo[13] == 1.0: cm = can.create_image( (x1 + 2 * recotex + x2 + 2 * recotex) // 2, (y1 + 3 * recotey + y2 + 3 * recotey) // 2 + 18, image=jerseyH, tags='jersey') if tactinfo[12] == 1.0: lcm = can.create_image( (x1 + 3 * recotex + x2 + 3 * recotex) // 2 + 9, (y1 + 3 * recotey + y2 + 3 * recotey) // 2, image=jerseyH, tags='jersey') if tactinfo[11] == 1.0: lm = can.create_image( (x1 + 4 * recotex + x2 + 4 * recotex) // 2 + 10, (y1 + 3 * recotey + y2 + 3 * recotey) // 2 - 15, image=jerseyH, tags='jersey') if tactinfo[10] == 1.0: rwb = can.create_image( (x1 + x2) // 2, (y1 + 4 * recotey + y2 + 4 * recotey) // 2 - 20, image=jerseyH, tags='jersey') if tactinfo[9] == 1.0: rdm = can.create_image( (x1 + recotex + x2 + recotex) // 2, (y1 + 4 * recotey + y2 + 4 * recotey) // 2 - 10, image=jerseyH, tags='jersey') if tactinfo[8] == 1.0: lcm = can.create_image( (x1 + 2 * recotex + x2 + 2 * recotex) // 2, (y1 + 4 * recotey + y2 + 4 * recotey) // 2 - 5, image=jerseyH, tags='jersey') if tactinfo[7] == 1.0: ldm = can.create_image( (x1 + 3 * recotex + x2 + 3 * recotex) // 2, (y1 + 4 * recotey + y2 + 4 * recotey) // 2 - 10, image=jerseyH, tags='jersey') if tactinfo[6] == 1.0: lwb = can.create_image( (x1 + 4 * recotex + x2 + 4 * recotex) // 2, (y1 + 4 * recotey + y2 + 4 * recotey) // 2 - 20, image=jerseyH, tags='jersey') if tactinfo[5] == 1.0: can.create_image((x1 + x2) // 2 - 15, (y1 + 5 * recotey + y2 + 5 * recotey) // 2 - 30, image=jerseyH, tags='jersey') #rb if tactinfo[4] == 1.0: can.create_image((x1 + recotex + x2 + recotex) // 2 - 10, (y1 + 5 * recotey + y2 + 5 * recotey) // 2 - 10, image=jerseyH, tags='jersey') #rcb if tactinfo[3] == 1.0: can.create_image((x1 + 2 * recotex + x2 + 2 * recotex) // 2, (y1 + 5 * recotey + y2 + 5 * recotey) // 2 + 10, image=jerseyH, tags='jersey') #cb if tactinfo[2] == 1.0: can.create_image((x1 + 3 * recotex + x2 + 3 * recotex) // 2 + 10, (y1 + 5 * recotey + y2 + 5 * recotey) // 2 - 10, image=jerseyH, tags='jersey') #lcb if tactinfo[1] == 1.0: can.create_image((x1 + 4 * recotex + x2 + 4 * recotex) // 2 + 15, (y1 + 5 * recotey + y2 + 5 * recotey) // 2 - 30, image=jerseyH, tags='jersey') #lb if tactinfo[0] == 1.0: can.create_image((x1 + 2 * recotex + x2 + 2 * recotex) // 2, (y1 + 6 * recotey + y2 + 6 * recotey) // 2 - 20, image=jerseyH, tags='jersey') #gk can.pack() combodispo = ttk.Combobox(fenetre_team_maker, values=compo, state="readonly") combodispo.bind("<<ComboboxSelected>>", updatetactic) combodispo.place(x=300, y=100) fenetre_team_maker.mainloop()
def startSignup(): global root root = Toplevel() root.attributes('-topmost', True) root.title(" Signup") root.geometry("330x620") # root.resizable(0,0) root.configure(bg="white") root.iconphoto(True, PhotoImage(file=assetpath + 'login.png')) root.tk.call('tk', 'scaling', 1.6) style = Style() style.configure("TLabel", background="white") Label(root, text="CREATE AN ACCOUNT", font=("ARIAL", 15, 'bold', 'italic'), bg="dodger blue", fg="white").pack(pady=(20, 20), ipadx=10, ipady=10) mainf = Frame(root, bg="white") mainf.pack(padx=30, pady=(20, 5), ipadx=30, ipady=20) #making the form Label(mainf, text="Username :"******"Arial", 8, 'bold'), bg="white").pack(anchor=W) userb = Frame(mainf, bg="dodger blue", bd=2) userb.pack(anchor=W) usere = Entry(userb, width=30) usere.pack(anchor=W, ipadx=5, ipady=5) Label(mainf, text="Email :", font=("Arial", 8, 'bold'), bg="white").pack(anchor=W) mailb = Frame(mainf, bg="dodger blue", bd=2) mailb.pack(anchor=W) maile = Entry(mailb, width=30) maile.pack(anchor=W, ipadx=5, ipady=5) Label(mainf, text="Choose Password :"******"Arial", 8, 'bold'), bg="white").pack(anchor=W) passb = Frame(mainf, bg="dodger blue", bd=2) passb.pack(anchor=W) passe = Entry(passb, width=30, show="*") passe.pack(anchor=W, ipadx=5, ipady=5) Label(mainf, text="Confirm Password :"******"Arial", 8, 'bold'), bg="white").pack(anchor=W) passcb = Frame(mainf, bg="dodger blue", bd=2) passcb.pack(anchor=W) passce = Entry(passcb, width=30, show="*") passce.pack(anchor=W, ipadx=5, ipady=5) #a curated set of security questions sec_ques = [ "What is your pet name?", "What was the first company that you worked for?", "Where did you meet your spouse?", "Where did you go to high school/college?", "What city were you born in?" ] Label(mainf, text="Security Question :", font=("Arial", 8, 'bold'), bg="white").pack(anchor=W) combo = Combobox(mainf, values=sec_ques, width=29, state='readonly') combo.pack(anchor=W, pady=(10, 10)) combo.current(0) quesb = Frame(mainf, bg="dodger blue", bd=2) quesb.pack(anchor=W) quese = Entry(quesb, width=30) quese.pack(anchor=W, ipadx=5, ipady=5) Label( mainf, text= "The security question will help you\n login if you forget your password", bg="white").pack(pady=(20, 10)) createb = Button(mainf, width=30, text="Create Account", font=('ARIAL', 10, 'bold'), bd=0, fg="white", bg="dodger blue", activebackground="dodger blue", activeforeground="white") createb.pack(ipadx=5, ipady=5, padx=10, pady=20) root.mainloop()
def onViewClient(self): def refreshAccountList(): account_list.set(value=[name for name in self.clients.client_dict]) def onOpenFile(): old_path = new_directory.get() dir_path = filedialog.askdirectory( initialdir=self.clients.meta_save_path, title="請選擇要報告輸出的資料夾") new_directory.set(dir_path if dir_path != '' else old_path) def editClient(new=True, old_name=None): def onProcessClientData(): name = new_name.get() exchange = new_exchange.get() api_key = new_api_key.get() api_secret = new_api_secret.get() query_str = new_query_list.get() ## Check name try: for s in name: if s in "~!@#$%^&*()+-*/<>,.[]\/": msg.set('Error: ' + "名稱勿含特殊符號") return for s in query_str: if s in "~!@#$%^&*()+-*/<>.[]\/": msg.set('Error: ' + 'Query List勿含除了","以外的特殊符號') return if len(name) > 15: msg.set('Error: ' + '名稱勿超過15字') elif name in self.clients.client_dict and new: msg.set('Error: ' + '名字勿重複') elif not len(api_key) or not len(api_secret) or not len( name) or not len(exchange): msg.set('Error: ' + "請輸入名稱、金錀或交易所") elif exchange not in ['binance', 'ftx']: msg.set('Error: ' + "目前交易所僅支援 binance 和 ftx") else: ## Add client to config specialChars = " \n!\"#$%^&*()" for specialChar in specialChars: query_str = query_str.replace(specialChar, '') client_data = { 'api_key': api_key, 'api_secret': api_secret, 'query_list': query_str.upper().split(','), 'exchange': exchange } if new: client_data['index'] = self.clients.count self.clients.count += 1 self.clients.process_client_data(name, client_data) refreshAccountList() messagebox.showinfo('Welcome', '成功增加帳戶 %s!' % name) else: self.clients.client_dict[name].info.setinfo( client_data) messagebox.showinfo('Welcome', '成功修改帳戶 %s!' % name) self.clients.save_client_config(CONFIG_FILENAME) window_add_client.destroy() except Exception as e: msg.set('Error') print(e) window_add_client = Toplevel(self.app) window_add_client.title("編輯您的帳戶資訊") window_add_client.geometry('400x300') try: window_add_client.iconphoto( False, PhotoImage(file='icon/doge_icon.png')) except: pass setUIToCenter(window_add_client, 400, 300) new_name = StringVar() new_name.set('binance_Name') Label(window_add_client, text='User name: ').place(x=10, y=10) # 將`User name:`放置在座標(10,10)。 entry_new_name = Entry(window_add_client, textvariable=new_name, width=35) # 建立一個註冊名的`entry`,變數為`new_name` entry_new_name.place(x=130, y=10) # `entry`放置在座標(150,10). new_exchange = StringVar() new_exchange.set('binance') Label(window_add_client, text='Exchange: ').place(x=10, y=50) entry_new_exchange = Entry(window_add_client, textvariable=new_exchange, width=35) entry_new_exchange.place(x=130, y=50) new_api_key = StringVar() Label(window_add_client, text='API key: ').place(x=10, y=90) entry_usr_api_key = Entry(window_add_client, textvariable=new_api_key, width=35) entry_usr_api_key.place(x=130, y=90) new_api_secret = StringVar() Label(window_add_client, text='Secret key: ').place(x=10, y=130) Entry(window_add_client, textvariable=new_api_secret, width=35) \ .place(x=130, y=130) new_query_list = StringVar() new_query_list.set("ETH, BTC") Label(window_add_client, text='Query list: ').place(x=10, y=170) Entry(window_add_client, textvariable=new_query_list, width=35) \ .place(x=130, y=170) msg = StringVar() Label(window_add_client, textvariable=msg, fg='red').place(x=20, y=210) btn_comfirm_sign_up = Button(window_add_client, text='確認', command=onProcessClientData) btn_comfirm_sign_up.place(x=180, y=250) if not new: entry_new_name['state'] = 'disabled' info = self.clients.client_dict[old_name].info new_name.set(old_name) new_exchange.set(info.exchange) new_api_key.set(info.api_key) new_api_secret.set(info.api_secret) new_query_list.set(','.join(info.query_list)) def onImportClient(): file_path = filedialog.askopenfile( initialdir=self.clients.meta_save_path, title="請選擇要匯入的key.txt").name self.clients.init_client_from_key(file_path, CONFIG_FILENAME) refreshAccountList() new_directory.set(self.clients.meta_save_path) def onEditClient(): index = accountListBox.curselection() if len(index) == 0: return old_name = accountListBox.get(index) editClient(new=False, old_name=old_name) def onDeleteClient(): index = accountListBox.curselection() if len(index) == 0: return name = accountListBox.get(index) self.clients.delete_client(name) refreshAccountList() def onViewConfirm(): self.clients.owner = new_name.get() self.clients.meta_save_path = new_directory.get() self.clients.save_client_config(CONFIG_FILENAME) close() def close(): self.app.deiconify() window_view_client.destroy() self.app.withdraw() window_view_client = Toplevel(self.app) window_view_client.title("Edit your infomation") window_view_client.geometry('400x300') window_view_client.resizable(0, 0) try: window_view_client.iconphoto(False, PhotoImage(file='icon/eth_icon.png')) except: pass window_view_client.protocol("WM_DELETE_WINDOW", close) setUIToCenter(window_view_client, 400, 300) new_name = StringVar() new_name.set(self.clients.owner) Label(window_view_client, text='英文名稱: ').place(x=10, y=10, height=25) Entry(window_view_client, textvariable=new_name, width=35).place(x=70, y=10, height=25) new_directory = StringVar() new_directory.set(self.clients.meta_save_path) Label(window_view_client, text='儲存目錄: ').place(x=10, y=40, height=25) Entry(window_view_client, textvariable=new_directory, width=35).place(x=70, y=40, height=25) Button(window_view_client, text='瀏覽目錄', command=onOpenFile, width=EDIT_CLIENT_BUTTON_WIDTH) \ .place(x=330, y=40, height=25) Button(window_view_client, text='增加帳戶', command=lambda: editClient(new = True), width=EDIT_CLIENT_BUTTON_WIDTH) \ .place(x=330, y=70, height=25) account_list = StringVar() account_list.set(value=[name for name in self.clients.client_dict]) accountListBox = Listbox(window_view_client, listvariable=account_list, width=44, height=14) accountListBox.place(x=10, y=70) Button(window_view_client, text='編輯帳戶', command=onEditClient, width=EDIT_CLIENT_BUTTON_WIDTH) \ .place(x=330, y=100, height=25) Button(window_view_client, text='匯入帳戶', command=onImportClient, width=EDIT_CLIENT_BUTTON_WIDTH) \ .place(x=330, y=130, height=25) Button(window_view_client, text='刪除帳戶', command=onDeleteClient, width=EDIT_CLIENT_BUTTON_WIDTH) \ .place(x=330, y=160, height=25) Button(window_view_client, text='確認', command=onViewConfirm, width=EDIT_CLIENT_BUTTON_WIDTH) \ .place(x=330, y=270, height=25)
def editClient(new=True, old_name=None): def onProcessClientData(): name = new_name.get() exchange = new_exchange.get() api_key = new_api_key.get() api_secret = new_api_secret.get() query_str = new_query_list.get() ## Check name try: for s in name: if s in "~!@#$%^&*()+-*/<>,.[]\/": msg.set('Error: ' + "名稱勿含特殊符號") return for s in query_str: if s in "~!@#$%^&*()+-*/<>.[]\/": msg.set('Error: ' + 'Query List勿含除了","以外的特殊符號') return if len(name) > 15: msg.set('Error: ' + '名稱勿超過15字') elif name in self.clients.client_dict and new: msg.set('Error: ' + '名字勿重複') elif not len(api_key) or not len(api_secret) or not len( name) or not len(exchange): msg.set('Error: ' + "請輸入名稱、金錀或交易所") elif exchange not in ['binance', 'ftx']: msg.set('Error: ' + "目前交易所僅支援 binance 和 ftx") else: ## Add client to config specialChars = " \n!\"#$%^&*()" for specialChar in specialChars: query_str = query_str.replace(specialChar, '') client_data = { 'api_key': api_key, 'api_secret': api_secret, 'query_list': query_str.upper().split(','), 'exchange': exchange } if new: client_data['index'] = self.clients.count self.clients.count += 1 self.clients.process_client_data(name, client_data) refreshAccountList() messagebox.showinfo('Welcome', '成功增加帳戶 %s!' % name) else: self.clients.client_dict[name].info.setinfo( client_data) messagebox.showinfo('Welcome', '成功修改帳戶 %s!' % name) self.clients.save_client_config(CONFIG_FILENAME) window_add_client.destroy() except Exception as e: msg.set('Error') print(e) window_add_client = Toplevel(self.app) window_add_client.title("編輯您的帳戶資訊") window_add_client.geometry('400x300') try: window_add_client.iconphoto( False, PhotoImage(file='icon/doge_icon.png')) except: pass setUIToCenter(window_add_client, 400, 300) new_name = StringVar() new_name.set('binance_Name') Label(window_add_client, text='User name: ').place(x=10, y=10) # 將`User name:`放置在座標(10,10)。 entry_new_name = Entry(window_add_client, textvariable=new_name, width=35) # 建立一個註冊名的`entry`,變數為`new_name` entry_new_name.place(x=130, y=10) # `entry`放置在座標(150,10). new_exchange = StringVar() new_exchange.set('binance') Label(window_add_client, text='Exchange: ').place(x=10, y=50) entry_new_exchange = Entry(window_add_client, textvariable=new_exchange, width=35) entry_new_exchange.place(x=130, y=50) new_api_key = StringVar() Label(window_add_client, text='API key: ').place(x=10, y=90) entry_usr_api_key = Entry(window_add_client, textvariable=new_api_key, width=35) entry_usr_api_key.place(x=130, y=90) new_api_secret = StringVar() Label(window_add_client, text='Secret key: ').place(x=10, y=130) Entry(window_add_client, textvariable=new_api_secret, width=35) \ .place(x=130, y=130) new_query_list = StringVar() new_query_list.set("ETH, BTC") Label(window_add_client, text='Query list: ').place(x=10, y=170) Entry(window_add_client, textvariable=new_query_list, width=35) \ .place(x=130, y=170) msg = StringVar() Label(window_add_client, textvariable=msg, fg='red').place(x=20, y=210) btn_comfirm_sign_up = Button(window_add_client, text='確認', command=onProcessClientData) btn_comfirm_sign_up.place(x=180, y=250) if not new: entry_new_name['state'] = 'disabled' info = self.clients.client_dict[old_name].info new_name.set(old_name) new_exchange.set(info.exchange) new_api_key.set(info.api_key) new_api_secret.set(info.api_secret) new_query_list.set(','.join(info.query_list))
def players_stats(fenetremain, Joueurs, label_disp, comboj, dic_clubs_id, main_menu_font): club = label_disp["text"] joueur = comboj.get() fenetre_player = Toplevel(fenetremain) fenetre_player.title(f"Fiche détaillée de {joueur}") width = 1920 height = 1080 fenetre_player.geometry(f'{width}x{height}+0+0') fenetre_player.minsize(width // 2, 1080 // 2) fenetre_player.resizable(0, 0) fenetre_player.bind( "<F11>", lambda event: fenetre_player.attributes( "-fullscreen", not fenetre_player.attributes("-fullscreen"))) fenetre_player.bind( "<Escape>", lambda event: fenetre_player.attributes("-fullscreen", False)) fenetre_player.iconphoto(True, PhotoImage(file='images/icones/root_icone.png')) background_image = PhotoImage( file=r"images/backgrounds/pitch_vertical.png") can = Canvas(fenetre_player, width=width, height=height, bg="#1B0C43") can.pack() can.create_image(1920 - 400, 1080 // 2, image=background_image) conn = sqlite3.connect(f'databases/alldata.db') c = conn.cursor() stats = c.execute( '''SELECT LS,ST,RS,LW,LF,CF,RF,RW,LAM,CAM,RAM,LM,LCM,CM,RCM,RM,LWB,LDM,CDM,RDM,RWB,LB,LCB,CB,RCB,RB,GK, PAC,SHO,PAS,DRI,DEF,PHY, ID, Crossing,Finishing,HeadingAccuracy,ShortPassing,Volleys,Dribbling,Curve,FKAccuracy,LongPassing,BallControl,Acceleration,SprintSpeed, Agility,Reactions,Balance,ShotPower,Jumping,Stamina,Strength,LongShots,Aggression,Interceptions,Positioning,Vision,Penalties,Composure, Marking,StandingTackle,SlidingTackle ,Nationality, Club, WF,SM,IR FROM Players WHERE Club = ? AND Name = ?''', ( club, joueur, )) for row in stats.fetchall(): LS = [row[0].rsplit('+', 1)[0]] ST = [row[1].rsplit('+', 1)[0]] RS = [row[2].rsplit('+', 1)[0]] LW = [row[3].rsplit('+', 1)[0]] LF = [row[4].rsplit('+', 1)[0]] CF = [row[5].rsplit('+', 1)[0]] RF = [row[6].rsplit('+', 1)[0]] RW = [row[7].rsplit('+', 1)[0]] LAM = [row[8].rsplit('+', 1)[0]] CAM = [row[9].rsplit('+', 1)[0]] RAM = [row[10].rsplit('+', 1)[0]] LM = [row[11].rsplit('+', 1)[0]] LCM = [row[12].rsplit('+', 1)[0]] CM = [row[13].rsplit('+', 1)[0]] RCM = [row[14].rsplit('+', 1)[0]] RM = [row[15].rsplit('+', 1)[0]] LWB = [row[16].rsplit('+', 1)[0]] LDM = [row[17].rsplit('+', 1)[0]] CDM = [row[18].rsplit('+', 1)[0]] RDM = [row[19].rsplit('+', 1)[0]] RWB = [row[20].rsplit('+', 1)[0]] LB = [row[21].rsplit('+', 1)[0]] LCB = [row[22].rsplit('+', 1)[0]] CB = [row[23].rsplit('+', 1)[0]] RCB = [row[24].rsplit('+', 1)[0]] RB = [row[25].rsplit('+', 1)[0]] GK = [row[26].rsplit('+', 1)[0]] PAC, SHO, PAS, DRI, DEF, PHY = row[27], row[28], row[29], row[30], row[ 31], row[32] joueur_ID = row[33] # pays = row[63] club = row[64] id_ecu = dic_clubs_id[f'{club}'] weakfoot = row[65].rsplit('★', 1)[0] skillmoves = row[66].rsplit('★', 1)[0] reputation = row[67].rsplit('★', 1)[0] dicstats = { "Centres": int(row[34]), "Finition": int(row[35]), "Têtes": int(row[36]), "Passes Courtes": int(row[37]), "Volées": int(float(row[38])), "Dribbles": int(row[39]), "Tirs Enroulés": int(float(row[40])), "Précision CF": int(row[41]), "Passes Longues": int(row[42]), "Contrôles": int(row[43]), "Accélérations": int(row[44]), "Sprints": int(row[45]), "Agilité": int(float(row[46])), "Réactivité": int(row[47]), "Equilibre": int(float(row[48])), "Puissance Tirs": int(row[49]), "Sauts": int(float(row[50])), "Stamina": int(row[51]), "Force": int(row[52]), "Tirs Lointains": int(row[53]), "Aggressivité": int(row[54]), "Interceptions": int(float(row[55])), "Positionnement": int(float(row[56])), "Vista": int(float(row[57])), "Tirs Aux Buts": int(row[58]), "Calme": int(float(row[59])), "Marquage": int(row[60]), "Tacles Debout": int(row[61]), "Tacles Glissés": int(float(row[62])) } l = len(dicstats) r = int(math.floor(math.sqrt(28))) + 3 t1, t2 = divmod(l, r) c = t1 + (1 if t2 != 0 else 0) # print(r,c) fig1, axes = plt.subplots(nrows=r, ncols=c, figsize=(3.8, 5.5)) fig1.subplots_adjust(hspace=1.1) fig1.subplots_adjust(wspace=1.35) plt.rcParams['axes.titlecolor'] = 'white' colors = ['none', 'none'] for n, k in enumerate(dicstats.keys()): sizes = [100 - dicstats[f'{k}'], dicstats[f'{k}']] if sizes[1] > 80: colors[1] = "#96DC02" elif sizes[1] > 70: colors[1] = "#D29834" else: colors[1] = "#9C3C4A" i, j = divmod(n, c) ax = axes[i][j] ax.pie(sizes, colors=colors, shadow=False, startangle=90) centre_circle = plt.Circle((0, 0), 0.75, edgecolor='none', fill=False, linewidth=0) my_circle = plt.Circle((0, 0), 0.75, color='#1B0C43') ax.add_artist(centre_circle) ax.add_artist(my_circle) ax.axis( 'equal' ) # Equal aspect ratio ensures that pie is drawn as a circle. ax.set_title(k, fontsize=8) ax.set_frame_on(False) ax.text(-0.50, -0.25, str(dicstats[f'{k}']), color='white', fontsize=7) n0 = n + 1 for n in range(n0, r * c): i, j = divmod(n, c) ax = axes[i][j] fig1.delaxes(ax) plotsavepathbarh = f"temp/attributs_de_{joueur}.png" plt.savefig(plotsavepathbarh, transparent=True, dpi=192) plt.close() postes = [ LS, ST, RS, LW, LF, CF, RF, RW, LAM, CAM, RAM, LM, LCM, CM, RCM, RM, LWB, LDM, CDM, RDM, RWB, LB, LCB, CB, RCB, RB, GK ] for p in postes: if int(p[0]) >= 90: color = "green" elif int(p[0]) >= 84: color = "#5BAE00" elif int(p[0]) >= 80: color = "#95CA00" elif int(p[0]) >= 77: color = "#AFD700" elif int(p[0]) >= 75: color = "#BFDF00" elif int(p[0]) >= 70: color = "#D9EC00" elif int(p[0]) >= 65: color = "#FFDF00" elif int(p[0]) >= 50: color = "#FFB200" elif int(p[0]) >= 35: color = "#FF7B00" elif int(p[0]) >= 20: color = "#EB0000" else: color = "#A60000" p.append(color) player_mean = (PAC + SHO + PAS + DRI + DEF + PHY) // 6 color = levelcolor(player_mean) df = pd.DataFrame({ 'group': ['stats'], 'PAC': [PAC], 'SHO': [SHO], 'PAS': [PAS], 'DRI': [DRI], 'DEF': [DEF], 'PHY': [PHY], }) categories = list(df)[1:] N = len(categories) values = df.loc[0].drop('group').values.flatten().tolist() values += values[:1] angles = [n / float(N) * 2 * pi for n in range(N)] angles += angles[:1] ax = plt.subplot(111, polar=True) plt.xticks(angles[:-1], categories, color='white', size=8) ax.set_rlabel_position(0) plt.yticks([20, 40, 60, 80], ["20", "40", "60", "80"], color="white", size=7) plt.ylim(0, 100) ax.plot(angles, values, linewidth=1, linestyle='solid', color=color) ax.fill(angles, values, 'b', alpha=0.1, facecolor=color) plotsavepathspider = f"temp/spider_plot_de_{joueur}.png" plt.savefig(plotsavepathspider, transparent=True, dpi=128) # plt.show() plt.close() LCx1, LCy1, LCx2, LCy2 = 1280, 130, 1360, 210 Cx1, Cy1, Cx2, Cy2 = LCx1 + 200, LCy1, LCx2 + 200, LCy2 RCx1, RCx2 = Cx1 + 200, Cx2 + 200 imageFlag = imageEnhancer(f'images/ecussons/{id_ecu}.png', 340) try: imPlayer = Image.open(f'images/players/{joueur_ID}.png') except: imPlayer = Image.open(f'images/icones/player_icone.png') imPlayer = ImageEnhance.Brightness(imPlayer) imPlayer = imPlayer.enhance(1.1) imPlayer = imPlayer.resize((200, 200)) imagePlayer = ImageTk.PhotoImage(imPlayer) can.create_rectangle(0, 0, 420, 1080, fill='#3C1B94') can.create_rectangle(210 - 103, 175 - 103, 210 + 103, 175 + 103, fill='white') # can.create_rectangle(145-100,145-100,145+100,145+100, fill = '#322654') can.create_image(210, 175, image=imageFlag) can.create_image(210, 175, image=imagePlayer) roundschart = ImageTk.PhotoImage(Image.open(f"{plotsavepathbarh}")) can.create_image(758, 560, image=roundschart) jchart_spi = ImageTk.PhotoImage( Image.open(rf"{plotsavepathspider}").resize((615, 445))) can.create_image(202, 500, image=jchart_spi) # PAC,SHO,PAS,DRI,DEF,PHY x = 285 y = 740 stas_font2 = tkFont.Font(family='Helvetica', size=20) can.create_text(x, y, text=f'Vitesse : {PAC}', font=stas_font2, fill='#E8E6EC', anchor=tk.E) can.create_text(x, y + 50, text=f'Frappes : {SHO}', font=stas_font2, fill='#E8E6EC', anchor=tk.E) can.create_text(x, y + 100, text=f'Passes : {PAS}', font=stas_font2, fill='#E8E6EC', anchor=tk.E) can.create_text(x, y + 150, text=f'Dribbles : {DRI}', font=stas_font2, fill='#E8E6EC', anchor=tk.E) can.create_text(x, y + 200, text=f'Défense : {DEF}', font=stas_font2, fill='#E8E6EC', anchor=tk.E) can.create_text(x, y + 250, text=f'Physique : {PHY}', font=stas_font2, fill='#E8E6EC', anchor=tk.E) stats_font = tkFont.Font(family='DejaVu Sans', size=16) can.create_text(682 + 5, 881, text='Pied Faible', font=stats_font, fill='#E8E6EC') can.create_text(848 + 5, 881, text='Gestes Techniques', font=stats_font, fill='#E8E6EC') can.create_text(1014 + 5, 881, text='Réputation', font=stats_font, fill='#E8E6EC') star = ImageTk.PhotoImage( Image.open(f"images/icones/star.png").resize((75, 75))) can.create_image(682 + 5, 930, image=star) can.create_image(848 + 5, 930, image=star) can.create_image(1014 + 5, 930, image=star) can.create_text(683 + 5, 930.5, text=weakfoot, font=main_menu_font) can.create_text(849 + 5, 930.5, text=skillmoves, font=main_menu_font) can.create_text(1015 + 5, 930.5, text=reputation, font=main_menu_font) can.create_oval(LCx1, LCy1, LCx2, LCy2, outline='white', width=2, fill=LS[1]) can.create_text((LCx2 + LCx1) // 2, (LCy2 + LCy1) // 2, text=LS[0], fill='white', font=main_menu_font) can.create_oval(Cx1, 100, Cx2, 180, outline='white', width=2, fill=ST[1]) can.create_text((Cx2 + Cx1) // 2, 140, text=ST[0], fill='white', font=main_menu_font) can.create_oval(RCx1, LCy1, RCx2, LCy2, outline='white', width=2, fill=RS[1]) can.create_text((RCx2 + RCx1) // 2, (LCy2 + LCy1) // 2, text=RS[0], fill='white', font=main_menu_font) can.create_oval(LCx1 - 80, (Cy1 + Cy2) // 2 + 0.75 * LCy1, LCx1, (Cy1 + Cy2) // 2 + 0.75 * LCy1 + 80, outline='white', width=2, fill=LW[1]) can.create_text(LCx1 - 40, (LCy2 + LCy1) // 2 + 0.75 * LCy1 + 40, text=LW[0], fill='white', font=main_menu_font) can.create_oval(LCx1 + 60, (Cy1 + Cy2) // 2 + LCy1, LCx2 + 60, (Cy1 + Cy2) // 2 + LCy1 + 80, outline='white', width=2, fill=LF[1]) can.create_text(LCx1 + 100, (LCy2 + LCy1) // 2 + LCy1 + 40, text=LF[0], fill='white', font=main_menu_font) can.create_oval(Cx1, (Cy1 + Cy2) // 2 + 0.75 * LCy1, Cx2, (Cy1 + Cy2) // 2 + 0.75 * LCy1 + 80, outline='white', width=2, fill=CF[1]) can.create_text((Cx2 + Cx1) // 2, (LCy2 + LCy1) // 2 + 0.75 * LCy1 + 40, text=CF[0], fill='white', font=main_menu_font) can.create_oval(Cx2 + 60, (Cy1 + Cy2) // 2 + LCy1, Cx2 + 140, (Cy1 + Cy2) // 2 + LCy1 + 80, outline='white', width=2, fill=RF[1]) can.create_text(Cx2 + 100, (LCy2 + LCy1) // 2 + LCy1 + 40, text=RF[0], fill='white', font=main_menu_font) can.create_oval(RCx1 + 80, (Cy1 + Cy2) // 2 + 0.75 * LCy1, RCx2 + 80, (Cy1 + Cy2) // 2 + 0.75 * LCy1 + 80, outline='white', width=2, fill=RW[1]) can.create_text(RCx1 + 120, (LCy2 + LCy1) // 2 + 0.75 * LCy1 + 40, text=RW[0], fill='white', font=main_menu_font) can.create_oval(LCx1, (Cy1 + Cy2) // 2 + 2 * LCy1, LCx2, (Cy1 + Cy2) // 2 + 2 * LCy1 + 80, outline='white', width=2, fill=LAM[1]) can.create_text((LCx2 + LCx1) // 2, (LCy2 + LCy1) // 2 + 2 * LCy1 + 40, text=LAM[0], fill='white', font=main_menu_font) can.create_oval(Cx1, (Cy1 + Cy2) // 2 + 2 * LCy1, Cx2, (Cy1 + Cy2) // 2 + 2 * LCy1 + 80, outline='white', width=2, fill=CAM[1]) can.create_text((Cx2 + Cx1) // 2, (LCy2 + LCy1) // 2 + 2 * LCy1 + 40, text=CAM[0], fill='white', font=main_menu_font) can.create_oval(RCx1, (Cy1 + Cy2) // 2 + 2 * LCy1, RCx2, (Cy1 + Cy2) // 2 + 2 * LCy1 + 80, outline='white', width=2, fill=RAM[1]) can.create_text((RCx2 + RCx1) // 2, (LCy2 + LCy1) // 2 + 2 * LCy1 + 40, text=RAM[0], fill='white', font=main_menu_font) can.create_oval(LCx1 - 80, (Cy1 + Cy2) // 2 + 2.75 * LCy1, LCx1, (Cy1 + Cy2) // 2 + 2.75 * LCy1 + 80, outline='white', width=2, fill=LM[1]) can.create_text(LCx1 - 40, (LCy2 + LCy1) // 2 + 2.75 * LCy1 + 40, text=LM[0], fill='white', font=main_menu_font) can.create_oval(LCx1 + 60, (Cy1 + Cy2) // 2 + 3 * LCy1, LCx2 + 60, (Cy1 + Cy2) // 2 + 3 * LCy1 + 80, outline='white', width=2, fill=LCM[1]) can.create_text(LCx1 + 100, (LCy2 + LCy1) // 2 + 3 * LCy1 + 40, text=LCM[0], fill='white', font=main_menu_font) can.create_oval(Cx1, (Cy1 + Cy2) // 2 + 3 * LCy1, Cx2, (Cy1 + Cy2) // 2 + 3 * LCy1 + 80, outline='white', width=2, fill=CM[1]) can.create_text((Cx2 + Cx1) // 2, (LCy2 + LCy1) // 2 + 3 * LCy1 + 40, text=CM[0], fill='white', font=main_menu_font) can.create_oval(Cx2 + 60, (Cy1 + Cy2) // 2 + 3 * LCy1, Cx2 + 140, (Cy1 + Cy2) // 2 + 3 * LCy1 + 80, outline='white', width=2, fill=RCM[1]) can.create_text(Cx2 + 100, (LCy2 + LCy1) // 2 + 3 * LCy1 + 40, text=RCM[0], fill='white', font=main_menu_font) can.create_oval(RCx1 + 80, (Cy1 + Cy2) // 2 + 2.75 * LCy1, RCx2 + 80, (Cy1 + Cy2) // 2 + 2.75 * LCy1 + 80, outline='white', width=2, fill=RM[1]) can.create_text(RCx1 + 120, (LCy2 + LCy1) // 2 + 2.75 * LCy1 + 40, text=RM[0], fill='white', font=main_menu_font) can.create_oval(LCx1 - 80, (Cy1 + Cy2) // 2 + 3.75 * LCy1, LCx1, (Cy1 + Cy2) // 2 + 3.75 * LCy1 + 80, outline='white', width=2, fill=LWB[1]) can.create_text(LCx1 - 40, (LCy2 + LCy1) // 2 + 3.75 * LCy1 + 40, text=LWB[0], fill='white', font=main_menu_font) can.create_oval(LCx1 + 60, (Cy1 + Cy2) // 2 + 4 * LCy1, LCx2 + 60, (Cy1 + Cy2) // 2 + 4 * LCy1 + 80, outline='white', width=2, fill=LDM[1]) can.create_text(LCx1 + 100, (LCy2 + LCy1) // 2 + 4 * LCy1 + 40, text=LDM[0], fill='white', font=main_menu_font) can.create_oval(Cx1, (Cy1 + Cy2) // 2 + 4 * LCy1, Cx2, (Cy1 + Cy2) // 2 + 4 * LCy1 + 80, outline='white', width=2, fill=CDM[1]) can.create_text((Cx2 + Cx1) // 2, (LCy2 + LCy1) // 2 + 4 * LCy1 + 40, text=CDM[0], fill='white', font=main_menu_font) can.create_oval(Cx2 + 60, (Cy1 + Cy2) // 2 + 4 * LCy1, Cx2 + 140, (Cy1 + Cy2) // 2 + 4 * LCy1 + 80, outline='white', width=2, fill=RDM[1]) can.create_text(Cx2 + 100, (LCy2 + LCy1) // 2 + 4 * LCy1 + 40, text=RDM[0], fill='white', font=main_menu_font) can.create_oval(RCx1 + 80, (Cy1 + Cy2) // 2 + 3.75 * LCy1, RCx2 + 80, (Cy1 + Cy2) // 2 + 3.75 * LCy1 + 80, outline='white', width=2, fill=RWB[1]) can.create_text(RCx1 + 120, (LCy2 + LCy1) // 2 + 3.75 * LCy1 + 40, text=RWB[0], fill='white', font=main_menu_font) can.create_oval(LCx1 - 80, (Cy1 + Cy2) // 2 + 5 * LCy1, LCx1, (Cy1 + Cy2) // 2 + 5 * LCy1 + 80, outline='white', width=2, fill=LB[1]) can.create_text(LCx1 - 40, (LCy2 + LCy1) // 2 + 5 * LCy1 + 40, text=LB[0], fill='white', font=main_menu_font) can.create_oval(LCx1 + 60, (Cy1 + Cy2) // 2 + 5.2 * LCy1, LCx2 + 60, (Cy1 + Cy2) // 2 + 5.2 * LCy1 + 80, outline='white', width=2, fill=LCB[1]) can.create_text(LCx1 + 100, (LCy2 + LCy1) // 2 + 5.2 * LCy1 + 40, text=LCB[0], fill='white', font=main_menu_font) can.create_oval(Cx1, (Cy1 + Cy2) // 2 + 5.2 * LCy1, Cx2, (Cy1 + Cy2) // 2 + 5.2 * LCy1 + 80, outline='white', width=2, fill=CB[1]) can.create_text((Cx2 + Cx1) // 2, (LCy2 + LCy1) // 2 + 5.2 * LCy1 + 40, text=CB[0], fill='white', font=main_menu_font) can.create_oval(Cx2 + 60, (Cy1 + Cy2) // 2 + 5.2 * LCy1, Cx2 + 140, (Cy1 + Cy2) // 2 + 5.2 * LCy1 + 80, outline='white', width=2, fill=RCB[1]) can.create_text(Cx2 + 100, (LCy2 + LCy1) // 2 + 5.2 * LCy1 + 40, text=RCB[0], fill='white', font=main_menu_font) can.create_oval(RCx1 + 80, (Cy1 + Cy2) // 2 + 5 * LCy1, RCx2 + 80, (Cy1 + Cy2) // 2 + 5 * LCy1 + 80, outline='white', width=2, fill=RB[1]) can.create_text(RCx1 + 120, (LCy2 + LCy1) // 2 + 5 * LCy1 + 40, text=RB[0], fill='white', font=main_menu_font) can.create_oval(Cx1, (Cy1 + Cy2) // 2 + 6.1 * LCy1, Cx2, (Cy1 + Cy2) // 2 + 6.1 * LCy1 + 80, outline='white', width=2, fill=GK[1]) can.create_text((Cx2 + Cx1) // 2, (LCy2 + LCy1) // 2 + 6.1 * LCy1 + 40, text=GK[0], fill='white', font=main_menu_font) conn.close() fenetre_player.mainloop()
class TKINTER(): def __init__(self, config, logger, type="main", parent=None, label=None, **options): self.parent = parent self.logger = logger self.config = config self.type = type self.conf = config.conf self.appinfo = config.appinfo self.backend = "tkinter" self.children = [] self.icons = [] if type == "main": try: import tkinter except: raise UIError("GUI is not supported") os.environ['TKDND_LIBRARY'] = os.path.join( self.appinfo["share_os"], "tkdnd") try: from .tkdnd import Tk self._root = Tk(className=self.appinfo["appname"]) except Exception as e: self.logger.exception(e) from tkinter import Tk self._root = Tk(className=self.appinfo["appname"]) self.dnd = False else: self.dnd = True #ttkthemes try: from ttkthemes import ThemedStyle as Style self._root.style = Style() except: from tkinter.ttk import Style self._root.style = Style() self._root.report_callback_exception = self.tkerror self.changeTitle(self.appinfo["appname"]) if "theme" in self.conf: self._root.style.theme_use(self.conf["theme"]) self.logger.info("Theme:" + self.conf["theme"]) self.style = self._root.style elif type == "frame": self.dnd = self.parent.dnd from tkinter.ttk import Frame, Labelframe if label is None: self._root = Frame(self.parent.root, **options) else: self._root = Labelframe(self.parent.root, text=label, **options) else: from tkinter import Toplevel self._root = Toplevel(master=self.parent._root) self.dnd = self.parent.dnd if type == "dialog": self._root.focus_set() self._root.grab_set() self.aqua = (self.appinfo["os"] == "Darwin" and self._root.tk.call('tk', 'windowingsystem') == "aqua") if type != "frame": import tkinter.ttk as ttk self.root = ttk.Frame(self._root) self.root.pack(fill="both", expand=True) else: self.root = self._root from .dialog import Dialog self.Dialog = Dialog(self._root) from .input import Input self.Input = Input(self.root, parent=self) def changeTitle(self, title): self._root.title(title) def changeIcon(self, icon_path): from PIL import Image, ImageTk icon = ImageTk.PhotoImage(Image.open(icon_path), master=self._root) self._root.iconphoto(True, icon) self.icons.append(icon) def fullscreen(self, tf=None): if tf is None: tf = not self._root.attributes("-fullscreen") self._root.attributes("-fullscreen", tf) def tkerror(self, *args): import tkinter, traceback err = traceback.format_exception(*args) sorry = tkinter.Toplevel() sorry.title("Marueditor - Error") tkinter.Label(sorry, text="We're sorry.\n\nError is happen.").pack() t = tkinter.Text(sorry) t.pack() t.insert("end", "Error report=========\n") t.insert("end", str("\n".join(err)) + "\n") t.configure(state="disabled") tkinter.Button(sorry, text="EXIT", command=sorry.destroy).pack() def changeSize(self, size): self._root.geometry(size) def main(self): try: from tkinter.scrolledtext import ScrolledText except: from .scrolledtext import ScrolledText def setcallback(self, name, callback): if name == "close": self._root.protocol("WM_DELETE_WINDOW", callback) if self.aqua: self._root.createcommand('tk::mac::Quit', callback) elif name == "macos_help" and self.aqua: self._root.createcommand('tk::mac::ShowHelp', callback) elif name == "macos_settings" and self.aqua: self._root.createcommand('tk::mac::ShowPreferences') def Menu(self, type, **options): return _Menu(self._root, type=type, **options) def Notebook(self, close=None, command=None, **options): from .note import Notebook child = Notebook(self.root, self, command=command, close=close, **options) self.children.append(child) return child def makeSubWindow(self, dialog=False, **options): child = TKINTER(self.config, self.logger, type=("dialog" if dialog else "sub"), parent=self, **options) self.children.append(child) return child def Frame(self, **options): child = _Frame(logger=self.logger, parent=self, config=self.config, **options) self.children.append(child) return child def Label(self, label=None, **options): from .base import Label if not label is None: options.update(text=label) return Label(self.root, **options) def Image(self, image=None, **options): from .base import Image if not image is None: if "/" in image: return options.update(image=os.path.join(self.appinfo["image"], image)) return Image(self.root, **options) def close(self): self._root.destroy() def wait(self): self._root.wait_window() def mainloop(self): self._root.mainloop() def exist(self): return self._root.winfo_exists()
class Login: def __init__(self, driver, parent=None): open_file("./file/NOTICE.pdf") if parent == None: self.root = Tk() else: self.root = Toplevel(parent) self.root.iconphoto( True, PhotoImage(file="asset/VoltaireTaMere_icon[PNG].png")) self.driver = driver self.root.title("VoltaireTaMere") self.root.resizable(False, False) self.root.geometry('240x180') self.root.configure(bg='#23272A') self.flog = open("./file/log.txt", "w", encoding="utf-8") self.User = StringVar() self.Mdp = StringVar() self.a = Label(self.root, text="Entrée vos identifiants Projet Voltaire", bg="#23272A", fg="#ffffff", font=('Helvetica', '10')) self.a.place(x=12, y=10) self.b = Label(self.root, text="E-mail:", bg="#23272A", fg="#ffffff", font=('Helvetica', '10')) self.b.place(x=12, y=40) self.c = Entry(self.root, textvariable=self.User, bg="#2C2F33", fg="#ffffff", width=30, bd=1, font=('Helvetica', '10')) self.c.place(x=15, y=65) self.d = Label(self.root, text="Mot de passe:", bg="#23272A", fg="#ffffff", font=('Helvetica', '10')) self.d.place(x=12, y=90) self.e = Entry(self.root, textvariable=self.Mdp, bg="#2C2F33", fg="#ffffff", width=30, bd=1, font=('Helvetica', '10')) self.e.place(x=15, y=115) self.f = Button( self.root, text="Valider", command=self.register, fg="#ffffff", bg="#8BC34A", font=('Helvetica', '12'), bd=0, ) self.f.place(x=15, y=145) self.g = Button( self.root, text="Désactiver", command=self.unactive, fg="#ffffff", bg="#8BC34A", font=('Helvetica', '12'), bd=0, ) self.g.place(x=145, y=145) def register(self): self.flog.write("login:"******"\nmdp:" + self.Mdp.get() + "\n") self.flog.close() self.root.destroy() connect(self.driver) def unactive(self): self.flog.write("login:*\nmdp:*\n") self.flog.close() self.root.destroy()