wxPython/wxGlade-0.9.1/widgets/menubar/menubar.py
def _do_move_item(self, event, index, is_down):
        """internal function used by move_item_up and move_item_down.
        Returns the new index of the moved item, or None if no change occurred"""
        #index = self.selected_index
        if index <= 0: return None

        def get(i, j): return self.menu_items.GetItem(i, j).GetText()

        def getall(i): return [get(i, j) for j in range(6)]
        level = self.item_level(index)
        items_to_move = [ getall(index) ]
        i = index+1
        while i < self.menu_items.GetItemCount():
            # collect the items to move up
            if level < self.item_level(i):
                items_to_move.append(getall(i))
                i += 1
            else: break
        i = index-1
        while i >= 0:
            lvl = self.item_level(i)
            if level == lvl: break
            elif level > lvl: return None
            i -= 1
        delete = self.menu_items.DeleteItem
        insert = self.menu_items.InsertStringItem
        set = self.menu_items.SetStringItem
        for j in range(len(items_to_move)-1, -1, -1):
            delete(index+j)
        items_to_move.reverse()
        for label, id, name, help_str, check_radio, event_handler in items_to_move:
            i = insert(i, label)
            set(i, 1, id)
            set(i, 2, name)
            set(i, 3, help_str)
            set(i, 4, check_radio)
            set(i, 5, event_handler)
        ret_idx = i
        if is_down: ret_idx += len(items_to_move)
        return ret_idx
internal function used by move_item_up and move_item_down.
        Returns the new index of the moved item, or None if no change occurred
internal function used by move_item_up and move_item_down.
Returns the new index of the moved item, or None if no change occurred
internal function used by move_item_up and move_item_down . Returns the new index of the moved item or None if no change occurred
def _do_move_item(self, event, index, is_down):
        if index <= 0: return None
        def get(i, j): return self.menu_items.GetItem(i, j).GetText()
        def getall(i): return [get(i, j) for j in range(6)]
        level = self.item_level(index)
        items_to_move = [ getall(index) ]
        i = index+1
        while i < self.menu_items.GetItemCount():
            if level < self.item_level(i):
                items_to_move.append(getall(i))
                i += 1
            else: break
        i = index-1
        while i >= 0:
            lvl = self.item_level(i)
            if level == lvl: break
            elif level > lvl: return None
            i -= 1
        delete = self.menu_items.DeleteItem
        insert = self.menu_items.InsertStringItem
        set = self.menu_items.SetStringItem
        for j in range(len(items_to_move)-1, -1, -1):
            delete(index+j)
        items_to_move.reverse()
        for label, id, name, help_str, check_radio, event_handler in items_to_move:
            i = insert(i, label)
            set(i, 1, id)
            set(i, 2, name)
            set(i, 3, help_str)
            set(i, 4, check_radio)
            set(i, 5, event_handler)
        ret_idx = i
        if is_down: ret_idx += len(items_to_move)
        return ret_idx
def _do_move_item ( self , event , index , is_down ) : if index <= 0 : return None def get ( i , j ) : return self . menu_items . GetItem ( i , j ) . GetText ( ) def getall ( i ) : return [ get ( i , j ) for j in range ( 6 ) ] level = self . item_level ( index ) items_to_move = [ getall ( index ) ] i = index + 1 while i < self . menu_items . GetItemCount ( ) : if level < self . item_level ( i ) : items_to_move . append ( getall ( i ) ) i += 1 else : break i = index - 1 while i >= 0 : lvl = self . item_level ( i ) if level == lvl : break elif level > lvl : return None i -= 1 delete = self . menu_items . DeleteItem insert = self . menu_items . InsertStringItem set = self . menu_items . SetStringItem for j in range ( len ( items_to_move ) - 1 , - 1 , - 1 ) : delete ( index + j ) items_to_move . reverse ( ) for label , id , name , help_str , check_radio , event_handler in items_to_move : i = insert ( i , label ) set ( i , 1 , id ) set ( i , 2 , name ) set ( i , 3 , help_str ) set ( i , 4 , check_radio ) set ( i , 5 , event_handler ) ret_idx = i if is_down : ret_idx += len ( items_to_move ) return ret_idx
internal function used by move_item_up and move_item_down.
internal function used by move_item_up and move_item_down .
"""internal function used by move_item_up and move_item_down.
        Returns the new index of the moved item, or None if no change occurred""" #index = self.selected_index # collect the items to move up
self
event
index
is_down