python timers and COM/directshow

Tim Golden mail at
Tue Sep 23 13:24:05 CEST 2008

Sayanan Sivaraman wrote:
> So I've written a simple video player using directshow/COM in VC++,
> and I'm in the process of translating it to python.  For example, when
> the avi starts playing, I have a call media_control.Run() , etc.
> I'm wondering how I should go about updating my gtk.Hscale widget as a
> trackbar for the avi player.
> In C++, I have the following callbacks that update the scrollbar and
> video position with a timer.

[... snip callbacks ...]

> I'm wondering how I would implement similar callbacks in Python for a
> gtk.Hscale, and some sort of time [I'm not familiar with Pythons
> timers/threading at all].

You'd help your cause a lot here if you posted *Python*
code to indicate what's calling what back where. Also if
you stated whether you were using, eg, the GTK toolkit which
your description suggests, or some other GUI toolkit. Because
they tend to vary as to how they arrange their callbacks.

In geeneral, Python callbacks are trivial: you create the
function to do whatever and then pass the function as an
object into the calling-back function call. Something
like this (invented GUI toolkit):

def handle_lbutton_click (event):
  # do stuff with lbutton click

def handle_widget_slide (event):
  # do stuff with widget slide

handle_event ("lbutton_click", handle_lbutton_click)
widget.attach_event ("slide", handle_widget_slide)


But the details will obviously depend on the toolkit you


More information about the Python-list mailing list