I have made a simple game to start learning python, you press a button and the color changes. I have tried to execute this but it doesn't change the color, even tho the variable changes. It’s a bit messy, I know, but I’m still learning.
I've cleaned up the code a little bit
from random import randint
from tkinter import *
color_numb = randint(1,3)
status = True
color = "Blue"
root = Tk()
if True:
if color_numb == 1:
color = "Blue"
if color_numb == 2:
color = "Orange"
if color_numb == 3:
color = "Red"
T = Text(root, height=2, width=30, fg=color)
def ColorC():
color_numb = randint(1,3)
if color_numb == 1:
color = "Blue"
if color_numb == 2:
color = "Orange"
if color_numb == 3:
color = "Red"
T.delete(0.0, END)
T.insert (END, (color))
print((color_numb), (color))
buttonA = Button(root, text = 'Change the colour!', command=ColorC)
T.pack()
buttonA.pack()