Hi guys, I am trying to put the result in a label in TKInter but, I am an absolute beginner, I can find the rught way. Practically I'd like to have a list of labels that pick up the result from the win32.
import win32pdh, string, win32api import tkinter as TT window = TT.Tk() window.title ('Power BI') window.geometry("400x400") def procids(): # each instance is a process, you can have multiple processes w/same name junk, instances = win32pdh.EnumObjectItems(None, None, 'process', win32pdh.PERF_DETAIL_WIZARD) proc_ids = [] proc_dict = {} for instance in instances: if instance in proc_dict: proc_dict[instance] = proc_dict[instance] + 1 else: proc_dict[instance] = 0 for instance, max_instances in proc_dict.items(): for inum in range(max_instances + 1): hq = win32pdh.OpenQuery() # initializes the query handle path = win32pdh.MakeCounterPath((None, 'process', instance, None, inum, 'ID Process')) counter_handle = win32pdh.AddCounter(hq, path) win32pdh.CollectQueryData(hq) # collects data for the counter type, val = win32pdh.GetFormattedCounterValue(counter_handle, win32pdh.PDH_FMT_LONG) proc_ids.append((instance, str(val))) win32pdh.CloseQuery(hq) Lista=(counter_handle,instance, str(val)) proc_ids.sort() return proc_ids label2 = TT.Label(text=Lista, borderwidth=2, relief="groove") label2.grid(column=0, row=0) label2.config(height=2, width=20) window.configure(background='#ffcc00') window.mainloop()
Error:Traceback (most recent call last):
File "C:/Users/xxxxx/PycharmProjects/Primo/TaskManager.py", line 33, in <module>
label2 = TT.Label(text=Lista, borderwidth=2, relief="groove")
NameError: name 'Lista' is not defined