On Monday 03 December 2007 12:54:54 pm Ed Leafe wrote: > Some corrections interspersed with your post: > > The next line of code assigns a variable “ourButton” for a Dabo > > button. > > Notice that I have added a new attribute “RegID”. Every control/ > > object > > within the Dabo framework can have a “RegID” (or a name?). It > > should be > > unique and if you don't assign a “RegID” the framework will assign > > one. This > > is cool because it allows us (the programmers) to later reference > > the object. > > Knowing the “RegID” I can later assign a value or change a value or > > property > > of the object. > > > > ourButton=dabo.ui.dButton(self,RegID="selectButton",Caption= "...") > > Couple of things. First, Python doesn't have variables; it has local > names for objects. You might think that this is hair-splitting, but > there are substantial differences, and long-time Pythonistas will > sneer at you if you call them 'variables'. > > More importantly, you are confusing 'RegID' with an object's name. > The only thing that a RegID does is provide a unique identifier > within a form for an object that needs to be referenced from > somewhere else. They should never be used at a class level, such as a > custom container with a bunch of controls on it, since you don't know > what else may be on the form when that class is used. Dabo does not > assign RegIDs. > > > Now let's open a file dialog. > > def _openDialog(self,evt): > > # need to pass the evt (in this case a click or Hit) > > evt.stop() > > You definitely don't need to stop() the event, since button events > are not propagated up the containership tree. You should almost never > need to issue stop() for an event. > > > theDialog=dabo.ui.dFileDialog(self) > > theDialog.show() > > > > First you must pass the event (in this case “evt”) otherwise the > > program will > > complain. > > You don't "pass" the event; you have to accept it. > > Events are raised by the UI. You write event handlers to react to > those events, and those handlers must accept an event object. > > > The “evt” variable is very powerful. Using evt.EventObject > > provides the calling objects “ID” for example – there are many other > > attributes. > > It's not a calling object, as it isn't doing any calling. It is the > object for which the event was raised. You may think it is just > semantics, but when you are creating a document to instruct others, > you must use the correct terminology. > > > -- Ed Leafe > -- http://leafe.com > -- http://dabodev.com
Thanks Ed for the corrections. However, I have two questions. My "Learning Python (2nd Editon)" O'Reilly Authors Mark Lutz and David Ascher refers to 'a' in the following: a = 100 as a variable. It's all over the book that way. It also implies that 'a' is an object reference. This follows my thinking as in other languages. What am I missing? I recall you telling me all Dabo objects have a unique identifier. Re-reading the def for RegID you are of course correct that the RegID is not automaticly assigned. Again what am I missing? Do objects have a unique identifier or do I just have a faulty memory? -- John Fabiani _______________________________________________ Post Messages to: [email protected] Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users Searchable Archives: http://leafe.com/archives/search/dabo-users This message: http://leafe.com/archives/byMID/dabo-users/[EMAIL PROTECTED]
