0
나는 다음과 같은 파이썬에서 파일을 읽을 루프가 : 내가 for 루프에 연결됩니다 Tkinter를 진행 표시 줄 및 파일 목록의 크기를 추가 할 수있는 방법Tkinter를 진행 표시 줄
def Rfile():
for fileName in fileList:
….
을 (루프 전에 시작하고 루프 다음에 닫는다)?.
들으
나는 다음과 같은 파이썬에서 파일을 읽을 루프가 : 내가 for 루프에 연결됩니다 Tkinter를 진행 표시 줄 및 파일 목록의 크기를 추가 할 수있는 방법Tkinter를 진행 표시 줄
def Rfile():
for fileName in fileList:
….
을 (루프 전에 시작하고 루프 다음에 닫는다)?.
들으
이 작은 스크립트는이 작업을 수행하는 방법을 보여줍니다한다 : 당신은 항상 완벽하게 당신의 요구를 충족하기 위해 조정할 수
import tkinter as tk
from time import sleep
# The truncation will make the progressbar more accurate
# Note however that no progressbar is perfect
from math import trunc
# You will need the ttk module for this
from tkinter import ttk
# Just to demonstrate
fileList = range(10)
# How much to increase by with each iteration
# This formula is in proportion to the length of the progressbar
step = trunc(100/len(fileList))
def MAIN():
"""Put your loop in here"""
for fileName in fileList:
# The sleeping represents a time consuming process
# such as reading a file.
sleep(1)
# Just to demonstrate
print(fileName)
# Update the progressbar
progress.step(step)
progress.update()
root.destroy()
root = tk.Tk()
progress = ttk.Progressbar(root, length=100)
progress.pack()
# Launch the loop once the window is loaded
progress.after(1, MAIN)
root.mainloop()
.