tags:

views:

13

answers:

2

What is the format of the parameter activate_time in Python GTK+ when using Gtk.Menu.popup() method?

I have tried using int(time.time()) but I get a traceback saying an integer is required...

+1  A: 

Not sure if it is a complete solution, but time.time() returns a float, try casting to an int and see what happens.

EDIT: After consulting the source docs, I found this tidbit:

The button and activate_time values should be the mouse button that was pressed to trigger the menu popup and the time the button was pressed. These values can usually be retrieved from the "button_press_event".

Perhaps this will be more helpful than my first attempt.

I also found this C snipet in the C docs, it has popup() being called in a signal handler (that is how they get a "button_press_event".

zdav
but I did specify I was using `int(time.time())` ;-)
jldupont
whoops, should try reading some time... It's a shame pygtk doesn't have any docs, it would sure help in situations like this!
zdav
been googling like crazy on this issue!!
jldupont
+1 for getting me a lead!
jldupont
A: 

I found out I can use gtk.get_current_event_time() to get a reasonable timestamp matching what Gtk looks like it expects.

jldupont