Does anyone know how I'd go about adding a MatPlotLib pie chart in this piece of code? I've been trying for hours but the figure popup just hangs or can't be opened.
from win32gui import GetForegroundWindow
import psutil
import time
import win32process
import matplotlib.pyplot as plt
from win10toast import ToastNotifier
toaster = ToastNotifier()
process_time={}
timestamp = {}
while True:
current_app = psutil.Process(win32process.GetWindowThreadProcessId(GetForegroundWindow())[1]).name().replace(".exe", "")
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]
if process_time[current_app] > 15:
toaster.show_toast("If something is cracked","Glue it!!!",icon_path='yeet notifi/amogus.ico')
""" labels = []
sizes = []
for x, y in process_time.items():
labels.append(x)
sizes.append(y)
plt.pie(sizes, labels=labels)
plt.axis('equal')
plt.show()
time.sleep(3)
plt.close('all')
#plt.pause() """
print(process_time) ```
The area with the """ is the area that I need the code it. It works for now but just hangs and can't be moved around. Is it something to do with the loop?
All help appreciated.