[Tutor] Getting all items above/below of a selected item....................

Magnus Lyckå magnus@thinkware.se
Tue May 13 04:09:20 2003


At 22:57 2003-05-12 -0700, Python-lover wrote:
>   How can i get all rectangles below/above the
>selected one? I tried with find_above()/find_below().
>But they return only one item that is above/below an
>item. Not all. In the case of find_all(), it returns a
>tuple all items Which i dont want.

I don't have a clue what you are talking about. I
think you have to fill us in on the context. What
is find_above and find_below? Are you talking about
some GUI toolkit or what?

Without really knowing what we are at, it seems that
if find_below() finds the next item below, you could
move that rectangle, and then use find_below() on *that*
to find the next and move that and so on.

Something along the lines of this pseudocodish thing...

def moveAllBelow(this, deltaX, deltaY):
     next = this.find_below()
     if next:
         next.moveRelative(deltaX, deltaY)
         moveAllBelow(next, deltaX, deltaY)

As I said, I don't really have a clue about what you
are talking about, so I'm sure this won't run as it is,
but the principle might work.


--
Magnus Lycka (It's really Lyckå), magnus@thinkware.se
Thinkware AB, Sweden, www.thinkware.se
I code Python ~ The shortest path from thought to working program