Package: pgmenu
pgmenupgmenu is a basic library for an easy creation of menus in pygame, supporting multiple widget types and designed with the user's experience at heart.It's optimized to not hinder performance, maintaining above 200 FPS on average and above 100 FPS for big projects. It's also the most customizable possible, allowing for any visuals to be modified to the user's liking. On top of all that, it stays true to the normal pygame experience, using simple and almost identical syntaxes to pygame's, making it easy to just add at any moment into your project.This library is made for your project, not the project made around the library.If you have anyfeaturesorchangesto add, orbugsto fix, please contact me atvermylioncode@gmail.com. Thanks in advance!Quick GuideA simple and quick guide to read on how to use this fabulous library.InstallationThis library can be installed usingPyPI:pip install pgmenuOr manually viaGitHuborGitLab.This library uses mainlypygame. On one rare occasion,Pillow,itertoolsanddarkdetectare used.UsageThis library, like any menu libraries, allow for multiple use case. It can be used for makingvideo game menus, interactable overlayUIs(widgets allow for transparency), or full-blownapplications.Here is a list of the available widgets:pgmenu.Buttonpgmenu.Checkboxpgmenu.Textboxpgmenu.Framepgmenu.Textpgmenu.ImageOther main functions:pgmenu.Menupgmenu.Themepgmenu.draw()pgmenu.update()pgmenu.getVar()pgmenu.requestCursor()ExampleAn example for a simple login screen using pgmenu:importpygameimportpgmenuFPS=60# Initiating window using pygamepygame.init()pygame.display.set_caption('Login Demo')screen=pygame.display.set_mode((700,700))# Filling screen using theme-given background colorscreen.fill(pgmenu.getVar('bgColor'))clock=pygame.time.Clock()defsubmit():# Check if checkbox of id agreementCheckbox has been checked (aka equal to True)ifpgmenu.Checkbox.get(agreementCheckbox)==True:print('Username:',pgmenu.Textbox.get(usernameTextbox))print('Password:',pgmenu.Textbox.get(passwordTextbox))defcheckboxType(id):print(pgmenu.Checkbox.get(id))# pgmenu default mode is 'System' ('System', 'Dark', 'Light')# pgmenu default theme is Blue ('BLUE', 'RED', 'GREEN', 'YELLOW', 'PURPLE', 'BLUE&BLACK', 'RED&BLACK', 'GREEN&BLACK', 'YELLOW&BLACK', 'PURPLE&BLACK')## pgmenu.Theme.mode('System')## pgmenu.Theme.set('BLUE')# Creating the widgetsloginFrame=pgmenu.Frame.create((100,100),(500,500))loginText=pgmenu.Text.create(screen,'Login Demo',(250,20),textSize=45,centerX=True)usernameText=pgmenu.Text.create(screen,'Username',(50,95),textSize=25)usernameTextbox=pgmenu.Textbox.create((50,125),(400,40))passwordText=pgmenu.Text.create(screen,'Password',(50,200),textSize=25)passwordTextbox=pgmenu.Textbox.create((50,230),(400,40))agreementCheckbox=pgmenu.Checkbox.create((50,290),activatedFunction=lambda:checkboxType(agreementCheckbox))submitButton=pgmenu.Button.create((100,400),(300,50),activatedFunction=submit)# Setting the visuals for the widgetspgmenu.Frame.visuals(screen,loginFrame,borderRadius=20)pgmenu.Textbox.visuals(screen,usernameTextbox)pgmenu.Textbox.visuals(screen,passwordTextbox,textCoverUp='*')pgmenu.Checkbox.visuals(screen,agreementCheckbox,text='I agree that pgmenu is beautiful',textSize=20)pgmenu.Button.visuals(screen,submitButton,text='Submit',textSize=30,borderRadius=15)# Adding them to the framepgmenu.Frame.add(loginFrame,loginText,usernameText,usernameTextbox,passwordText,passwordTextbox,agreementCheckbox,submitButton)# Adding them to a menu for easier global manipulationpgmenu.Menu.add('login',loginFrame,loginText,usernameText,usernameTextbox,passwordText,passwordTextbox,agreementCheckbox,submitButton)pgmenu.Menu.show('login')running=Truewhilerunning:foreventinpygame.event.get():ifevent.type==pygame.QUIT:print('Bye Bye!')running=False# Refresh screen every framescreen.fill(pgmenu.getVar('bgColor'))# Draw the widgets (this time not individually, because pgmenu.Menu takes care of it for us)# By default, pgmenu.Menu.draw() shows the current shown Menupgmenu.Menu.draw()pygame.display.flip()# Update the widgetspgmenu.update(event)# Update clockclock.tick(FPS)DocumentationDocumentation is in the works, and will be available in the next release (pgmenu 1.6).ReleasesNext Release (1.6)DOCUMENTATIONpgmenu.Surface or pgmenu.Canvaspgmenu.ProgressbarArgument: imageSurfacePotentially: pgmenu.Slider and pgmenu.FreesliderPotentially: pgmenu.DisplayRelease 1.5pgmenu.Buttonpgmenu.Checkboxpgmenu.Textboxpgmenu.Framepgmenu.Textpgmenu.Imagepgmenu.Menupgmenu.Themepgmenu.draw()pgmenu.update()pgmenu.getVar()pgmenu.requestCursor()pgmenulibrary by VermylionMIT License3.10.9 Python