recherche

Maison  >  Questions et réponses  >  le corps du texte

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

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

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

<code>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))

</code>

怪我咯怪我咯2880 Il y a quelques jours1466

répondre à tous(0)je répondrai

Pas de réponse
  • Annulerrépondre