Ok I have solved the problem I am having, I dug through the manual for the last few weeks and found it. Hopefully this can help anyone else who wants to make a DirectScrolledList button move to the next data in a list.
My code is still a bit buggy but you treat the button as a Direct button https://www.panda3d.org/manual/index.php/DirectButton
so create a function that does something, in my case I have two functions one goes to the next race description in the list and the other goes backwards through the same list (still buggy )
Now in your DirectScrolledList add a decButton_command and a incButton_command and make it equal to your functions (but do not put any brackets for your function “nextDescRace()” will cause an error).
def nextDescRace():
a = raceTable.raceDesc[race.getSelectedIndex() + 1]
print(a)
raceInfo.setText(a)
def previousDescRace():
a = raceTable.raceDesc[race.getSelectedIndex() - 1]
print(a)
raceInfo.setText(a)
race = DirectScrolledList(
decButton_pos= (0.09, 0, 0),
decButton_text = "<<",
decButton_text_scale = 0.15,
decButton_borderWidth = (0.005, 0.005),
decButton_command = previousDescRace,
incButton_pos= (0.8, 0, 0),
incButton_text = ">>",
incButton_text_scale = 0.15,
incButton_borderWidth = (0.005, 0.005),
incButton_command = nextDescRace,
#red frame size
frameSize = (0.0, 0.9, -0.05, 0.11),
#frameColor = (1,0,0,0.5),
pos = (-1.30, 0, 0.35),
items = [],
numItemsVisible = numItemsVisible,
forceHeight = itemHeight,
itemFrame_frameSize = (-0.2, 0.3, -0.05, 0.11),
itemFrame_pos = (0.40, 0,0),
)
run your code and you should be able to print to the console the next and previous data from a list, by clicking the increment or decrement buttons.