Why do Python Tkinter Radio Buttons align left?
我的单选按钮有对齐问题。我想要三列表单元素。由于某种原因,当我在表单中添加单选按钮时,它们似乎占据了左侧新列的空间。我希望每个单元具有相同大小的简单网格布局。事实并非如此。任何建议将不胜感激!
这是我的代码的一部分:
1 2 3 4 5 6 7 8 9 10 11 12 13 | self._mode_state = StringVar() self._mode_radio_timelapse = Radiobutton(self, text="Timelapse", command=self._transition(), value=self._timelapse_mode, variable=self._mode_state) self._mode_radio_continuous = Radiobutton(self, text="Continuous", command=self._transition(), value=self._continuous_mode, variable=self._mode_state) self._mode_radio_ramphold = Radiobutton(self, text="Ramp and Hold", command=self._transition(), value=self._ramp_hold_mode, variable=self._mode_state) self._mode_radio_timelapse.grid(row=0, column=0, pady=10) self._mode_radio_continuous.grid(row=0, column=1, pady=10) self._mode_radio_ramphold.grid(row=0, column=2, pady=10) image_set_label = Label(text="Image Set Type:") image_set_label.grid(row=1, column=0, pady=10) self._image_set_type = Entry() self._image_set_type.insert(0,"Ramp") self._image_set_type.grid(row=1, column=1, pady=10, columnspan=2) |
窗口小部件并非全部在同一网格上。单选按钮特别是用
解决方法:
1 2 3 4 5 | image_set_label = Label(self, text="Image Set Type:") # made self parent image_set_label.grid(row=1, column=0, pady=10) self._image_set_type = Entry(self) # made self parent self._image_set_type.insert(0,"Ramp") self._image_set_type.grid(row=1, column=1, pady=10, columnspan=2) |