472,371 Members | 1,520 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,371 software developers and data experts.

How the event list be sent to EventManager?

The example code from: http://sjbrown.ezide.com/games/example1.py.html
....
def Notify( self, event ):
if not isinstance(event, TickEvent): Debug( "
Message: " + event.name )
for listener in self.listeners.keys():
#If the weakref has died, remove it and
continue
#through the list
if listener is None:
del self.listeners[ listener ]
continue
listener.Notify( event )

I can not figure out how 'event' can has reference to 'event.name'?
Anyhow the 'event' has not defined!
The 'event' dynamically get its own type through
isinstance(event,TickEvent):...?

Oct 26 '06 #1
4 1093
steve wrote:
The example code from: http://sjbrown.ezide.com/games/example1.py.html
...
def Notify( self, event ):
if not isinstance(event, TickEvent): Debug( "
Message: " + event.name )
for listener in self.listeners.keys():
#If the weakref has died, remove it and
continue
#through the list
if listener is None:
del self.listeners[ listener ]
continue
listener.Notify( event )

I can not figure out how 'event' can has reference to 'event.name'?
because the developer expects you to pass in an object that has a name
attribute ? (one of the Event types defined at the top of that module,
most likely).
Anyhow the 'event' has not defined!
it's an argument to the method.
The 'event' dynamically get its own type through
isinstance(event,TickEvent):...?
no, that line simply checks if it's a specific Event type, and enables
debug logging for all other event types.

</F>

Oct 26 '06 #2
Can an argument to reference an object's attribute??

Fredrik Lundh wrote:
steve wrote:
The example code from: http://sjbrown.ezide.com/games/example1.py.html
...
def Notify( self, event ):
if not isinstance(event, TickEvent): Debug( "
Message: " + event.name )
for listener in self.listeners.keys():
#If the weakref has died, remove it and
continue
#through the list
if listener is None:
del self.listeners[ listener ]
continue
listener.Notify( event )

I can not figure out how 'event' can has reference to 'event.name'?

because the developer expects you to pass in an object that has a name
attribute ? (one of the Event types defined at the top of that module,
most likely).
Anyhow the 'event' has not defined!

it's an argument to the method.
The 'event' dynamically get its own type through
isinstance(event,TickEvent):...?

no, that line simply checks if it's a specific Event type, and enables
debug logging for all other event types.

</F>
Oct 27 '06 #3
steve wrote:
Can an argument to reference an object's attribute??
sorry, cannot parse that sentence.

the arguments to a method are objects, and objects have attributes. why
do you find this surprising?

</F>

Oct 27 '06 #4
Thank you,Fredrik,I see.

Fredrik Lundh wrote:
steve wrote:
Can an argument to reference an object's attribute??

sorry, cannot parse that sentence.

the arguments to a method are objects, and objects have attributes. why
do you find this surprising?

</F>
Oct 28 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Robert | last post by:
Hello list, could somebody point me to a good reference about wxPython event handling? I have seen many examples but which one is the best. Waht are the advantages and disadvantages? Can you...
11
by: my-wings | last post by:
I think I've painted myself into a corner, and I'm hoping someone can help me out. I have a table of books (tblBooks), which includes a field (strPubName) for Publisher Name and another field...
4
by: rawCoder | last post by:
Hi all, How Can You Raise Events Asynchronously ? Now for the details ... I want to do inter modular communication using events in such a way that the contributing modules need not...
2
by: Borr | last post by:
Hi, I am writing an ASP .NET application that has a following logic : if one of application users performs some specific action, ALL other users that are browsing some page (lets call it...
8
by: Donald Xie | last post by:
Hi, I noticed an interesting effect when working with controls that are dynamically loaded. For instance, on a web form with a PlaceHolder control named ImageHolder, I dynamically add an image...
4
by: Steve Marshall | last post by:
I'm working on an owner-drawn combo box which has extended functionality. I have to do something to the dropdown list when it drops down, then undo it when it is closed up again. But I can't see...
4
by: AzizMandar | last post by:
C++ Event Coding Questions I have done some simple programs in C++ and read a lot of good C++ books (Including The C++ Programing Language, and C++ Primer) I am trying to understand and...
24
by: =?Utf-8?B?U3dhcHB5?= | last post by:
Can anyone suggest me to pass more parameters other than two parameter for events like the following? Event: Onbutton_click(object sender, EventArgs e)" Event handler: button.Click += new...
2
by: =?Utf-8?B?U2F2dm91bGlkaXMgSW9yZGFuaXM=?= | last post by:
Which is the event sequence when a gridview button (for update) is clicked and the page is post back? I am also a bit confused when to use ..IsPostBack(). If my page data is changing maybe in every...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and credentials and received a successful connection...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
1
by: ezappsrUS | last post by:
Hi, I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...
0
by: jack2019x | last post by:
hello, Is there code or static lib for hook swapchain present? I wanna hook dxgi swapchain present for dx11 and dx9.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.