# Python program to create a basic settings menu using the pygame_menu moduleimportpygameimportpygame_menuaspmpygame.init()# ScreenWIDTH,HEIGHT=700,600screen=pygame.display.set_mode((WIDTH,HEIGHT))# Standard RGB colorsRED=(255,0,0)GREEN=(0,255,0)BLUE=(0,0,255)CYAN=(0,100,100)BLACK=(0,0,0)WHITE=(255,255,255)# Main function of the programdefmain():# List that is displayed while selecting the graphics levelgraphics=[("Low","low"),("Medium","medium"),("High","high"),("Ultra High","ultra high")]# List that is displayed while selecting the window resolution levelresolution=[("1920x1080","1920x1080"),("1920x1200","1920x1200"),("1280x720","1280x720"),("2560x1440","2560x1440"),("3840x2160","3840x2160")]# List that is displayed while selecting the difficultydifficulty=[("Easy","Easy"),("Medium","Medium"),("Expert","Expert")]# List that is displayed while selecting the player's perspectiveperspectives=[("FPP","fpp"),("TPP","tpp")]# This function displays the currently selected optionsdefprintSettings():print("\n\n")# getting the data using "get_input_data" method of the Menu classsettingsData=settings.get_input_data()forkeyinsettingsData.keys():print(f"{key}\t:\t{settingsData[key]}")# Creating the settings menusettings=pm.Menu(title="Settings",width=WIDTH,height=HEIGHT,theme=pm.themes.THEME_GREEN)# Adjusting the default valuessettings._theme.widget_font_size=25settings._theme.widget_font_color=BLACKsettings._theme.widget_alignment=pm.locals.ALIGN_LEFT# Text input that takes in the usernamesettings.add.text_input(title="User Name : ",textinput_id="username")# 2 different Drop-downs to select the graphics level and the resolution levelsettings.add.dropselect(title="Graphics Level",items=graphics,dropselect_id="graphics level",default=0)settings.add.dropselect_multiple(title="Window Resolution",items=resolution,dropselect_multiple_id="Resolution",open_middle=True,max_selected=1,selection_box_height=6)# Toggle switches to turn on/off the music and soundsettings.add.toggle_switch(title="Muisc",default=True,toggleswitch_id="music")settings.add.toggle_switch(title="Sounds",default=False,toggleswitch_id="sound")# Selector to choose between the types of difficulties availablesettings.add.selector(title="Difficulty\t",items=difficulty,selector_id="difficulty",default=0)# Range slider that lets to choose a value using a slidersettings.add.range_slider(title="FOV",default=60,range_values=(50,100),increment=1,value_format=lambdax:str(int(x)),rangeslider_id="fov")# Fancy selector (style added to the default selector) to choose between#first person and third person perspectivessettings.add.selector(title="Perspective",items=perspectives,default=0,style="fancy",selector_id="perspective")# clock that displays the current date and timesettings.add.clock(clock_format="%d-%m-%y %H:%M:%S",title_format="Local Time :{0}")# 3 different buttons each with a different style and purposesettings.add.button(title="Print Settings",action=printSettings,font_color=WHITE,background_color=GREEN)settings.add.button(title="Restore Defaults",action=settings.reset_value,font_color=WHITE,background_color=RED)settings.add.button(title="Return To Main Menu",action=pm.events.BACK,align=pm.locals.ALIGN_CENTER)# Creating the main menumainMenu=pm.Menu(title="Main Menu",width=WIDTH,height=HEIGHT,theme=pm.themes.THEME_GREEN)# Adjusting the default valuesmainMenu._theme.widget_alignment=pm.locals.ALIGN_CENTER# Button that takes to the settings menu when clickedmainMenu.add.button(title="Settings",action=settings,font_color=WHITE,background_color=GREEN)# An empty label that is used to add a seperation between the two buttonsmainMenu.add.label(title="")# Exit button that is used to terminate the programmainMenu.add.button(title="Exit",action=pm.events.EXIT,font_color=WHITE,background_color=RED)# Lets us loop the main menu on the screenmainMenu.mainloop(screen)if__name__=="__main__":main()