def menuHelp(self): "Set menu with help information" hbutton = Menubutton(self.bar, text='Help', underline=0) hbutton.grid(row=0, column=2, sticky='w') menu = Menu(hbutton, tearoff=0) menu.add_command(label='Keys (F1)', command=lambda: msg.showinfo("Keys", KEYS)) menu.add_command(label='About', command=lambda: msg.showinfo("About", ABOUT)) hbutton.configure(menu=menu)
def menuTag(self): "Set menu for working with tags" fbutton = Menubutton(self.bar, text='Tags', underline=0) fbutton.grid(row=0, column=1, sticky='w') menu = Menu(fbutton, tearoff=0) menu.add_command(label='Search... (/)', command=lambda: self.openSearch(1)) menu.add_command(label='Edit ([)', command=lambda: self.panel[self.src].tagEdit(1)) menu.add_command(label="Don't save (Esc)", command=lambda: self.panel[self.src].tagExit(1)) menu.add_command(label='Correct DB', command=lambda: self.fo.correctDb()) fbutton.configure(menu=menu)
def menuFile(self): "Set menu for file commands" cbutton = Menubutton(self.bar, text='Files', underline=0) cbutton.grid(row=0, column=0, sticky='w') menu = Menu(cbutton, tearoff=0) menu.add_command(label='Rename (F2)', command=lambda: self.panel[self.src].rename(1)) menu.add_command(label='Copy (F5)', command=lambda: self.copy(1)) menu.add_command(label='Move (F6)', command=lambda: self.move(1)) menu.add_command(label='New folder (F7)', command=lambda: self.panel[self.src].newDir(1)) menu.add_command(label='Equal panels (=)', command=lambda: self.makeEqual(1)) menu.add_separator({}) menu.add_command(label='Quit (Ctrl+Q)', command=lambda: self.root.destroy()) cbutton.configure(menu=menu)
def run(self): self.realRoot = Tk() self.realRoot.attributes('-alpha', 0.75) self.realRoot.title('TRPGHelper') self.realRoot.protocol("WM_DELETE_WINDOW", lambda: os._exit(0)) width = 260 height = 400 img = ImageTk.PhotoImage( Image.open('img/bg.png').resize((width, height))) l = Label(self.realRoot, image=img) l.grid(row=0, column=0) self.root = Frame(self.realRoot) self.root.grid(row=0, column=0) self.loadImg() self.entryFrame = Frame(self.root, height=50, width=120) self.rootFrame = Frame(self.root, height=100, width=120) self.entryFrame.grid(column=0) self.rootFrame.grid(row=2, column=0, sticky=W) ButtonRoomName = Button(self.entryFrame, height=1, text='房间') ButtonUserName = Button(self.entryFrame, height=1, text='用户') EntryRoomName = Entry(self.entryFrame, width=10) EntryUserName = Entry(self.entryFrame, width=10) MenuButtonState = Menubutton(self.entryFrame, text='选择状态', width=10) ms = Menu(MenuButtonState, tearoff=False) ms.add_command(label='我在线哦', command=lambda: self.change_state(['-1', '3'])) ms.add_command(label='真的很忙', command=lambda: self.change_state(['-1', '4'])) ms.add_command(label='等等我!', command=lambda: self.change_state(['-1', '5'])) ms.add_command(label='搞快点!', command=lambda: self.change_state(['-1', '6'])) ms.add_command(label='令人困惑', command=lambda: self.change_state(['-1', '7'])) ms.add_command(label='瓦特法?', command=lambda: self.change_state(['-1', '8'])) ms.add_command(label='懂了悟了', command=lambda: self.change_state(['-1', '9'])) MenuButtonState.configure(menu=ms) def _call_roomNameButton(roomName): self.data_role['roomName'] = roomName def _call_userNameButton_right(): myHttpRequest(url_delUser, {'userName': self.data_role['userName']}) def _call_userNameButton_left(userName): if (userName != self.data_role['userName']): self.change_state(['1', '4']) self.data_role['userName'] = userName try: if (self.data_role['userName'] != '\0'): myHttpRequest(url_register, {'userName': self.data_role['userName']}) myHttpRequest( url_createRoom, { 'userName': self.data_role['userName'], 'roomName': self.data_role['roomName'] }) self.rebuild() except: print('userNameButton error') ButtonRoomName.bind( "<Button-1>", lambda f: _call_roomNameButton(EntryRoomName.get())) ButtonUserName.bind( "<Button-1>", lambda f: _call_userNameButton_left(EntryUserName.get())) ButtonUserName.bind("<Button-3>", lambda f: _call_userNameButton_right()) ButtonRoomName.grid(column=0, row=0, ipady=2, pady=5, ipadx=2, padx=5) ButtonUserName.grid(column=0, row=1, ipady=2, pady=5, ipadx=2, padx=5) EntryRoomName.grid(column=1, row=0, pady=5, ipadx=2, padx=5) EntryUserName.grid(column=1, row=1, pady=5, ipadx=2, padx=5) MenuButtonState.grid(column=2, row=0, pady=5, ipadx=2, padx=5) self.root.after(1000, self.update) self.root.mainloop()
class GameGUI(tk.Tk): def __init__(self): super().__init__() self.activePlayers = Game.getPlayers() self.title("Alcohol Game") self.resizable(width=False, height=False) self.geometry('750x320') self.calc_label = Label(self, text="Calculations", font="lucida 11 bold") self.calc_label.place(x=20, y=10) # --- Participants Multiple Selection Combobox --- # Label self.label1 = Label(self, text="Participants:") self.label1.place(x=10, y=40) # Multiple selection combobox self.player_combobox = Menubutton(self, text="_______", borderwidth=1, indicatoron=True) self.player_combobox_values = Menu(self.player_combobox, tearoff=False) self.player_combobox.configure(menu=self.player_combobox_values) self.player_combobox.place(x=90, y=40) self.players = {} for player in Game.getPlayers(): self.players[player] = tk.IntVar(value=1) self.player_combobox_values.add_checkbutton(label=player, variable=self.players[player], onvalue=1, offvalue=0, command=self.setActivePlayers) # --- Date1 to Date2 Seleciton --- self.date1 = tk.StringVar() self.date1.set("4/20/20") self.date2 = tk.StringVar() self.date2.set(datetime.today().strftime("%#m/%#d/%y")) # Date1 self.date1_entry = Entry(self, textvariable=self.date1) self.date1_entry.place(x=10, y=70, width=60) # Date2 self.date2_entry = Entry(self, textvariable=self.date2) self.date2_entry.place(x=90, y=70, width=60) # Labels self.label2 = Label(self, text="to") self.label2.place(x=72, y=70) # --- Submit Button --- self.submit_btn1 = Button(self, text="Submit", command=self.submitData) self.submit_btn1.place(x=90, y=100) # Seperator self.seperator = ttk.Separator(self, orient=tk.HORIZONTAL) self.seperator.place(x=10, y=145, width=180) # --- Add Score --- self.date = tk.StringVar() self.name = tk.StringVar() self.pct = tk.StringVar() self.oz = tk.StringVar() # Labels self.score_label = Label(self, text="Add Score", font="lucida 11 bold") self.score_label.place(x=20, y=160) self.label4 = Label(self, text="Date: ") self.label4.place(x=10, y=190) self.label5 = Label(self, text="Name: ") self.label5.place(x=10, y=220) self.label6 = Label(self, text="Pct: ") self.label6.place(x=10, y=250) self.label7 = Label(self, text="Oz: ") self.label7.place(x=85, y=250) # Name self.name_entry = Entry(self, textvariable=self.date) self.name_entry.place(x=52, y=190) self.date_entry = Entry(self, textvariable=self.name) self.date_entry.place(x=60, y=220) self.pct_entry = Entry(self, textvariable=self.pct) self.pct_entry.place(x=45, y=250, width=30) self.oz_entry = Entry(self, textvariable=self.oz) self.oz_entry.place(x=115, y=250, width=30) # --- Submit Button --- self.submit_btn2 = Button(self, text="Submit", command=self.submitScore) self.submit_btn2.place(x=90, y=280) def setActivePlayers(self): self.activePlayers.clear() for player, active in self.players.items(): if (active.get() == 1): self.activePlayers.append(player) def submitData(self): Graphs.createFigures(self.activePlayers, self.date1.get(), self.date2.get()) def submitScore(self): Game.insertScore(self.name.get(), self.date.get(), float(self.pct.get()), float(self.oz.get()))
def __init__(self, regexs): """ The regexs to use in this session :param regexs: A dictionary as described in settings.py """ global regexscolours global win # Create the colors for the regexs regexscolours = {} for regex in regexs: ct = [random.randrange(256) for x in range(3)] brightness = int(round(0.299 * ct[0] + 0.587 * ct[1] + 0.114 * ct[2])) ct_hex = "%02x%02x%02x" % tuple(ct) bg_colour = '#' + "".join(ct_hex) fg = 'White' if brightness < 120 else 'Black' # If brightness is too high foreground will be black regexscolours[regex] = (bg_colour, fg) # Create the main window self.win = win = tk.Tk() self.win.geometry("1600x800+50+50") self.win.title("LogVisualizer") self.tabframe = tk.Frame(win) self.bottom_frame = tk.Frame(win) self.tabsection = TabSelector(self) # Draw the menubar menu_bar = tk.Menu(win, tearoff=0) win.config(menu=menu_bar) # Add a cascade for the file managing file_cascade = tk.Menu(menu_bar, tearoff=0) file_cascade.add_command(label="Open file", command=self.promptlocalfileloader) file_cascade.add_command(label="Open remote file", command=self.promptremotefileloader) file_cascade.add_separator() file_cascade.add_command(label="Quit", command=win.destroy) menu_bar.add_cascade(label="File", menu=file_cascade) # Draw the filters and tab control on the left side of the window self.leftframe = tk.Frame(win) addbutton = tk.Button(self.leftframe, text="Add", padx=8, command=lambda: self.tabsection.addtab("Empty")) erasebutton = tk.Button(self.leftframe, text="Del", padx=8, command=lambda: self.tabsection.erasetab()) self.leftframe.pack(side=tk.LEFT) addbutton.grid(row=1, column=0) erasebutton.grid(row=1, column=1) todraw = [] cascades = [] buttons = [] self.filter_menu_frame = tk.Frame(self.leftframe, relief=tk.RAISED, bd=2) self.filter_menu_frame.grid(row=2, columnspan=2, ipady=220, ipadx=21) filter_menu = Menubutton(self.filter_menu_frame, text="Filters") topmenu = tk.Menu(filter_menu, tearoff=True) filter_menu.configure(menu=topmenu) for path in regexs: for submenu in range(len(path.split("_"))): todraw.append("_".join(path.split("_")[:submenu+1])) todraw = list(dict.fromkeys(todraw).keys()) todraw.remove("") # Separate cascades from final buttons for element in todraw: if "·" in element: buttons.append(element) cascades.append("_".join(element.split("·")[:-1])) else: cascades.append(element) cascades = list(dict.fromkeys(cascades).keys()) cascades.sort() # Draw submenus with cascades for cascade in cascades: splitted = cascade.split("_") if len(splitted) == 2: exec("_" + splitted[-1] + " = tk.Menu(topmenu)") exec("topmenu.add_cascade(label=splitted[-1], menu=" + "_" + splitted[-1] + ")") else: parent = "_".join(splitted[:-1]) actual = "_".join(splitted) exec(actual + " = tk.Menu(" + parent + ")") exec(parent + ".add_cascade(label=splitted[-1], menu=" + actual + ")") i = 0 # Auxiliary variable for filter in buttons: splitted = filter.split("·") parent = splitted[0] filtername = splitted[1] exec(parent + ".add_command(label = filtername, command = lambda self=self: alternateregex(self, %s))" % i) i = i + 1 filter_menu.pack(expand=tk.YES, fill=tk.BOTH) self.tabframe.pack(expand=tk.YES, fill=tk.BOTH) bottom_frame = tk.Frame(win) bottom_frame.pack(side=tk.BOTTOM) self.tabsection.addtab("Empty")
class GUI: def __init__(self, driver): self.root = Tk() self.root.title("VoltaireTaMere") self.root.resizable(False, False) self.root.geometry('600x350') self.root.iconphoto( True, PhotoImage(file="asset/VoltaireTaMere_icon[PNG].png")) self.root.configure(bg='#23272A') self.Auto_off = PhotoImage(file="asset/Boutton_Auto_off.png") self.Auto_on = PhotoImage(file="asset/Boutton_Auto_on.png") self.Manual = PhotoImage(file="asset/Boutton_Manuel.png") self.back = PhotoImage(file="asset/Boutton_Retour.png") self.load_file = PhotoImage(file="asset/Boutton_Load.png") self.Quitter = PhotoImage(file="asset/boutton_Quitter.png") self.BG1 = PhotoImage(file="asset/Menu_1.png") self.BG2 = PhotoImage(file="asset/Menu_2.png") self.BG3 = PhotoImage(file="asset/Menu_3.png") self.driver = driver self.module = Module("") self.bot_on = False self.accuracy = IntVar() self.time_next = IntVar() self.accuracy.set(found_data("./file/options.txt", "accuracy", "int")) self.time_next.set(found_data("./file/options.txt", "accuracy", "int")) self.number_q = 0 self.prgm = StringVar() self.niveau = StringVar() self.fond = Label(self.root, image=None, bg='#23272A') self.btn_pont_sup = Button( self.root, text="PONT\nSUPÉRIEUR", command=lambda: [ self.prgm.set("pont_Supérieur"), self.niveau. set("Module\\ 1 Module\\ 2 Module\\ 3 Module\\ 4 Module\\ 5 Module\\ 6 Module\\ 7 Module\\ 8 Test\\ Blanc" ), self.Menu_Unpack(), self.Menu_2(self.BG2) ], bg="#a2d417", highlightthickness=2, bd=0, height=6, width=12, font=('Helvetica', '10', "bold")) self.btn_sup = Button( self.root, text="SUPÉRIEUR", command=lambda: [ self.prgm.set("Supérieur"), self.niveau. set("Module\\ 1 Module\\ 2 Module\\ 3 Module\\ 4 Module\\ 5 Module\\ 6 Module\\ 7 Module\\ 8 Module\\ 9 Module\\ 10 Test\\ Blanc" ), self.Menu_Unpack(), self.Menu_2(self.BG2) ], bg="#a2d417", highlightthickness=2, bd=0, height=6, width=12, font=('Helvetica', '10', "bold")) self.btn_exc = Button( self.root, text="EXCELLENCE", command=lambda: [ self.prgm.set("Excellence"), self.niveau. set("Module\\ 1 Module\\ 2 Module\\ 3 Module\\ 4 Module\\ 5 Module\\ 6 Module\\ 7 Module\\ 8 Module\\ 9 Module\\ 10 Module\\ 11 Module\\ 12 Verbes\\ Pronominaux\\ II" ), self.Menu_Unpack(), self.Menu_2(self.BG2) ], bg="#a2d417", highlightthickness=2, bd=0, height=6, width=12, font=('Helvetica', '10', "bold")) self.btn_cus = Button(self.root, text="CUSTOM", bg="#a2d417", command=lambda: [ self.prgm.set("CUS"), self.niveau.set(""), self.Menu_Unpack(), self.Menu_3(self.BG3) ], activebackground="#ffffff", bd=0, height=6, width=12, font=('Helvetica', '10', "bold")) self.btn_auto = Button(self.root, image=self.Auto_off, command=self.switch_bot, bg="#a2d417", activebackground="#a2d417", bd=0) self.btn_manual = Button( self.root, image=self.Manual, command=lambda: Thread(target=self.ROUTINE_MANUAL).start(), bg="#23272A", activebackground="#23272A", bd=0) self.btn_load_file = Button(self.root, image=self.load_file, command=self.init_module, bg="#23272A", activebackground="#23272A", bd=0) self.btn_back = Button( self.root, image=self.back, command=lambda: [self.Menu_Unpack(), self.Menu_1(self.BG1)], bg="#23272A", activebackground="#23272A", bd=0) self.btn_quit = Button(self.root, image=self.Quitter, command=self.root.destroy, bg="#23272A", activebackground="#23272A", bd=0) self.listB_Module = Listbox(self.root, exportselection=0, listvariable=self.niveau, selectmode="single", activestyle="none", height=14, width=21, bd=0, bg="#2C2F33", fg="#ffffff", selectbackground="#a2d417", font=('Helvetica', '10')) self.log = Text(self.root, height=12, width=47, bg="#2C2F33", fg="#ffffff", bd=0, font=('Helvetica', '10')) self.log.tag_config("green", foreground="#40ff46") self.log.tag_config("red", foreground="#ff4040") self.log.tag_config("yellow", foreground="#f5ff40") self.log.tag_config("cyan", foreground="#00ffff") self.log.tag_config("magenta", foreground="#ff00ff") self.log.tag_config("white", foreground="#ffffff") self.menuAide = Menubutton(self.root, text='Aide', width='6', fg='#ffffff', bg='#2c2e30', activebackground='#a2d417', bd=0) self.SousMenuAide = Menu(self.menuAide, fg='#ffffff', bg='#2c2e30', activebackground='#a2d417') self.SousMenuAide.add_command( label='Notice', command=lambda: open_file("./file/NOTICE.pdf")) self.SousMenuAide.add_command( label='réinitialiser Login', command=lambda: [Login(self.driver, self.root)]) self.menuAide.configure(menu=self.SousMenuAide) self.menuOption = Menubutton(self.root, text='Option', width='6', fg='#ffffff', bg='#2c2e30', activebackground='#a2d417', bd=0) self.SousMenuOption = Menu(self.menuOption, fg='#ffffff', bg='#2c2e30', activebackground='#a2d417') self.SousMenuOption.add_command( label='OverClock', command=lambda: [ self.time_next.set(1), print_debug("[MAIN] Overclock ON", "yellow"), self.log.insert("end", "Overclock ON\n", "yellow") ]) self.SousMenuOption.add_command( label='options', command=lambda: [self.Menu_Unpack(), self.Menu_4()]) self.menuOption.configure(menu=self.SousMenuOption) self.option_auto_login = Button( self.root, text="auto login", command=lambda: [ self.log.delete(1.0, "end"), self.input_data.place_forget(), self.log.insert( "end", "L'auto login permet de se connecter automatiquement a son compte projet voltaire lors du démarage" ), self.switch_auto_login.place(x=320, y=30) ], bg="#a2d417", highlightthickness=2, bd=0, height=2, width=20, font=('Helvetica', '10')) self.option_accuracy = Button( self.root, text="précision", command=lambda: [ self.switch_auto_login.place_forget(), self.log.delete(1.0, "end"), self.set_accurate_buffer(), self.input_data.place(x=320, y=30), self.log.insert("end", "Définit le pourcentage de bonnes réponses") ], bg="#a2d417", highlightthickness=2, bd=0, height=2, width=20, font=('Helvetica', '10')) self.option_time = Button( self.root, text="temps d'attente", command=lambda: [ self.switch_auto_login.place_forget(), self.log.delete(1.0, "end"), self.set_time_buffer(), self.input_data.place(x=320, y=30), self.log.insert( "end", "définit le temps d'attente entre chaque question") ], bg="#a2d417", highlightthickness=2, bd=0, height=2, width=20, font=('Helvetica', '10')) self.switch_auto_login = Button(self.root, text="", command=None, bg="#a2d417", highlightthickness=2, bd=0, height=1, width=10, font=('Helvetica', '10')) self.time_buffer = StringVar() self.time_buffer.set(found_data("./file/options.txt", "time", "int")) self.accurate_buffer = StringVar() self.accurate_buffer.set( found_data("./file/options.txt", "accuracy", "int")) self.input_data = Entry(self.root, textvariable=None, bg="#2C2F33", fg="#ffffff", width=11, bd=1, font=('Helvetica', '10')) def auto_login_switch(self): if found_data("./file/options.txt", "auto_login", "int"): self.switch_auto_login["bg"] = "#a2d417" self.switch_auto_login["text"] = "activer" self.switch_auto_login["command"] = lambda: [ write_data("./file/options.txt", "auto_login", 0), self.auto_login_switch() ] else: self.switch_auto_login["bg"] = "#2C2F33" self.switch_auto_login["text"] = "desactiver" self.switch_auto_login["command"] = lambda: [ write_data("./file/options.txt", "auto_login", 1), self.auto_login_switch() ] def Menu_1(self, BG): self.fond["image"] = BG self.fond.pack() self.btn_pont_sup.place(x=22, y=170) self.btn_sup.place(x=174, y=170) self.btn_exc.place(x=326, y=170) self.btn_cus.place(x=478, y=170) self.btn_quit.place(x=478, y=307) self.menuAide.place(x=555, y=0) self.menuOption.place(x=510, y=0) def Menu_2(self, BGaff): self.fond["image"] = BGaff self.log["width"] = 47 self.btn_auto["bg"] = "#a2d417" self.btn_auto["activebackground"] = "#a2d417" self.fond.pack() self.btn_load_file.place(x=30, y=308) self.btn_manual.place(x=255, y=60) self.btn_auto.place(x=402, y=60) self.btn_back.place(x=477, y=309) self.log.place(x=255, y=105) self.listB_Module.place(x=32, y=60) self.listB_Module.selection_set(0) self.menuAide.place(x=555, y=0) self.menuOption.place(x=510, y=0) def Menu_3(self, BGaff): self.fond["image"] = BGaff self.log["width"] = 79 self.btn_auto["bg"] = "#23272A" self.btn_auto["activebackground"] = "#23272A" self.fond.pack() self.btn_load_file.place(x=30, y=308) self.btn_manual.place(x=30, y=63) self.btn_auto.place(x=156, y=63) self.btn_back.place(x=477, y=309) self.log.place(x=30, y=103) self.menuAide.place(x=555, y=0) self.menuOption.place(x=500, y=0) open_file("./Modules/Custom/Module1.txt") def Menu_4(self): self.btn_back["command"] = lambda: [ self.Menu_Unpack(), self.Menu_1(self.BG1), write_data("./file/options.txt", "time", self.time_buffer.get()), write_data("./file/options.txt", "accuracy", self.accurate_buffer.get()), self.accuracy.set( found_data("./file/options.txt", "accuracy", "int")), self.time_next.set( found_data("./file/options.txt", "accuracy", "int")) ] self.auto_login_switch() self.log["width"] = 58 self.log["bg"] = "#23272A" self.btn_back.place(x=477, y=309) self.menuAide.place(x=555, y=0) self.option_auto_login.place(x=0, y=10) self.option_accuracy.place(x=0, y=65) self.option_time.place(x=0, y=120) self.log.place(x=180, y=80) def set_time_buffer(self): self.input_data["textvariable"] = self.time_buffer def set_accurate_buffer(self): self.input_data["textvariable"] = self.accurate_buffer def Menu_Unpack(self): self.log["bg"] = "#2C2F33" self.log.delete(1.0, "end") self.bot_on = False self.btn_auto["image"] = self.Auto_off self.btn_back["command"] = lambda: [ self.Menu_Unpack(), self.Menu_1(self.BG1) ] self.input_data.place_forget() self.switch_auto_login.place_forget() self.fond.pack_forget() self.btn_load_file.place_forget() self.btn_manual.place_forget() self.btn_auto.place_forget() self.btn_back.place_forget() self.listB_Module.place_forget() self.log.place_forget() self.btn_pont_sup.place_forget() self.btn_sup.place_forget() self.btn_exc.place_forget() self.btn_cus.place_forget() self.btn_quit.place_forget() self.menuAide.place_forget() self.menuOption.place_forget() self.option_auto_login.place_forget() self.option_accuracy.place_forget() self.option_time.place_forget() def init_module(self): try: self.module = Module("./Modules/" + self.prgm.get() + "/Module" + str(self.listB_Module.curselection()[0] + 1) + ".txt") except: self.module = Module("./Modules/Custom/Module1.txt") if self.module.data == []: self.log.insert("end", "erreur aucun fichier chargé\n", "red") else: self.log.insert("end", "fichier correctement chargé\n", "green") def switch_bot(self): if self.bot_on: self.bot_on = False self.btn_auto["image"] = self.Auto_off elif self.module.data != []: self.bot_on = True self.btn_auto["image"] = self.Auto_on self.td = Thread(target=self.ROUTINE_BOT) self.td.start() else: self.log.insert("end", "erreur aucun fichier chargé\n", "red") print_debug("AUCUN FICHIER CHARGÉ", "red") def ROUTINE_BOT(self): if self.accuracy.get() < 0: self.accuracy.set(0) write_data("./file/options.txt", "accuracy", 0) print_debug("[option] accuracy valeur interdite", "red") if self.time_next.get() < 1: self.time_next.set(1) write_data("./file/options.txt", "time", 1) print_debug("[option] time valeur interdite", "red") while self.bot_on: self.log.delete(1.0, "end") return_tag = BOT(self.driver, self.module.data, self.module.test_blanc, self.accuracy.get()) print_debug("return_tag: " + str(return_tag) + "\n", "yellow") if type(return_tag) != list: if return_tag == "feature_in": self.log.insert("end", "Merci de fermer la Pop-up\n", "yellow") elif "can't_touche" in return_tag: self.log.insert( "end", "Je n'arrive pas a toucher: " + return_tag[return_tag.index("&") + 1:len(return_tag)] + "\n", "yellow") elif return_tag == "not_found": self.log.insert("end", "je trouve pas sorry UwU\n", "yellow") break self.number_q += 1 if self.module.test_blanc == False: if self.driver.find_elements_by_xpath( "//span[@title='Mauvaise réponse']" ) != [] and return_tag != ["auto_fail"]: text = '' answer_word_els = self.driver.find_elements_by_xpath( "//span[@class = 'answerWord']/span[@class = 'pointAndClickSpan']" ) if len(answer_word_els) >= 1: text = answer_word_els[1].text else: text = answer_word_els[0].text or "" if return_tag == []: auto_learning().add_match( self.driver.find_element_by_class_name( "sentence").text, text) else: auto_learning().add_data(return_tag, text) self.log.insert("end", "erreur détéctée apprentissage...\n", "green") try: self.driver.find_element_by_class_name( "nextButton").click() except Exception: pass self.log.insert("end", "[" + str(self.number_q) + "]: Clique fait !\n", "green") self.log.insert( "end", open("./file/VTMtext.txt", "r", encoding="utf-8").read()) self.log.insert("end", "\n\nWaiting...\n", "green") i = 0 while i < self.time_next.get() and self.bot_on: sleep(1) i += 1 self.bot_on = False self.btn_auto["image"] = self.Auto_off self.time_next.set(found_data("./file/options.txt", "time", "int")) print_debug( "[BOT_ROUTINE] I am a bot, and this action was performed automatically.\nI answered " + str(self.number_q) + " questions", "green") self.log.insert( "end", "I am a bot, and this action was performed automatically.\nI answered " + str(self.number_q) + " questions\n", "green") self.number_q = 0 return 0 def ROUTINE_MANUAL(self): self.log.delete(1.0, "end") return_tag = MANUAL(self.driver, self.module.data, self.module.test_blanc) if return_tag == "feature_in": self.log.insert("end", "Merci de fermer la Pop-up\n", "yellow") elif return_tag == "not_found": self.log.insert("end", "je trouve pas sorry UwU\n", "yellow") elif return_tag == "no_error": self.log.insert("end", "pas de faute :D\n", "green") else: self.log.insert("end", "la faute est: " + return_tag + "\n", "green") self.log.insert( "end", open("./file/VTMtext.txt", "r", encoding="utf-8").read())