[英]how can I change the colour of my text in python?
我正在为一个学校项目制作一个巫师主题的战斗游戏,但我不知道如何更改文本的颜色。
到目前为止我的代码:
from tkinter import *
import random
root = Tk()
background = PhotoImage(file = 'background.png')
win_screen_image = PhotoImage(file = 'win_screen.png')
lose_screen_image = PhotoImage(file = 'lose_screen.png')
def introductionCanvas():
intro_screen = Canvas(root, height = 720, width = 1280)
intro_screen.create_image(0, 0, image = background, anchor = 'nw')
intro_screen.pack()
intro_text = intro_screen.create_text(240, 80, font = 'Calibri 18', text = ' Welcome, Witcher\nPlease Enter Your Name:', )
introductionCanvas()
root.mainloop()
我尝试使用 tag_configure,但后来我不得不将 the.create_text 更改为 intro_screen = Text(root, ...),而且我不知道如何在不出错的情况下添加实际文本。
您可以在更改字体的同一位置添加fill = 'red'
或任何颜色来更改它:
intro_text = intro_screen.create_text(240, 80, font = 'Calibri 18', fill = 'red', text = ' Welcome, Witcher\nPlease Enter Your Name:', )
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.