So im working on a task manager but the widgets disappear after a second or so, see provided video showing how they appear after the hardcoded 100ms delay but then disappear
The related widgets are in watchtower/widgets/tasks.py
code: https://github.com/CheetahDoesStuff/Watchtower
#๐ Qt Widgets disappear?
83 messages ยท Page 1 of 1 (latest)
@glossy tulip
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
Closes after a period of inactivity, or when you send !close.
ive discovered that they disappear instantly if i dont focus the window and if i spawn it and immediently focus it it shows until i unfocus!
dont know how that makes any sense though
Not familiar with PyQT but do you need a similar interval timer or oneshot is fine ?
oneshot is fine, it just fires it after the window and stuff is done
Then my only other guess is either the tasks or one of the parents being garbage collected
how would i check that
If I remember there's a way to execute a lambda on the widgets when destroy happens
May have to look it up though
widget.destroyed.connect(lambda: print("Widget is destroyed"))
Google search tells me this
doesnt print anything when they disappear, it works though because it prints that they get destroyed when closing the window
def get_tasks(self):
tasks = []
for proc in psutil.process_iter(["pid", "name"]):
try:
tasks.append({"pid": proc.info["pid"], "name": proc.info["name"]})
except (psutil.NoSuchProcess, psutil.AccessDenied):
continue
return tasks
check if this exception is thrown
here you continue so you have no idea
its only called when creating the widgets, and the widgets are created, it doesnt repeat its just called once so they wont get overriden
oh ok
def update_tasks(self):
all_tasks = self.get_tasks()
grouped = {}
for task in all_tasks:
grouped.setdefault(task["name"], []).append(task["pid"])
for widget in self.task_widgets:
widget.setParent(None)
self.task_widgets.clear()
for name, pids in grouped.items():
task_widget = Task(name, pids)
self.task_widgets.append(task_widget)
self.addWidget(task_widget)
then it must be this function
that calls successfully and creates the widgets, then when i unfocus the window the widgets disappear
not when that is called tho
yeah
okay so it has to be something with the event loop of focussing I think
another wierd artifact is that the disk progress bars and the ram progress bar (Meter) stays on 100% (cpu meter is unaffected) when focused, then go back to normal when unfocusing
okay so yeah it's gotta do with that
for widget in self.task_widgets:
widget.setParent(None)
self.task_widgets.clear()
why do you do this exactly?
in the future when this function is called repeatedly to update the list this would clear the previous widgets before adding the new ones
if you increase the OneShot
does that affect when they disappear if you unfocus sooner?
wait nvm
shouldn't matter
if its unfocused when the function is called it disappeares almost instantly
ill try to make a repeating function printing the layouts current widgets
i've downloaded your repo imma check on my end
the layout().count() (amount of widgets) starts at 0, then when the widgets are created its 330 which it stays at even after they disappear
so its just visual
but what would cause them to stop rendering
also if i focus the window again they dont reappear
im pretty sure when i focus for the first time the max value of the bars change making the more filled ones look full while the cpu doesnt because its already so low it doesnt exceed the new (unintentional) maximum
okay so what if you tried to set that function on repeat
also the bar problem doesnt happen if i remove thhe TaskSection from the window from the start
what the F is even going on
note that it focuses on hover
yeah
why are the progressbars even affected ๐ญ
there's something with your settings
so that might explain the bars
yeah
your cmd showed an error
or like a remark
so that might also explain the weird full screen on my end
Also so do you click on your cmd or just stop hovering your mouse over the app?
because when I unhover, the PIDs stay
when I click away it minimizes because the always on top setting is not on
yeah no my wayland compositor focuses automatically on hover, you can see that when i hover the window the border becomes brighter showing that its focused
okay I'll enable always on top and see if the PIDs disappear
btw here I would not do Expanding
nvm it's for vertical
yeah
hey so even when windows stays on top when out of focus
the PIDs are still there
so it may be OS
hmm
This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.