_tkinter.TclError: wrong # args: should be ".!text3 insert i
Résolu
Pr.Witherfire
-
Pr.Witherfire -
Pr.Witherfire -
Bonjour. J'ai un problème avec Tkinter. Je veux passer en argument d'un insert une variable.
Code :
# IMPORTS--------------------------------------------------------------------------------------------------------------- import pickle from tkinter import * import time # INFOS----------------------------------------------------------------------------------------------------------------- Version = "Consolaire" Color1 = "#41413F" Color2 = "white" Police = "Arial" # VARIABLES------------------------------------------------------------------------------------------------------------- # Fenetres F = Tk() F.geometry("500x250+550+250") # FICHIERS-------------------------------------------------------------------------------------------------------------- # Loads LoadGeneral = "D:\Gwenneg\Programmation\Python\\3-Repertoires\\1-PCHI\\1-PCHI Consolaire\PCHI\Sauvegardes\Sauve.Sauve" # FONCTIONS------------------------------------------------------------------------------------------------------------- def FoSuppContenuF(): global CMenu global LtMenu global BAjouterProjet global BDocOffi global BCredits for For in F.winfo_children(): For.destroy() def FoFermetureMenu(self): NbDeProjetP1=0 S = {"NbDeProjetP1": int(NbDeProjetP1), "Exp": 1} with open(LoadGeneral, "wb") as FileSGenerale: pickle.dump(S, FileSGenerale) F.destroy() def FoLancerProj(Projet): SauveProjet = "D:\Gwenneg\Programmation\Python\\3-Repertoires\\1-PCHI\\1-PCHI Consolaire\PCHI\Sauvegardes\Proj%s.Sauve" % Projet try : with open(SauveProjet, "rb") as FileSGenerale: SRestProj = pickle.load(FileSGenerale) TextProj = Srest.get("TextProj") except: pass FoSuppContenuF() F.title("Projet %s"%Projet) LtLancementproj = Label(F, text=Projet, fg=Color2, bg=Color1, font=(Police, 40)) LtLancementproj.place(x=1700, y=300) F.update() time.sleep(0.05) F.update() LtLancementproj.place(x=1600, y=300) F.update() time.sleep(0.05) LtLancementproj.place(x=1500, y=300) F.update() time.sleep(0.05) LtLancementproj.place(x=1400, y=300) F.update() time.sleep(0.05) LtLancementproj.place(x=1300, y=300) F.update() time.sleep(0.05) LtLancementproj.place(x=1200, y=300) F.update() time.sleep(0.05) LtLancementproj.place(x=1100, y=300) F.update() time.sleep(0.04) LtLancementproj.place(x=1000, y=300) F.update() time.sleep(0.03) LtLancementproj.place(x=900, y=300) F.update() time.sleep(0.03) LtLancementproj.place(x=800, y=300) F.update() time.sleep(0.02) LtLancementproj.place(x=700, y=300) F.update() time.sleep(0.015) LtLancementproj.place(x=600, y=300) F.update() time.sleep(0.01) LtLancementproj.place(x=500, y=300) F.update() time.sleep(0.5) FoSuppContenuF() TProjet2 = Text(F, bg=Color2, fg=Color1, width=40, height=200, font=(Police, 15)) def BreakFocus(): TProjet.focus() TProjet2.delete(0.0, END) TProjet2.insert(0.0, TextTProjet2) TProjet2.place(x=0, y=0) TextTProjet2 = TProjet2.get(0.0, END) TProjet2 = Text(F, bg=Color2, fg=Color1, width=40, height=200, font=(Police, 15)) TProjet2.bind_all("<Key>", lambda e : BreakFocus()) TProjet2.place(x=0, y=0) TProjet2.insert("1.0", "1") TProjet = Text(F, bg=Color1, fg=Color2, width=500, height=200, font=(Police, 15)) TextProj2 = TextProj TProjet.insert("1.0", TextProj2) TProjet.place(x=40, y=0) TProjet3 = Text(F, bg=Color1, fg=Color2, width=50, height=200, font=(Police, 1)) TProjet3.config(state=DISABLED) TProjet3.place(x=1550, y=0) def FoMajPT2(self): TProjet2.config(state=NORMAL) # Prendre Nb De Lignes Text = TProjet.get(2.0, END) NbLignesText = len(Text)+2 NbLignesTextP1 = NbLignesText+1 # Print print(NbLignesText) # Suppression du contenu TProjet2.delete(0.0, END) for i in range(1, NbLignesTextP1): if i == 1: Text = "%s\n" % i else : Text = Text+"%s\n"%i TProjet2.insert(0.0, Text) TProjet2.place(x=0, y=0) TProjet2.config(state=DISABLED) if NbLignesText == 37: SbText11 = Scrollbar(F) SbText11.pack(side=RIGHT, fill=Y) SbText11.config(command=TProjet2.yview) TProjet2.config(yscrollcommand=SbText11.set) TProjet3.place(x=1525, y=0) FoMajText3(self) def FoMajMT2(self): TProjet2.config(state=NORMAL) # Prendre Nb De Lignes Text = TProjet.get(2.0, END) NbLignesText = len(Text)+2 NbLignesTextM1 = NbLignesText-1 # Print print(NbLignesText) # Suppression du contenu TProjet2.delete(0.0, END) for i in range(1, NbLignesTextM1): if i == 1: Text = "%s\n" % i else : Text = Text+"%s\n"%i TProjet2.insert(0.0, Text) TProjet2.place(x=0, y=0) TProjet2.config(state=DISABLED) if NbLignesText == 36: SbText11 = Scrollbar(F).place(x=3000, y=3000) TProjet3.place(x=1550, y=0) FoMajText3(self) def FoMajText3(self): TProjet3.config(state=NORMAL) TProjet3.delete(0.0, END) Text = TProjet.get(0.0, END) NbLignesText = len(Text) + 2 TProjet3.insert(0.0, Text) TProjet3.config(state=DISABLED) def FoMajTest(self): print("ControlV") def FoMajTest2(self): TProjet.bind("<V>", lambda : FoMajTest2) def CompDirect(): for i in range(NbLignesText): o = 1 if o == "af": pass elif o == "#": pass elif o == "repetex": pass elif o =="silon": pass elif o == "sinon": pass elif o == "sinonsilon": pass elif o == "atadrex": pass elif o == "fok": pass elif o == "[": pass elif o == ")": pass else: pass def FoFermetureProjet(Projet): NbDeProjetP1 = 0 S = {"NbDeProjetP1": int(NbDeProjetP1), "Exp": 1} with open(LoadGeneral, "wb") as FileSGenerale: pickle.dump(S, FileSGenerale) TextProj = TProjet.get(0.0, END) with open(SauveProjet, "wb") as FileSGenerale: pickle.dump(TextProj, FileSGenerale) F.destroy() TProjet.bind("<Key>", FoMajText3) TProjet.bind("<Return>", FoMajPT2) TProjet.bind("<BackSpace>", FoMajMT2) TProjet.bind("<Control_L>", FoMajTest) F.protocol("WM_DELETE_WINDOW", lambda: FoFermetureProjet(Projet)) def FoSupp(Proj): print("Suppression projet %s" % Proj) FolamLancer = lambda Proj: FoLancerProj(Proj) FolamSupp = lambda Proj: FoSupp(Proj) # Importation with open(LoadGeneral, "rb") as f1: Srest = pickle.load(f1) NbDeProjetP1 = Srest.get("NbDeProjetP1") Exp = Srest.get("Exp") def FoMenu(): global Exp F.title(Version + " Menu") F.iconbitmap("D:\Gwenneg\Programmation\Python\\3-Repertoires\\1-PCHI\\1-PCHI Consolaire\PCHI\Ressources\Images\Logo.ico") F.geometry("1600x900+-8+0") F.overrideredirect(0) F.config(bg=Color1) CMenu = Canvas(F, width=1600, height=270, bg=Color2) CMenu.place(x=0, y=0) LtMenu = Label(CMenu, text="Pseudo Compilateur Hybride Infynyty", font=(Police, 40), fg=Color1, bg=Color2) LtMenu.place(x=375, y=100) PCHIBTest = Button(F, text="Lancer Projet", bg=Color2, fg=Color1, font=(Police, 15), command=lambda : FoLancerProj("IKOS")) PCHIBTest.pack() F.protocol("WM_DELETE_WINDOW", lambda: FoFermetureMenu(1)) if Exp == 0: F.update() if Exp == 1: F.mainloop() # Exp Checker if Exp == 0: FsBienvenue = Toplevel(bd=0, bg=Color1, height=500, width=250) FsBienvenue.title("Bienvenue") FsBienvenue.resizable(0, 0) FsBienvenue.iconbitmap("D:\Gwenneg\Programmation\Python\\3-Repertoires\\1-PCHI\\1-PCHI Consolaire\PCHI\Ressources\Images\Logo.ico") FsBienvenue.geometry("500x250+550+300") TBienvenue = Label(FsBienvenue, text="Bienvenue!", font=(Police, 25), fg=Color2, bg=Color1) TBienvenue.place(x=10, y=10) LtBienvenue = Label(FsBienvenue, fg= Color2, bg=Color1, font=(Police, 10), bd=0, text="Bienvenue dans PCHI, l'IDE officiel du language de programmation INFYNYTY, le") LtBienvenue2 = Label(FsBienvenue, fg= Color2, bg=Color1, font=(Police, 10), bd=0, text="language de programation avec le meilleur rapport difficulté/résultat de la planète!!!") LtBienvenue3 = Label(FsBienvenue, fg=Color2, bg=Color1, font=(Police, 10), bd=0, text="Une documentation officielle integrée vous en apprendra plus sur PCHI et Infynyty,") LtBienvenue4 = Label(FsBienvenue, fg=Color2, bg=Color1, font=(Police, 10), bd=0, text="en vous apprenant des bases de la programation aux moindres recoins d'") LtBienvenue5 = Label(FsBienvenue, fg=Color2, bg=Color1, font=(Police, 10), bd=0, text="InfynytyPL...") LtBienvenue.place(x=10, y=70) LtBienvenue2.place(x=10, y=85) LtBienvenue3.place(x=10, y=100) LtBienvenue4.place(x=10, y=115) LtBienvenue5.place(x=10, y=130) TBienvenue2 = Label(FsBienvenue, text=" Bon code,", font=(Police, 25), fg=Color2, bg=Color1) TBienvenue2.place(x=10, y=150) TBienvenue3 = Label(FsBienvenue, text=" Gwenneg, administrateur d'Infynyty Project, dévellopeur de PCHI et créateur d'InfynytyPL", font=(Police, 7), fg=Color2, bg=Color1) TBienvenue3.place(x=10, y=225) FsBienvenue.mainloop() Exp = 1 FoMenu()
Erreur
Exception in Tkinter callback Traceback (most recent call last): File "C:\Program Files\Python311\Lib\tkinter\__init__.py", line 1948, in __call__ return self.func(*args) ^^^^^^^^^^^^^^^^ File "C:\Users\Gwenneg\PycharmProjects\Picklecreator\main.py", line 409, in <lambda> PCHIBTest = Button(F, text="Lancer Projet", bg=Color2, fg=Color1, font=(Police, 15), command=lambda : FoLancerProj("IKOS")) ^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Gwenneg\PycharmProjects\Picklecreator\main.py", line 175, in FoLancerProj TProjet.insert("1.0", TextProj2) File "C:\Program Files\Python311\Lib\tkinter\__init__.py", line 3799, in insert self.tk.call((self._w, 'insert', index, chars) + args) _tkinter.TclError: wrong # args: should be ".!text3 insert index chars ?tagList chars tagList ...?" Process finished with exit code 0
Merci.
Au revoir.
Ok. Les dossiers aussi avec ou juste le fichier ?