Re: abstract layer question

Magnus Lie Hetland <[email protected]>
Newsgroups gmane.comp.python.anygui.devel
Message-ID <[email protected]>
Robin Becker <[email protected]>:
>         def _set_range(self,range):
>                 assert range[0]<range[1], "reversed or zero range"
>                 self._range = range
>                 self.pos = range[0]
> 
> in the backend I used _ensure_pos to transmit the value to the
> underlying widget.
> 
> How should I achieve the same kind of thing in 0.2.

This sort of thing is still handled by the Attrib class (which has
been rewritten quite a bit). If there is a setter method available (as
defined by anygui.Utils.getSetter) then that will be called instead of
the generic set(). set() is basically a rawSet() (which updates
self.state) followed by a push() (which pushes thing through to the
wrapper).

So... To make a long story short, what you have to do is simply:

  def setRange(self, range):
      assert range[0]<range[1], "reversed or zero range"
      self.set(range=range)

You could also manipulate self.state directly and call
self.push('state') but there's really no point.

So, basically the abstract layer is still here -- it just looks better
(IMO) <wink>.

(Note that I haven't tested this code, and am very tired, so I may not
be making sense at all -- but I think I am. This is how I think it
*should* work, anyway ;)

BTW: getSetter should probably be rewritten since we're not using the
setFooAndBarAndBaz syntax after all... :)

-- 
Magnus Lie Hetland                                  The Anygui Project
http://hetland.org                                  http://anygui.org


-------------------------------------------------------
This sf.net email is sponsored by: OSDN - Tired of that same old
cell phone?  Get a new here for FREE!
https://www.inphonic.com/r.asp?r=sourceforge1&refcode1=vs3390
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.