'I want the output to showup in the tkinter body in Dark Pink color. But I have no idea how to do it, and there are no tutorials regarding this
I want the output to showup in the tkinter body in Dark Pink color. But I have no idea how to do it, and there are no tutorials regarding this so please help me.
*And the output text should not have a background color. *And when the input is a number or blank or a symbol, there should be a alert message saying "Please Enter A Name.."
from tkinter import *
import tkinter as tk
import random
import numpy
root = tk.Tk()
root.title("Brain Power Checker By Krish")
def func():
nme = name.get()
alist = ['Smart', 'Dumb', 'Average']
names = {'krish': alist[0], 'gazal': alist[1], 'gajal': alist[1], 'shrilekhya': alist[2], 'siri': alist[2], 'shri': alist[2]}
if (nickname := names.get(nme.lower(), None)):
print(f'{nme} is {nickname}')
else:
print(nme + " is " + random.choice(alist))
name.delete(0, END)
C = tk.Canvas(root,height=900, width=1200)
C.pack()
bg = PhotoImage(file="D:/Brain.png")
my_label = Label(root, image=bg, height=900, width=1200, anchor="nw" )
my_label.place(x=0, y=0, relwidth=1, relheight=1)
name = Entry(root, width=20, bg='#f4c2c2', bd='1', font="arial, 30" )
name.place(x=375, y=150)
button = tk.Button(root, text="Check Now!", font="arial, 25", fg='#AA336A', bg='#f4c2c2', height=1, width=20, command=func)
button.place(x=425, y=700)
root.mainloop()
Solution 1:[1]
Just turn the printing value into a label and you are good to go
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | ANONYMOUS GAMER |