python - Tkinter Label 如何改变Label中的文字样式,例如给文字加删除线

 李妙妙_minioniu_173 发布于 2022-11-05 07:00

如题。未查到Tkinter下,促发条件后,是否能修改label中文字的样式

class Pomodoro_app(Tk):
    def add_task(self):
        global time
        time = StringVar()
        time.set("Start")
        task_content = askstring(title = 'Add a Task', prompt = "Input a task")
        task_label   = Label(self, text = task_content, font = ("Arial, 12")).grid(column = 0, row = 3)
        task_start_button = Button(self, textvariable = time, command = self.start_working).grid(column = 1, row = 3)

    def createWidgets(self):
        self.welcome_label   = Label(self, text = "Welcome to the Challenge!", font = ("Arial, 12")).grid(column = 0, row = 0, columnspan = 2)

        self.add_task_button = Button(self, text = "Add Task", width = 20, command = self.add_task).grid(column = 0 , columnspan = 2)

    def __init__(self):
        """GUI Initiation"""
        Tk.__init__(self)
        self.createWidgets()
        """window Initiation"""
        self.resizable(False, False)
        x = (self.winfo_screenwidth() - self.winfo_reqwidth()) / 2
        y = (self.winfo_screenheight() - self.winfo_reqheight()) / 2
        self.geometry('250x400+%d+%d' % (x, y))
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有