All right, sorry, a couple things. First I did realize that my indentations were off, I was consistent so my program ran fine and I wasn't paying close attention. Second thanks for the tip for the functions I didn't know that. I Changed that in my list and I am still getting weird output. It is different though. Also, I did not right a condition for the case of the item number being larger or smaller yet. I did know that it was an issue, sorry for not making that clear in the previous post, I just wanted to get this working first.
Can you explain more about why i should use tuples?
Also, I actually try and follow Pep8 when I am righting nontesting python, but here I am just trying to get this working for my own knowledge base. What standards am I not following other than doc strings and comments? I have not read the standards for classes yet sinse I just learned them recently. I am probably going to do that right now.
I actually found a couple other errors too. I didn't include the index number when I was refering to the currentItem to access the sublist.
That actually helpd quite a bit, however now I am not able to change to the next item in the list.
My new output is something like
main menu start game. like it should be, but when I press down errow it does nothing, or it is just lagging a lot I noticed I was having a problem with lag earlier.
I was able to use a find and replace on my tabs to convert them to spaces to make it more readable to NVDA and Jaws. I forget that when pasting code into forms you have to account for tabs converting.
Also I forgot to mention a couple other things to clarify. The game() and rules() functions just output accessible_output, and the function spk I am using I created to simplify accessible_output.
def spk(text):
speech.Speaker().output(text)
calling and passing in:
mainMenu = [["Start Game", game], ["Start Rules", rules], ["Exit", "Exit"]]
main = Menu()
main.run(mainMenu, "Main Menu")
class Menu():
def run(self, items, title):
itemNumber = 0
itemsLength = len(items)
currentItem = items[itemNumber]
closeMenu = False
spk(title)
spk(currentItem[0])
while closeMenu == False:
for event in pygame.event.get():
key = pygame.key.get_pressed()
if key[pygame.K_t]:
spk(title)
if key[pygame.K_RETURN]:
return currentItem[1]
if key[pygame.K_DOWN]:
itemNumber += 1
spk(currentItem[0])
if key[pygame.K_UP]:
itemNumber -= 1
spk(currentItem[0])
if key[pygame.K_x]:
spk("closing menu")
closeMenu = True