我希望输出以深粉色显示在 tkinter 主体中。但是我不知道该怎么做,也没有这方面的教程
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
我希望输出以深粉色显示在 tkinter 主体中。但是我不知道该怎么做,也没有这方面的教程,所以请帮助我。
*并且输出文本不应该有背景色。
*当输入的是数字或空白或符号时,应该有一条警告消息说“请输入姓名..”
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()
只需将打印值变成标签即可开始使用
我希望输出以深粉色显示在 tkinter 主体中。但是我不知道该怎么做,也没有这方面的教程,所以请帮助我。
*并且输出文本不应该有背景色。 *当输入的是数字或空白或符号时,应该有一条警告消息说“请输入姓名..”
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()
只需将打印值变成标签即可开始使用