Re: [gDesklets] Access objects from classes



Mario Gonzalez kirjoitti:
On 07/11/2007, Lauri Kainulainen <lauri sokkelo net> wrote:
One solution would be to give containers a method like
setAttribute(attrName, value) that does the change of value and
refreshes the view.

Any other ideas, anyone?


  I think I found a solution. Maybe it isn't elegant but:

1) I wrote a function inside a .display file
2) I hacked Starter.py file and I added something like the next
paragraph inside a method:

  dsp = self.__containers[0]._Window__display
  scriptlet = Scriptlet("change_img()", dsp._Display__display_file)
  dsp._Display__script.execute(scriptlet)

 Now (writing this email) I think I could use the "scriptlet" from the
Display.py file and avoid the import Scriptlet in Starter.py

 So, with this "solution" (is this really a solution?) I'm able to
access to any object inside a .display file.

Is the purpose of this work to enable displays to get access to all their elements of a certain type? E.g. get access to all labels as you mentioned earlier?

If this is the case, would it be best to introduce a method like "getElementsOfType( typename )" to Dsp class? So developers would do something like this:

for label in Dsp.getElementsOfType('label'):
    # do something with the label element

Is that what you're looking for?

Cheers,
Lauri


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]