Package: easy-button
EasyButtonEasily create interactable button objects in PyGame with just a few short lines of code.EasyButton is used to create button objects from class objects defined in theeasy_button.pymodule file. These buttons are fully customizable; can be updated and moved in-execution of code; and contain several methods for displaying hover effects and executing commands when clicked. As of this first launch version, the only button object is the 'rect' rectangle button. This module is not a professional product; rather, it is made by a student for other students as an alternative to the tedious, excessive amount of code it takes to create a working, interactive button in PyGame.If you would like to Say Thanks for this project, then please.Button Class ObjectsTo create a button object,import easy_button, and setmy_button = easy_button.button_object(). No object requires values to be passed to it to initiate, though such will be required to make the button usable. Following are headings for each button object; then comes a bulleted list of the object's methods — the functions that can be called upon the button to make it operate — and what they do. Each method is followed by a sublist of the values that can be passed to it and the same's defaults. The final bullet point is another sublist, of certain attributes of the whole class that are not covered by the method documentation, but may be of interest to the programmer; not all other attributes are present, however.EasyButton AttributesVariables of the EasyButton module that do not belong to any of its subclasses.__version__A variable that contains the version of EasyButton installed in your directory; the version that is being used.rect()Rectangular button object.__init__(pos=(0, 0), width=100, height=50, text='', bg=(255, 255, 255), fg=(0, 0, 0), font='timesnewroman', pixel=False, thickness=0, command=None, border=0, margin=10, bc=(255, 0, 0), hover_bg=None, hover_fg=None, hover_border=5, hover_bc=(0, 255, 0), hover_text=None, hover_margin=None, hover_font=None, hover_pixel=False, image=None, hover_image=None)This method is run upon creating the button object; it stores the buttons properties.pos = (0, 0)Position of top-left corner of button objectwidth = 100Widthheight = 50Heightborder = 0Thickness of border with which to wrap buttontext = ""Text to display on button; defaults to no textfont = "timesnewroman"Font to use on textpixel = FalsePixelate text or notmargin = 10Margin of spacing to put betweentextandimageand border/button edge; negative value blows text out of buttonimage = NoneImage to display on button background, behindtext; will be automatically scaled smaller — not larger — to fit usingmargin, liketext; takes either image file path or predefined PyGame Image object — note that the former sometimes fails (known error), and is not advised; defaults to no imagebg = (255, 255, 255)Background color of button; defaults to blackbc = (255, 0, 0)Border color; defaults to redfg = (0, 0, 0)Foreground (text) color; defaults to whitethickness = 0Thickness of button background; does not inhibit placement of objects of the button; value less than width/height results in transparent button center; defaults to solid backgroundcommand = NoneFunction to execute when button is clickedhover_border = 5Thickness of border to wrap button with while the same is touching the mouse cursorhover_text = NoneText to display when button is touching mouse cursor; defaults totexthover_font = NoneFont to use on text displayed while button is touching the mouse cursor; defaults totexthover_pixel = FalsePixelate the text displayed when button is touching the mouse cursor or nothover_margin = NoneMargin of spacing to put between text and border/button edge while the same is touching the mouse cursor; negative value blows text out of button; defaults tomarginhover_image = NoneImage to display on button background, behind text, when button is touching the mouse cursor; will automatically be scaled to size like text usinghover_margin; takes either image file path or predefined PyGame Image object — note that the former sometimes fails, and is not advised; defaults toimagehover_bg = NoneBackground color of button while the same is touching the mouse cursor; defaults tobghover_bc = (0, 255, 0)Border color while button is touching mouse cursor; defaults to greenhover_fg = NoneForeground (text) color while button is touching the mouse cursor; defaults tofgupdate(self)This method updates the button object'ssurfaceattribute so as to make it display updated properties. It is automatically run by thecheck_hovermethod when a change inhoveringstatus is detected, or the text it is displaying varies from the text it should be displaying.draw(self, destinationThis method blits the button onto a PyGame Surface.destinationThe PyGame Surface that the button is to be drawn tohover(self, point)This method checks to see if the button is touching the mouse cursor; if it is, it updates the button's Surface to display the values specially entered for when the button is being hovered over.pointA tuple or list containing thexandypositions of the mousecheck_hover(self, point)This method checks to see whether the button is touching the mouse cursor and returns the according boolean value.pointA tuple or list containing thexandypositions of the mouseclick(self, point, down)This method checks whether or not the button has been clicked. If it has, then it executes thecommandfunction attribute of the button.pointA tuple or list containing thexandypositions of the mousedownA boolean value stating whether or not the mouse is downcheck_click(self, point, down)This method checks whether or not the button has been clicked, and returns the according boolean value.pointA tuple or list containing thexandypositions of the mousedownA boolean value stating whether or not the mouse is downget_fonts(self)This method calls the PyGamefont.get_fontsmethod and returns a list of all the available fonts that can be given as values forfontandhover_font.AttributessurfaceThe PyGame surface object that contains the image of the button which is updated by theupdatemethod and blitted to a PyGame Surface object by thedrawmethod.