Sep-12-2022, 07:47 PM
Yo guys,
I have come quite a bit in coding the crap of this menu but now im kinda stuck! :(
I wonder if there is anyone here that might help me out with a thing or two :P
1, I have now made a "program" for a "client" that helps him handle customers/cars/employes etc.. all this is chooseable with arrow keys!
Exept when I go in a menu program lets say for example the first alternative "handle customers".. I have no clue what so ever how to make arrow keys inside those names.. and how to make "register new customers" open up and give a message like "This option is not available at the moment, contact your administrator for help" or something..
Is it manageble? I think it is since everything is possible while coding hehe :P
2, Also in the code I have written a test that is supposed to be at the top of the program, you can see it in the attached code below, this text does not show when I run the code, how come?
I have come quite a bit in coding the crap of this menu but now im kinda stuck! :(
I wonder if there is anyone here that might help me out with a thing or two :P
1, I have now made a "program" for a "client" that helps him handle customers/cars/employes etc.. all this is chooseable with arrow keys!
Exept when I go in a menu program lets say for example the first alternative "handle customers".. I have no clue what so ever how to make arrow keys inside those names.. and how to make "register new customers" open up and give a message like "This option is not available at the moment, contact your administrator for help" or something..
Is it manageble? I think it is since everything is possible while coding hehe :P
2, Also in the code I have written a test that is supposed to be at the top of the program, you can see it in the attached code below, this text does not show when I run the code, how come?
import replit from getkey import getkey, keys This text does not show in the menubar when I run the program: #Text that is supposed to show in menubar: print(" The bilfirma meny") print("-._.-._.-._.-._.-._.-._.-._.-._.-._.-\n") print("Välj något av nedanstående för att gå vidare:") #Defines "choices" for while-true loop so choises made by user is printed on screen def FirstChoise(): replit.clear() print("Kundlistan:") print("***********") print("1.Gordon Ramsey\n2.Christiano Ronaldo\n3.Lionel Messi\n4.Neymar Jr\n5.Zinedin Zidan\n6.Gareth Bale\n7.Kylian Mpabbe\n8.Paul Pogba\n9.David Beckham\n10.Zlatan Ibrahimovic\n") print("Registrera nya kunder:\n") input("För att gå tillbaka till menyn tryck Enter.") def SecondChoise(): replit.clear() print("Bilar i lager:") print("****************") print("1. Volvo XC90\n2. Citroen C3\n3. Audi Q7\n4. Volkswagen Passat\n") print("Registrera nya bilar:\n") input("För att gå tillbaka till menyn tryck Enter.") def ThirdChoise(): replit.clear() print("Personal:") print("*************") print("1. Mikael Persbrant\n2. Stellan Skarsgård\n3. Michael Nyqvist\n4. Peter Stormare\n5. Johan Falk\n") print("Registrera ny anställd\n") input("För att gå tillbaka till menyn tryck Enter.") #To exit the program: def FourthChoise(): replit.clear() print("Service, verkstad & garantiärenden:") print("***********************************") print("Service & verkstad:\n1. Nissan Micra: olje & bromsbyte (Ska vara klart till kl 14!)\n2. Seat Almera: Påfyllning av vätskor, kyl/spol/olja. (Ska stå klar till imorgon bitti kl 09.00.) \n3. Tesla modell 3: Batteri byte. (1 vecka har vi på oss att lösa detta!)\n\n\n Garantiärenden:\n 1. Volvo XC90, dåligt jobb med bromsbyte, garantin täcker nytt jobb.") input("För att gå tillbaka till menyn tryck Enter.") def EndProgram(): replit.clear() print("Du har valt att avsluta programmet") input("Tryck enter för att avsluta") MenuOptions = ["\t-Hantera Kunder\t", "\t-Hantera bilar\t", "\t-Hantera personal\t","\t-Boka in service, reparationer & garantiärenden\t\n", "\t-Avsluta programmet\t"] #Creates flat number for "default" state MenuSelected = 0 while(True): replit.clear() #Clears screen after selection print("\x1b[?25l") # Prints visual menu, options and highlighting "arrows" if MenuSelected == 0: print("->" + MenuOptions[0] + "<-") print(MenuOptions[1]) print(MenuOptions[2]) print(MenuOptions[3]) print(MenuOptions[4]) elif MenuSelected == 1: print(MenuOptions[0]) print("->" + MenuOptions[1] + "<-") print(MenuOptions[2]) print(MenuOptions[3]) print(MenuOptions[4]) elif MenuSelected == 2: print(MenuOptions[0]) print(MenuOptions[1]) print("->" + MenuOptions[2] + "<-") print(MenuOptions[3]) print(MenuOptions[4]) elif MenuSelected == 3: print(MenuOptions[0]) print(MenuOptions[1]) print(MenuOptions[2]) print("->" + MenuOptions[3] + "<-") print(MenuOptions[4]) elif MenuSelected == 4: print(MenuOptions[0]) print(MenuOptions[1]) print(MenuOptions[2]) print(MenuOptions[3]) print("->" + MenuOptions[4] + "<-") #Allows arrowkey "up" to go upward in menu keyPressed = getkey() if keyPressed == keys.DOWN and MenuSelected + 1 != len(MenuOptions): MenuSelected += 1 #Allows arrowkey "down" to go downward in menu elif keyPressed == keys.UP and not (MenuSelected == 0): MenuSelected -= 1 #Allows "Enter key" to select highlighted option and go to that option elif keyPressed == keys.ENTER: if MenuSelected == 0: FirstChoise() elif MenuSelected == 1: SecondChoise() elif MenuSelected == 2: ThirdChoise() elif MenuSelected == 3: FourthChoise() elif MenuSelected == 4: EndProgram() print("\x1b[?25h") break