Issue
I'm developing a python script with a graphical interface to export files to a website. The problem is that when I launch the export see the variable 'buttonExportation (en français)', the customTkinter page says it doesn't respond and I can't display the progress bar. I think it's a matter of process. I'm a computer science student and the concept of process with process is understood but hard to apply. I've tried Threading but it doesn't seem to work.My idea would be to create an another sub-process for the interface. Here's some code, if you need more I can put :
enter code here
class FenetreLogin(customtkinter.CTk):
def __init__(self):
super().__init__()
self.geometry("700x680")
self.title("Exportation_Fanny v1")
self.initial_width = 650
labelAuteur = customtkinter.CTkLabel(master=self,font=("",20,'underline'),text="Made By Lucas Desperrois")
labelAuteur.pack(anchor="n",pady=10)
self.resizable(width=False,height=False)
self.fenetreConnexion = self.frameConnexion();
self.browser1=None;
self.nni = None;
def threadExportation(self,listeRep):
rep=0
if(listeRep[0]==1 and listeRep[1]==0):
rep=listeRep[0]
elif(listeRep[0]==0 and listeRep[1]==2):
rep=listeRep[1]
# it's here that i start the exportation and that my window is fixed . I would like show the advenced bar
threadExportation = threading.Thread(target=self.browser1.ExportationFanny("recherche_beneficiaire_natureBeneficiaire",rep=rep,nni=self.nni))
threadExportation.start();
def frameChoixExportation(self):
self.fenetreConnexion.pack_forget()
choix1 = customtkinter.IntVar()
choix2 = customtkinter.IntVar()
frameChoix = self.cadre();
frameChoix.pack(fill="both", expand=False)
labelInformation = customtkinter.CTkLabel(master=frameChoix,font=("",20,'underline'),text="En cochant une des deux cases\nvous lancez une exportation Salariés ou Pensionnés",width=200)
labelInformation.pack(anchor="n",side="top",pady=20)
checkboxSalarie = customtkinter.CTkCheckBox(master=frameChoix,variable=choix1,text="Salariés",font=("",20),width=100,onvalue=1,offvalue=0,command=lambda:self.onlyOneCheckboxS(choix1,choix2,checkboxPensionne));
checkboxSalarie.pack(anchor="n",side="left",padx=20,pady=40)
checkboxPensionne = customtkinter.CTkCheckBox(master=frameChoix,variable=choix2,text="Pensionnés",font=("",20),onvalue=2,offvalue=0,command=lambda:self.onlyOneCheckboxP(choix2,choix1,checkboxSalarie))
checkboxPensionne.pack(anchor="n",side="right",padx=20,pady=40)
checkboxSalarie.pack()
boutonExportation = customtkinter.CTkButton(frameChoix,text="Lancer Exporation",text_color="white",fg_color="blue",font=("",20),corner_radius=10,width=200,height=50,hover=None,command=lambda:self.threadExportation([choix1.get(),choix2.get()]))
boutonExportation.pack(anchor="s",side="bottom",padx=(frameChoix.winfo_width()// 2, 0),pady=20)
Solution
Bon, j'ai trouvé la solution pour éviter que lors de l'exportation des fichiers ma fenêtre soit fixe. J'ai utilisé dans threading.Thread() le mot lambda qui permet d'enfermer les arguments. Car threading.Thread() ne demande que le nom de la fonction.
threadExportation = threading.Thread(target=lambda:self.exportThread(rep,labelDebut))
threadExportation.start();
Answered By - Desperrois Lucas
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.