from tkinter import *
import random
a = random.randint(1,10)
print(a)
root = Tk()
root.geometry("500x500")
root.title(" peleg's random number")
wrongtxt = "Wrong answer the number was, {}".format(a)
righttxt= "Correct the number was {}".format(a)
def Take_input():
INPUT = inputtxt.get("1.0", "end-1c",)
print(INPUT)
if (INPUT == format(a)):
Output.insert(END, righttxt)
else:
Output.insert(END, wrongtxt)
l = Label(text="pick a number between 1-10")
inputtxt = Text(root, height=10,
width=35,
bg="gray")
Output = Text(root, height=10,
width=35,
bg="black")
Display = Button(root, height=2,
bg="black",
width=20,
text="Show",
command=lambda: Take_input())
l.pack()
inputtxt.pack()
Display.pack()
Output.pack()
mainloop()
my code is pretty simple but i cant seem to find a solution on how to change the color of the text that you input, i meant the text of the input that the user is writing also how do i change the color of the text of the printed output
CodePudding user response:
Use fg
parameter:
inputtxt = Text(root, height=10,
width=35,
bg="gray",
fg="red") # <- HERE
Output = Text(root, height=10,
width=35,
bg="black",
fg="red") # <- HERE
Update
How do I do the same thing with the root, I mean the background of the screen?
root.configure(background="red")