如何使用tkinter pack()方法将小部件放在下一行?我用了 打包(边=左),但我不能像我的上传图片。包(侧= 左)只剩下...我不能放下一行小部件。一世 怀疑..
[]
from tkinter import *
app = Tk()
app.title('')
app.geometry("800x1200")
Label(app, text = 'a:').pack(side= LEFT)
a = Entry(app)
a.insert(0, "")
a.pack(side= LEFT)
Label(app, text = 'b:').pack(side= LEFT)
b = Entry(app)
b.insert(0, "")
b.pack(side= LEFT)
Label(app, text = 'c:').pack(side= LEFT)
c = Entry(app)
c.insert(0, "")
c.pack(side= LEFT)
Label(app, text = 'd:').pack(side= LEFT)
d = Entry(app)
d.insert(0, "")
d.pack(side= LEFT)
Label(app, text = 'e:').pack(side= LEFT)
e = Entry(app)
e.insert(0, "")
e.pack(side= LEFT)
Label(app, text = 'f:').pack(side= LEFT)
f = Entry(app)
f.insert(0, "")
f.pack(side= LEFT)
Label(app, text = 'g:').pack(side= LEFT)
g = Entry(app)
g.insert(0, "")
g.pack(side= LEFT)
Label(app, text = 'h:').pack(side= LEFT)
h = Entry(app)
h.insert(0, "")
h.pack(side= LEFT)
Label(app, text = '').pack()
text = Text(app, width=100,height=12)
text.insert('1.0', "text")
text.pack()
Label(app, text = '').pack()
text2 = Text(app, width=100,height=12)
text2.insert('1.0', "text")
text2.pack()
Button(app, text = 'save ').pack()
app.mainloop()
回溯(最近一次呼叫最后一次):文件“D:/34545.py”,第2行,in 标签(app,text ='a:')。pack(side = LEFT)NameError:名称'Label'未定义
答案 0 :(得分:4)
如果要使用pack
,则需要将按钮A,B,C和D放在一个帧中,将按钮E,F,G和H放在另一个帧中。另一种选择是使用grid
将所有这些按钮放在一个帧中。