#Hey I need your help , I create un application with python (and tkinter ), when y run my #code the python Launcher stop my code . It is my Launcher or its my code ? form my it's my code because i thinks is the last v (sorry form my English i am french)
#It's My code
#!/usr/bin/python3.9
# -*-coding:Latin-1 -*
from os import read, write
import _tkinter
import tkinter as tk
import tkinter.font as font
# -- INPUT HOME PAGE --
#: indiqué votre premier titre de votre home page
input = tk.Entry()
#: indiqué le deuxieme titre de votre home page
input1 = tk.Entry()
#: Veuillez indiquer la couleur de fond de la home page
input2 = tk.Entry()
# Voullez vous des Bord rond 'oui' 'non'
input3 = tk.Entry()
#: la couleur du text :
input4 = tk.Entry()
# -- BackGround Couleur (Home Bar)
input5 = tk.Entry()
# -- Color (Home Bar)
input6 = tk.Entry()
#: Voulez vous des bord rond sur le cadre des boutton 'oui' 'non'
input7 = tk.Entry()
#: Voullez vous un effets sur les bouton 'aucun' / 'oui1' / 'oui2'
input8 = tk.Entry()
# -- FENETRE --
fenetre = tk.Tk()
fenetre.configure(bg='grey')
fenetre.geometry("5000x1000")
filin = open("apercu.html", "a")
filincss =open("apercu.css", "a")
def titre():
print("La fonction Titre is activate")
def homePage():
# getfonction()
print("function 'getInput' is activate")
filin.write("\n<DOCTYPE html>\n<head>\n<title>Apercu</title>\n<link rel='stylesheet' href='Apercu.css'>\n<meta charset='utf-8'>\n</head>\n<body>")
filincss.write("\nbody{\nmargin:0;}\n")
print("La fonction de la homebar is Avtivate")
filin.write("\n<div class='homebar''>\n")
filin.write("\n <div class='acceuil'><p class='p-home'>Acceuil</p></div>")
filin.write("\n <div class='contact'><p class='p-home1'>Contat</p></div>\n</div>")
filincss.write(".homebar{\nbackground-color:black;\height:150px;\ncolor: orange;\ndisplay: flex;")
filincss.write("\nborder-bottom-right-radius: 33px;\nborder-bottom-left-radius: 33px;\n}")
filincss.write("\n.contact{\nposition: relative;\nleft:870px;\nfont-size: 25px;\ntop: 50px;\nborder: solid 3px;\n")
filincss.write("border-radius:33px;\nwidth: 100px;\nheight: 30px;\n}")
filincss.write("\n.acceuil{\nposition: relative;\nborder: solid 3px black;\nborder-radius: 33px;\nwidth: 100px;\nheight: 30px;\nleft: 90px;\nfont-size: 25px;\ntop: 50px;\nleft: 30px;}")
filincss.write("\ncontact:hover,.acceuil:hover{\ntransition-duration: 1s;\ntop: 40px;\n}")
# -- Recuperation des Input Home Page --
def RecupI_HB():
recup = input.get()
print(recup)
recup1 =input2.get()
print(recup1)
recup2 = input3.get()
print(recup2)
recup3 = input3.get()
print(recup3)
recup4 = input3.get()
print(recup4)
recup5 = input3.get()
print(recup5)
recup6 = input3.get()
print(recup6)
recup7 = input3.get()
print(recup7)
# -- finish --
def finish(filin):
filin.write("\n</body>\n</DOCTYPE>")
filin.close()
tekt = tk.Entry()
# -- Boutton Home page --
bouton=tk.Button(fenetre, text="homepage",width=50,command=homePage)
label = tk.Label(fenetre,bg='grey', text="Usine a apercu")
label1 = tk.Label(fenetre, bg='grey',text="Indiquer le nom du clients :")
# -- Sapce --
space = tk.Label(fenetre,bg='grey', text=" ")
space1 = tk.Label(fenetre,bg='grey', text=" ")
space2 = tk.Label(fenetre,bg='grey', text=" ")
space3 = tk.Label(fenetre,bg='black',width=100,height=1, text=" ")
space4 = tk.Label(fenetre,bg='grey', text=" ")
space5 = tk.Label(fenetre,bg='grey', text=" ")
space6 = tk.Label(fenetre,bg='grey', text=" ")
space7 = tk.Label(fenetre,bg='grey', text=" ")
# -- Pack --
label.pack()
space.pack()
label1.pack()
space5.pack()
tekt.pack()
space2.pack()
space6.pack()
space3.pack()
space7.pack()
bouton.pack(padx=50, pady=10)
Really I dont say what is the probleme is test the last version of my code and this version dont run also .
CodePudding user response:
The problem is that you are not running the mainloop. Every tkinter.Tk() window needs a mainloop at the end of the program script. It makes the window run continuously. Also as per @acw1668, tkinter.Tk() should be done before creating any widget. Final code:
from os import read, write
import tkinter as tk
import tkinter.font as font
# -- INPUT HOME PAGE --
# -- FENETRE --
fenetre = tk.Tk()
fenetre.configure(bg='grey')
fenetre.state("zoomed")
#: indiqué votre premier titre de votre home page
input = tk.Entry()
#: indiqué le deuxieme titre de votre home page
input1 = tk.Entry()
#: Veuillez indiquer la couleur de fond de la home page
input2 = tk.Entry()
# Voullez vous des Bord rond 'oui' 'non'
input3 = tk.Entry()
#: la couleur du text :
input4 = tk.Entry()
# -- BackGround Couleur (Home Bar)
input5 = tk.Entry()
# -- Color (Home Bar)
input6 = tk.Entry()
#: Voulez vous des bord rond sur le cadre des boutton 'oui' 'non'
input7 = tk.Entry()
#: Voullez vous un effets sur les bouton 'aucun' / 'oui1' / 'oui2'
input8 = tk.Entry()
filin = open("apercu.html", "a")
filincss =open("apercu.css", "a")
def titre():
print("La fonction Titre is activate")
def homePage():
# getfonction()
print("function 'getInput' is activate")
filin.write("\n<DOCTYPE html>\n<head>\n<title>Apercu</title>\n<link rel='stylesheet' href='Apercu.css'>\n<meta charset='utf-8'>\n</head>\n<body>")
filincss.write("\nbody{\nmargin:0;}\n")
print("La fonction de la homebar is Avtivate")
filin.write("\n<div class='homebar''>\n")
filin.write("\n <div class='acceuil'><p class='p-home'>Acceuil</p></div>")
filin.write("\n <div class='contact'><p class='p-home1'>Contat</p></div>\n</div>")
filincss.write(".homebar{\nbackground-color:black;\height:150px;\ncolor: orange;\ndisplay: flex;")
filincss.write("\nborder-bottom-right-radius: 33px;\nborder-bottom-left-radius: 33px;\n}")
filincss.write("\n.contact{\nposition: relative;\nleft:870px;\nfont-size: 25px;\ntop: 50px;\nborder: solid 3px;\n")
filincss.write("border-radius:33px;\nwidth: 100px;\nheight: 30px;\n}")
filincss.write("\n.acceuil{\nposition: relative;\nborder: solid 3px black;\nborder-radius: 33px;\nwidth: 100px;\nheight: 30px;\nleft: 90px;\nfont-size: 25px;\ntop: 50px;\nleft: 30px;}")
filincss.write("\ncontact:hover,.acceuil:hover{\ntransition-duration: 1s;\ntop: 40px;\n}")
# -- Recuperation des Input Home Page --
def RecupI_HB():
recup = input.get()
print(recup)
recup1 =input2.get()
print(recup1)
recup2 = input3.get()
print(recup2)
recup3 = input3.get()
print(recup3)
recup4 = input3.get()
print(recup4)
recup5 = input3.get()
print(recup5)
recup6 = input3.get()
print(recup6)
recup7 = input3.get()
print(recup7)
# -- finish --
def finish(filin):
filin.write("\n</body>\n</DOCTYPE>")
filin.close()
tekt = tk.Entry()
# -- Boutton Home page --
bouton=tk.Button(fenetre, text="homepage",width=50,command=homePage)
label = tk.Label(fenetre,bg='grey', text="Usine a apercu")
label1 = tk.Label(fenetre, bg='grey',text="Indiquer le nom du clients :")
# -- Sapce --
space = tk.Label(fenetre,bg='grey', text=" ")
space1 = tk.Label(fenetre,bg='grey', text=" ")
space2 = tk.Label(fenetre,bg='grey', text=" ")
space3 = tk.Label(fenetre,bg='black',width=100,height=1, text=" ")
space4 = tk.Label(fenetre,bg='grey', text=" ")
space5 = tk.Label(fenetre,bg='grey', text=" ")
space6 = tk.Label(fenetre,bg='grey', text=" ")
space7 = tk.Label(fenetre,bg='grey', text=" ")
# -- Pack --
label.pack()
space.pack()
label1.pack()
space5.pack()
tekt.pack()
space2.pack()
space6.pack()
space3.pack()
space7.pack()
bouton.pack(padx=50, pady=10)
fenetre.mainloop()
CodePudding user response:
All you have to do is add this at the end:
fenetre.mainloop()
In addition, you don't need the import _tkinter