From: <kc1...@ya...> - 2007-06-22 16:56:38
|
I've been searching the net for this topic and the one thing that pops up is the addMethod routine. It sounds like something I can use. However, there is no information that I can find on how to use it to help me. Could somebody please help. When I create a button on the fly - with a name defined at run-time, how would I define a method for it? Thanks, > > > Okay, answering my own question: > > I discovered the noresource.py in the samples > directory and followed it to create a textfield at run > time. After that, I went a little further and setup a > button on the fly. In fact, I can have a function > on_Button1_mouseClick which in turn create another button so > that when I click on button1, it creates yet another button. > All works. See attached. > > However, how do I create the event handler on the fly? > In my sample, I pre-defined the routine > on_Button1_mouseClick but that's not going to work for > the general case. > > So, how can I define the event handler on the fly? > > > > --- kc1...@ya... wrote: > > > Hi list, > > > > I have a need to create an ap that changes at run > > time > > depends on what choices were selected. I have a > > tree > > control on the left, a static text area on the top > > right, and now I like to have other components on > > the > > lower right but it would depend on what the user > > clicked on the tree. > > > > The obvious way would be to design one dialog window > > for each of the tree branches, and then when > > selected, > > pop up the dialog window and off it goes. The > > problem > > is that not only would that be very boring, it is a > > *lot* of work because I have lots of branches - > > close > > to 100. > > > > What I am hoping is to simply have a template > > document > > that says when clicked on branch 1, I need a static > > text, followed by a button, a .... and so forth. I > > kind of have this document already. Now I need to > > figure out how to create these components on the > > fly. > > > > Does anybody has a simple example on how this can be > > done? I notice, for example, with the PythonCard > > layout Editor, the Property Editor in effect changes > > as a function of what the user clicks. So this is > > something doable. I did a brief look at the source > > code and its too big and complex program to chew on. > > > > I am hoping that somebody has a simpler example. > > > > Thanks, > > > > > > > > -- > > John Henry > > > > -- > John Henry > -- John Henry |