Scroll through options with buttons

Hi. I would like to create some buttons that scrolls through multiple options. How can I do this? If you have every played Disney’s Toontown Online or another MMO, you probably get the idea. If not, here is an example:

Thank you. :slight_smile:

This is off the top of my head, and so may not be the best solution:

Create your buttons as usual, and assign their command to some method that you define. For each button, set their “extraArgs” to indicate which part is being scrolled (perhaps use constants for this), and -1 for “scroll back” buttons and 1 for “scroll forwards” buttons. Put another way, the “extraArgs” for one arbitrary button might look something like this: [PART_HEAD, 1], where “PART_HEAD” is an integer constant defined elsewhere by you, and “1” indicates that this button scrolls forwards. Store your parts in a set of lists somewhere, and store a list of indices describing which parts are being used by the current model.

Your method would then do something like this (roughly):

def scrollPart(self, partID, dirToScroll):
    partList = self.listOfPartLists[partID]
    # self.modelIndices holds the indices of the current model
    index = self.modelIndices[partID]
    index += dirToScroll
    if index < 0:
        index = len(partList)-1
    elif index >= len(partList):
        index = 0
    self.modelIndices[partID] = index

    #  Now, using "index", get the part from "partList", remove the part being replaced,
    # and assign the new part to the model.

You could