请问:bt3 = TK.Button(win, text="clean", width=100, height=3, command=clean).pack()与bt3 = TK.Button(win, text="clean", width=100, height=3, command=clean)bt3.pack()m_text = TK.Text(win, width=100, height=5).m_text.pack()在引用属性insert时报错,但下面的写法就没有问题m_text = TK.Text(win, width=100, height=5)m_text.pack()
2 回答
catspeake
TA贡献1111条经验 获得超0个赞
代码如下:from tkinter import *root=Tk()lbred=Label(root,text="红色沟槽状边缘",fg="red",font=('微软雅黑',15),width=20,height=2,relief=GROOVE)lbred.pack()lbgreen=Label(root,text="绿色凸起的",fg="green",font=('微软雅黑',15),width=20,height=2,relief=RAISED)lbgreen.pack()lbblue=Label(root,text="蓝色脊状边缘",fg="blue",font=('微软雅黑',15),width=20,height=2,relief=RIDGE)lbblue.pack()lbyellow=Label(root,text="黄色凹陷的",fg="yellow",font=('微软雅黑',15),width=20,height=2,relief=SUNKEN)lbyellow.pack()lbpink=Label(root,text="粉红色平的",fg="pink",font=('微软雅黑',15),width=20,height=2,relief=FLAT)lbpink.pack()root.mainloop() |
侃侃无极
TA贡献2051条经验 获得超10个赞
你好,在Python的tkinter中,存在三种布局方法,分别是
place,pack,grid这三种布局方式是同级的,同级的布局方式不能同时使用
而insert属于精准插入,属于place,所以要将pack()分开写
因为你原来写的方式相当于
m_text = TK.Text(win, width=100, height=5).m_text.pack().insert
注意加粗部分!
添加回答
举报
0/150
提交
取消
