def on_refresh(): processes = psutil.process_iter() processes = sorted(processes, key=lambda proc: proc.name().lower()) list_view.clear() for proc in processes: item = QListWidgetItem(proc.name()) item.proc = proc list_view.addItem(item)