单选题

有如下程序:

import tkinter as tk
window = tk.Tk()
window.geometry('300x150')
window.title('my first window')
var = tk.StringVar() 
label = tk.Label(window, textvariable=var)
label.pack()
on_hit = False
def hit_me():
    global on_hit
    if on_hit == False:
        var.set('You hit me')
        on_hit = True
    else:
        var.set('')
        on_hit = False
button = tk.Button(window, text='hit me', width=15, height=1, command=hit_me)
button.pack()
window.mainloop()

下列说法不正确的是?()

A

程序运行时,窗体上有1个Label和1个Button

B

Button文字内容在'hit me'和'You hit me'间切换

C

hit_me函数是按钮事件

D

window.mainloop()省略不影响运行效果

赣ICP备20007335号-2