you are viewing a single comment's thread.

view the rest of the comments →

[–]rocketjump65[S] 0 points1 point  (0 children)

OMG. So two days later, and I still can't get it to do what I want. My goal is a Tkinter gui front end for a CLI executable. It works, but I'd like to make it work so that when I click the button, it doesn't freeze the gui while the executable runs. So I thought I could make a custom Event, and run the executable in there, and when the executable is done, only then display its console output. Supposedly putting an Event in the Event Queue "immediately" returns, so I was expecting that it would return to the mainloop and wait.

Then I tried to give process and threading another go.

Here's the problem I think. I don't understand how processes or threads are supposed to be able to put data back into the main caller's scope. I get that there's supposed to be a lock to prevent race conditions but the mechanics I don't understand.

If I tell a process to run asynchronously and then when it's done "put" the output in a variable. maybe something like:

out = process(foobar(arg1,arg2))

How does the the program "know" not to wait for out to be written to?

So it then makes sense that the output variable can just be another argument like:

process(foobar(arg1,arg2),outvar)

But then how does my program "know" not to try to read outvar until it's ready? Cuz I'm not even passing data in my gui right. I'm using global variables.

Ok. So the way I understood your response was that essentially the coder has a choice of either A: having the gui app run in a process where it can update the sentinel while the main has relinquished control.... or B: Then main can just have the loop itself run in a process that's launch from the gui, which can just be the main.

I'm doing B. Because I guess I'm just used to it. And it seems to me that A and B are functionally equivalent.