我想在下面获取以下Tkinker图像。我只需要将标签设置到所需的位置。
这是我想要的方向。 我不能复制这个,因为Frame不允许将多个东西设置为同一侧,LEFT或RIGHT。
以下是我用来编写此GUI的源代码:
master = Tk.Tk()
master.title('Program Application')
Folder(10)
print "VSM activated input range first"
################### Declare button and respective method ###################
button = Tk.Button(text='VSM', command=VSM, fg="red")
button.config( height = 8, width = 80 )
button.pack() #pack is needed to display the button
bluebutton = Tk.Button(text="AGM Folder",command= lambda: Folder(0), fg="blue").pack(side = LEFT)
bluebutton = Tk.Button(text="VSM Folder",command= lambda: Folder(1), fg="blue").pack(side = RIGHT)
Label(text='Correct Range for Gradient\nOP X2 X1\nIP X2 X1').pack(side=TOP,padx=10,pady=10)
################### Use 3 frames to contains entries, buttons ###################
frameX2 = Frame(master)
frameX2.pack(side=LEFT, expand=1, anchor=E)
entryX2 = Entry(frameX2, width=10)
entryX2.pack(side=TOP,padx=10,pady=10)
entryX2IP = Entry(frameX2, width=10)
entryX2IP.pack(side=TOP,padx=10,pady=10)
frameButton = Frame(master)
frameButton.pack(side=LEFT)
Tk.Button(frameButton, text='Input Range',command= lambda: Folder(2), fg="red").pack(padx=10, pady=10)
frameX1 = Frame(master)
frameX1.pack(side=LEFT, expand=1, anchor=W)
entryX1 = Entry(frameX1,width=10)
entryX1.pack(side=TOP,padx=10,pady=10)
entryX1IP = Entry(frameX1,width=10)
entryX1IP.pack(side=TOP,padx=10,pady=10)
######### Loop ############
master.mainloop() # Continue loop till user close tab
print "End of Program"
entryX1.pack(side=TOP,padx=10,pady=10)
entryX1IP = Entry(frameX1,width=10)
entryX1IP.pack(side=TOP,padx=10,pady=10)
######### Loop ############
master.mainloop() # Continue loop till user close tab
答案 0 :(得分:0)
似乎grid
更合适的布局。
master = Tk.Tk()
master.title('Program Application')
#Folder(10)
print "VSM activated input range first"
################### Declare button and respective method ###################
button = Tk.Button(text='VSM', command=VSM, fg="red")
button.config( height = 8, width = 80 )
button.pack() #pack is needed to display the button
bluebutton = Tk.Button(text="AGM Folder",command= lambda: Folder(0), fg="blue").pack(side = LEFT)
bluebutton = Tk.Button(text="VSM Folder",command= lambda: Folder(1), fg="blue").pack(side = RIGHT)
Label(text='Correct Range for Gradient').pack(side=TOP,padx=10,pady=10)
# ---------------------- change from here -------------------------
frame = Frame(master)
frame.pack(side=LEFT, expand=1)
Label(frame, text='X2').grid(row=0, column=1)
Label(frame, text='X1').grid(row=0, column=3)
Label(frame, text='OP').grid(row=1, column=0)
Label(frame, text='IP').grid(row=2, column=0)
entryX2 = Entry(frame, width=10)
entryX2.grid(row=1, column=1, padx=10, pady=10)
entryX2IP = Entry(frame, width=10)
entryX2IP.grid(row=2, column=1, padx=10, pady=10)
Tk.Button(frame, text='Input Range', command=lambda: Folder(2), fg="red").grid(row=0, column=2, rowspan=3, padx=10, pady=10)
entryX1 = Entry(frame,width=10)
entryX1.grid(row=1, column=3)
entryX1IP = Entry(frame,width=10)
entryX1IP.grid(row=2, column=3)
# ---------------------- to here -------------------------
master.mainloop() # Continue loop till user close tab
输出: