report progress from C function

Good day all.

I rewrote part of my program in C, it's a usually a
long task. I wanted to be able to report the progress
back to my python program. In my module (in addition
to the function that performs the above-mentioned
task) there is a function that returns the variable,
indicating the progress. However I am not sure how to
call it. Once I call the C function that does the work
(it's a while loop that takes minutes sometimes) I
can't call that progress function.
Any ideas?

Thanks in advance,
Michael

How about a Python function that is called from C and pushes the progress variable back into Python? Caveat: I haven't tried this myself.

Phil

···

At 02:09 PM 10/31/2006, you wrote:

Good day all.

I rewrote part of my program in C, it's a usually a
long task. I wanted to be able to report the progress
back to my python program. In my module (in addition
to the function that performs the above-mentioned
task) there is a function that returns the variable,
indicating the progress. However I am not sure how to
call it. Once I call the C function that does the work
(it's a while loop that takes minutes sometimes) I
can't call that progress function.
Any ideas?

Thanks in advance,
Michael

Phil Mayes wrote:

···

At 02:09 PM 10/31/2006, you wrote:

Good day all.

I rewrote part of my program in C, it's a usually a
long task. I wanted to be able to report the progress
back to my python program. In my module (in addition
to the function that performs the above-mentioned
task) there is a function that returns the variable,
indicating the progress. However I am not sure how to
call it. Once I call the C function that does the work
(it's a while loop that takes minutes sometimes) I
can't call that progress function.
Any ideas?

Thanks in advance,
Michael

Maybe use asynchronous pipes - and just set up a communications protocol. Its not fun but its effective.

David

Thanks.
Yes, I just saw in the documentation for parseTuple
that it was possible to push a pointer to a Python
object.

···

--- Phil Mayes <phil@philmayes.com> wrote:

At 02:09 PM 10/31/2006, you wrote:
>Good day all.
>
>I rewrote part of my program in C, it's a usually a
>long task. I wanted to be able to report the
progress
>back to my python program. In my module (in
addition
>to the function that performs the above-mentioned
>task) there is a function that returns the
variable,
>indicating the progress. However I am not sure how
to
>call it. Once I call the C function that does the
work
>(it's a while loop that takes minutes sometimes) I
>can't call that progress function.
>Any ideas?
>
>Thanks in advance,
>Michael

How about a Python function that is called from C
and pushes the progress
variable back into Python? Caveat: I haven't tried
this myself.

Phil

---------------------------------------------------------------------

To unsubscribe, e-mail:
wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail:
wxPython-users-help@lists.wxwidgets.org

Hello,

I wrote this to try and put into practice all I've learned so far about
background threads and progress report from C. This topic was discussed
a few months ago (I think).

After you compile libtest.c, minimal.py is the one to launch. As usual,
I would really welcome any feedback!

To me, the GUI still feel sluggish so my code might still be a bit wrong
(e.g. try to drag the window while it's being updated).

Cheers,
Egor

thread.zip (5.11 KB)