【发布时间】:2018-09-13 13:31:38
【问题描述】:
我有一个标签框,在标签框内,我放置了一个按钮。该按钮将始终出现在 LabelFrame 的左上角,尽管我希望它在 LabelFrame 中居中。我缺少什么属性会强制此按钮在 LabelFrame 内居中?
self.f1_section_frame=LabelFrame(self.mass_window, text="LOCATIONS", width=300, height=998, padx=5, pady=5, bd=5)
self.f1_section_frame.grid(row=0, rowspan=6, column=1, sticky="nw", padx=(2,0))
self.f1_section_frame.grid_propagate(False)
self.button_frame1 = LabelFrame(self.f1_section_frame, width=275, height=50)
self.button_frame1.grid_propagate(False)
self.button_frame1.grid(row=1, column=0)
self.b1_scoring=Button(self.button_frame1, text="CONFIRM\nLOCATION(S)", height=2, width=10, command=self.initiate_site_scoring, justify="center")
self.b1_scoring.grid(row=0,column=0, pady=(1,0))
【问题讨论】:
-
省略 pady 应该 - 根据documentation 将小部件居中在父级内。尽管如此,它只会在行/列内居中。根据它们的大小,它是否会出现居中。
标签: python button tkinter widget