如果您看到以下代码行:
L1 = Label(root, text="Time Input")
L1.pack( side = LEFT)
E1 = Entry(root,bd = 5)
E1.pack
我为文本输入编写了几行代码,但没有显示任何内容。我尝试了很多方法,但无法得到它。
这是我的完整代码:
label = Label(root)
label.pack(side = RIGHT)
from Tkinter import *
from tkFileDialog import askopenfilename
root = Tk()
root.geometry("400x400")
f = Frame(root)
#f.pack_propagate(0) # don't shrink
f.pack()
bottomframe = Frame(root)
bottomframe.pack( side = BOTTOM )
scrollbar = Scrollbar(root)
scrollbar.pack( side = RIGHT, fill=Y )
def callback():
r = open(askopenfilename(),'r')
def sel():
selection = "You have selected " + str(v.get())
label.config(text= selection)
a = Button( f,text='Choose File(Audio or Video)', fg="Blue",command=callback)
##b = Button(text='click me', command=callback)
a.pack(padx=10, pady=10, side=LEFT)
##b.pack()
##redbutton = Button(f, text="Red", fg="red")
##redbutton.pack( side = LEFT)
##
##greenbutton = Button(f, text="Brown", fg="brown")
##greenbutton.pack( side = LEFT )
##
##bluebutton = Button(f, text="Blue", fg="blue")
##bluebutton.pack( side = LEFT )
##
##blackbutton = Button(bottomframe, text="Black", fg="black")
##blackbutton.pack( side = BOTTOM)
v = StringVar()
R1 = Radiobutton(root, text="G", variable=v, value="G",
command=sel)
R1.pack( anchor = W )
R2 = Radiobutton(root, text="PG", variable=v, value="PG",
command=sel)
R2.pack( anchor = W )
R3 = Radiobutton(root, text="NC16", variable=v, value="NC16",
command=sel)
R3.pack( anchor = W )
R4 = Radiobutton(root, text="M18", variable=v, value="M18",
command=sel)
R4.pack( anchor = W )
R5 = Radiobutton(root, text="R21", variable=v, value="R21",
command=sel)
R5.pack( anchor = W )
L1 = Label(root, text="Time Input")
L1.pack( side = LEFT)
E1 = Entry(root,bd = 5)
E1.pack
label = Label(root)
label.pack(side = RIGHT)
R1.select()
root.mainloop()
答案 0 :(得分:0)
您忘记拨打pack
的{{1}}方法,将E1
放在其后:
()
如果没有这个更改,输入框将永远不会放在窗口上。