Event documentation

Discussion about using Python with libRocket.

Event documentation

Postby rcdailey on Thu Feb 28, 2008 6:06 pm

Hi,

I was trying to figure out how to get the 'mouse_x' property from the Event object generated due to a 'drag' event. However, after referencing this documentation, I find that at the bottom of the 'Event' category it states the following:

"Parameters on the event are accessed by name as properties on the event itself."

I'm not really sure what this means. At first I thought it meant that I could do this:

Code: Select all
event.mouse_x

However this did not work. According to the documentation here (look at the 3rd code block), this should work since it appears to be used in this form.

I actually had to go reference the pyinvaders sample to find out how to access it. I found out from the sample that there is actually a 'properties' member of the Event object that acts as a dictionary. Later on after looking at the sample I found documentation here that described the 'parameters' member of Event, however the API reference in the Python Manual (first link in the post) does not mention this member. I primarily use the API reference when looking for members for RocketPython objects, which is why it took me so long to find out about the 'parameters' member.

The purpose of this post is to point out what I believe are inconsistencies in an attempt to help you guys improve the documentation.
rcdailey
 
Posts: 113
Joined: Mon Feb 04, 2008 8:04 pm

Re: Event documentation

Postby lloydw on Thu Feb 28, 2008 9:51 pm

Thanks for reporting the incorrect documentation. Indeed, event.parameters['parameter_name'] is the way to access event parameters. The original implementation used direct attributes on the event object, unfortunately the API Reference must have missed when the documentation was updated.
lloydw
Rocket Engineer
Rocket Engineer
 
Posts: 380
Joined: Tue Jan 15, 2008 10:56 pm

Re: Event documentation

Postby GrizzLyCRO on Thu Feb 16, 2012 7:53 pm

Hello, i wonder how could i iterate over "event.parameters". I tried all pythonic ideas i had, then looked at docs more closely and found that rocket is using own Dictionary class. So i tried calling ".iterate" in various forms on parameters, but had no success at all.

I am simply trying to find event data, so i can see what i can work with.
GrizzLyCRO
 
Posts: 4
Joined: Mon Oct 31, 2011 2:07 am

Re: Event documentation

Postby lloydw on Fri Mar 02, 2012 11:53 pm

I'm not sure off the top of my head, but did you try:

Code: Select all
for key,value in event.parameters.iteritems():
   print key + '->' + value
lloydw
Rocket Engineer
Rocket Engineer
 
Posts: 380
Joined: Tue Jan 15, 2008 10:56 pm

Re: Event documentation

Postby manuel on Wed Mar 07, 2012 3:08 pm

lloydw wrote:
Code: Select all
for key,value in event.parameters.iteritems():
   print key + '->' + value

This doesn't work as there is no iterator/__iter__ in the DictionaryInterface
manuel
 
Posts: 2
Joined: Wed Mar 07, 2012 2:58 pm

Re: Event documentation

Postby lloydw on Tue Mar 20, 2012 10:33 pm

Yeah, you're right.

Sorry you may have to implement the __iter__ method according to the boost documentation.
lloydw
Rocket Engineer
Rocket Engineer
 
Posts: 380
Joined: Tue Jan 15, 2008 10:56 pm


Return to libRocket and Python


cron