Random Color Generator Function

  • Share this:

Code introduction


This function generates a random color, represented by three integers indicating the intensity of the red, green, and blue primary colors.


Technology Stack : Python, PyQt5.QtGui

Code Type : Python Function

Code Difficulty : Intermediate


                
                    
def generate_random_color():
    import random
    from PyQt5.QtGui import QColor

    def random_color():
        return QColor(random.randint(0, 255), random.randint(0, 255), random.randint(0, 255))

    return random_color()