2
我附上了两张图片,下面显示了我目前正在获取的布局以及我想要在GUI顶部框架中布局的布局,忽略了中框和底框的。为了尽可能缩短代码,我没有在其中包含代码。 Python Tkinter布局管理
Picture on Left = Layout我得到了。右=布局图像我需要
from Tkinter import *
root= Tk()
topFrame = Frame(root,bg="grey")
topFrame.pack()
midFrame = Frame(root,bg="lightblue",borderwidth=2,relief=GROOVE)
midFrame.pack()
bottomFrame= Frame(root,bg="lightgreen")
bottomFrame.pack(side=BOTTOM)
label1 = Label(topFrame, text="Upload Acitivity File:")
label1.pack(padx=5, pady=10)
first_button=Button(topFrame,text="Button 1")
first_button.pack()
label2 = Label(topFrame, text="Select the Activity")
label2.pack(padx=5,pady=10,side=LEFT)
b1 = Radiobutton(topFrame, text="Walking",value=1)
b1.pack(padx=5, pady=10,side=LEFT)
b2 = Radiobutton(topFrame, text="Running",value=2)
b2.pack(padx=10, pady=10)
root.mainloop()