簡體   English   中英

如何更改 tkinter label 的文本?

[英]How do you change the text of a tkinter label?

我是 tkinter 的新手。 按下按鈕后,如何在 tkinter 中更改 label 的文本? 謝謝您的幫助

代碼

import tkinter
root = tkinter.Tk()

def gotothenextstep():
    print('I need help here. How do I change the text of the label?')

label = tkinter.Label(root, text='Click the button to go to the next step:')
button = tkinter.Button(root, text='Click me', command=gotothenextstep)
label.grid(row=10, column=100)
button.grid(row=10, column=200)
root.mainloop()

我是 tkinter 的新手。 按下按鈕后,如何在 tkinter 中更改 label 的文本? 謝謝您的幫助

代碼

import tkinter
root = tkinter.Tk()

def gotothenextstep():
    print('I need help here. How do I change the text of the label?')

label = tkinter.Label(root, text='Click the button to go to the next step:')
button = tkinter.Button(root, text='Click me', command=gotothenextstep)
label.grid(row=10, column=100)
button.grid(row=10, column=200)
root.mainloop()

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM