I am seeking to add a status bar showing the progress, but not been able to accomplish this, Below is my code. Any help is highly appreciated.
import PySimpleGUI as sg
import pandas as pd
from geopy.geocoders import Nominatim
from geopy.extra.rate_limiter import RateLimiter
sg.theme("DarkTeal2")
layout = [[sg.T("")], [sg.Text("Import file: "), sg.Input(), sg.FileBrowse(key="-IN-")],[sg.Button("Submit")],
[sg.Button("Exit")],[sg.ProgressBar(100, orientation= 'h' , size=(50, 10), key= 'progressbar' )]]
###Building Window
window = sg.Window('Geocoder', layout, size=(600,150))
progress_bar = window['progressbar']
while True:
event, values = window.read()
if event == "Submit":
file = values["-IN-"]
filename = file.split('/')[len(file.split('/'))-1]
geolocator = Nominatim(user_agent = "geoapiExercises")
geocode = RateLimiter(geolocator.geocode, min_delay_seconds=1)
df = pd.read_csv(filename, encoding = 'unicode_escape')
df['location'] = df['add'].apply(geocode)
df['Lat'] = df['location'].apply(lambda x: x.latitude if x else None)
df['Lon'] = df['location'].apply(lambda x: x.longitude if x else None)
df.to_csv('Geo_test.csv')
elif event == sg.WIN_CLOSED or event=="Exit":
break
for i in range(1,10):
progress_bar.update(i)
i=i+=1
window.close()