在执行下载文件的selenium脚本期间显示自定义TKinter进度条

问题描述 投票:0回答:1

我正在开发一个带有图形界面的Python脚本,用于将文件导出到网站。问题是,当我启动导出时看到变量“buttonExportation (en français)”,customTkinter 页面显示它没有响应,并且我无法显示进度条。我认为这是一个过程问题。我是一名计算机科学专业的学生,过程与过程的概念是可以理解的,但很难应用。我尝试过线程,但它似乎不起作用。我的想法是为界面创建另一个子进程。这是一些代码,如果您需要更多,我可以添加:

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)
python selenium-webdriver automation process customtkinter
1个回答
0
投票

Bon,我找到了解决文件导出问题的解决方案。我使用 threading.Thread() 来获取参数。 Car threading.Thread() 不需要函数名称。 threadExportation = threading.Thread(target=lambda:self.exportThread(rep,labelDebut)) threadExportation.start();

© www.soinside.com 2019 - 2024. All rights reserved.