You can download this code by clicking the button below.
This code is now available for download.
This function randomly selects a color name from the QColor color name list in the PyQt5.QtGui module and returns the name of the color.
Technology Stack : PyQt5.QtGui
Code Type : Custom function
Code Difficulty : Intermediate
def select_random_color():
import random
from PyQt5.QtGui import QColor
colors = ["red", "green", "blue", "yellow", "purple", "orange"]
color_name = random.choice(colors)
color = QColor(color_name)
return color.name()