#๐ graphics window unresponsive
65 messages ยท Page 1 of 1 (latest)
@distant axle
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.
@uncut cosmos this is majoirity of it
I don't see a main call.
yh i have that below but the character limit
!paste
If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.
At what point does it cease being responsive?
it opens up
Do you get to your first input call, for example?
2 seconds later it beomces unresponsive
oh yes
after loading up the file and all the data processing
How large is the csv file?
Okay, so negligible.
i dont think its to do with my computer
It does to ask.
because ive tried solely the graphics window on another idle
it worked fine but when i tried again in my main code its just becomes unresponsive
looked everywhere for a solution but to no avail
Idk what graphics is, but you should almost certainly be calling win.update() very regularly. I suspect that as soon as input prevents it from being called, the window will freeze.
Not according to the docs.
re: update
But yes.
input would block, but I think it's threaded
Oh, it spawns its own thread? That's rarer.
I don't see a mainloop call in the examples.
It's tkinter.
So I think they've hidden that away.
There's an autoflush parameter.
True by default.
Would i need to add that to the creation of the window?
Wow, it appears to use update instead of mainloop to process updates, which is apparently really bad practice: https://stackoverflow.com/a/66781785/3000206
It also doesn't appear to spawn its own thread: https://github.com/drycode/zelle-python/blob/master/graphics.py#L185
graphics.py line 185
_root = tk.Tk()```
Maybe use Matplotlib or Seaborn?
There are plenty of use examples on matplltlib's site.
will do just was unsure why this didnt work
Granted, matplotlib is also tkinter.
But I think it's probably more established as a data display library.
Out of curiosity, does it start working of you get rid of the input calls?
Actually meant to reply to this.
lemme give it a go
If it doesn't spawn its own thread, I don't see how else it would work. update seems to process queued events like mainloop, but is sketchier. I'm wondering if things lock when the queues fill or something.
well now the inputs calls are gone the histogram is responsive
That tracks. When writing UIs, your code needs to execute as quickly as possible to give CPU time back to the graphics library so it can do important things, like redraw the window and respond to events. As soon as you having "blocking" code like input that prevents the code from advancing, you're preventing the library from updating the window, so it freezes.
If you need blocking work, you need to typically offload that onto a new thread.
Or just ask for input using the ways the library provides instead of input.
You're welcome.
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, 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.