下列Python代码创建了一个按钮,当按钮被点击时,会发生什么?( )
import tkinter as tk def on_button_click(): print("Button clicked!") root = tk.Tk() button = tk.Button(root, text="Click me!", command=on_button_click) button.pack() root.mainloop()
弹出对话框显示"Button clicked!"
在控制台输出"Button clicked!"
窗口标题变为"Button clicked!"
按钮文本变为"Clicked!"