def hello():
print('hello there')

from tkinter import *
tk = Tk()
btn = Button(tk, text='click me', command=hello)
btn.pack()
tk.mainloop()

在程序的最后要加tk.mainloop(),调用mainloop方法就可正常显示tkinter窗口

相关文章:

  • 2021-07-07
  • 2022-12-23
  • 2021-12-31
  • 2021-06-30
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-23
猜你喜欢
  • 2021-08-06
  • 2022-12-23
  • 2021-09-03
  • 2022-01-04
  • 2021-11-29
  • 2022-12-23
相关资源
相似解决方案