|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
本帖最后由 召唤狮 于 2020-11-16 15:42 编辑
>>> from tkinter import *
>>> root = Tk()
>>> text = Text(root, width=20, height=5)
>>> text.pack()
>>> text.insert(INSERT,"I love FishC.com!")
>>> def show():
print("呦,我被点了一下~")
bl = Button(text, text="点我点我", command=show, fg='red')
text.window_create(INSERT, window=bl)
mainloop()
windows中Button下text不显示,请问为什么?
你还没调用 show 函数呢,需要正常调用函数哈
参考代码:
- from tkinter import *
- root = Tk()
- text = Text(root, width=20, height=5)
- text.pack()
- text.insert(INSERT,"I love FishC.com!")
- def show():
- print("呦,我被点了一下~")
- bl = Button(text, text="点我点我", command=show, fg='red')
- text.window_create(INSERT, window=bl)
- mainloop()
- show()
复制代码
运行结果:
|
|