473,889 Members | 1,272 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(even t, 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(even t,TickEvent):.. .?

Oct 26 '06 #1
4 1156
steve wrote:
The example code from: http://sjbrown.ezide.com/games/example1.py.html
...
def Notify( self, event ):
if not isinstance(even t, 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(even t,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(even t, 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(even t,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
2894
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 also have a short look at the example below and give me some comments, please? Example:
11
2810
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 (strPubCity) for Publisher City. These two fields have a many-to-one relationship with tables, (tlkpPubName and tlkpPubCity) respectively. The lookup tables only have one field (strPubName and strPubCity), which is their primary key. I also have...
4
17279
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 maintain the reference to any module.
2
981
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 "WaitingForSpecificAction.aspx"), should get event that this action is performed. How to do it ?
8
4322
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 button at runtime: //----- Code snippet protected System.Web.UI.WebControls.PlaceHolder ImageHolder; private void Page_Load(object sender, System.EventArgs e)
4
2525
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 an event which seems to be a "CloseUp" event - is there such an event? Surely there must be!
4
6705
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 implement an Event based program and Message system. I have a very basic event engine that I'm feeling works a bit backwards. I'm looking for documents, source code, and books that may help me better understand how to implement this type of code. I am...
24
55289
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 EventHandler(Onbutton_click); I want to pass more information related that event. & want to use that
2
1459
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 10 or 20 seconds, should I use .IsPostback? If not, then the gridviews databinding in the page should be written in Page_Load or in the other events like SelectedIndexChanged, RowCommand where the click is handled? TIA Iordanis
0
9803
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11187
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10439
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7991
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7148
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5825
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6021
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4642
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4248
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.