on-internet
← Community

Python Tkinter random generating the colors?

Stack Overflow ·

from tkinter import * import random tk = Tk() canvas = Canvas(tk, width=400, height=400) canvas.pack() for x in range(0, 40): x1 = random.randint(0,400) y1 = random.randint(0,400) x2 = random.randint(0,400) y2 = random.randint(0,400) x3 = random.randint(0,400) y3 = random.randint(0,400) my_triangle = canvas.create_polygon(x1, y1, x2, y2, x3, y3,\ fill =("blue"), outline="red") Hi! I am playing with tkinter and generating random triangles. The problem is: I want to use random on fill = " " to generate random colors random.randint(start, end) returns numbers, but fill accepts only strings like f

Comments

Sign in or sign up to comment and upvote.

No comments yet.