I need track data of app usage using tkinter.
the code of the loop is....
'''while True:
current_app = get_active_window()
if 'Google Chrome' in current_app:
current_app = url_to_name(get_chrome_url())
timestamp[current_app] = int(time.time())
time.sleep(1)
if current_app not in process_time.keys():
process_time[current_app] = 0
process_time[current_app] = process_time[current_app] + int(time.time()) - timestamp[current_app]
print(process_time)'''
I need to perform this code using a button,
but when i start the window doesn't respond me.
is there any method for performing while loop along with tkinter window?
That comes from the mainloop() function that is in the Tkinter. You can not insert a while loop to the Tkinter program, because it will freeze it. If the freeze is not a problem for you, then you can do such a thing, but that is not recommended.
Performing while loops using a button in tkinter