1
votes

I'm having an alignment issue with radio buttons. I want three columns of form elements. For some reason, when I add radio buttons to the form, they appear to take up space for a new column on the left. I was hoping for a simple grid layout with each cell having equal size. That doesn't appear to be the case. Any suggestions would be greatly appreciated!

Radio Button Alignment

Here is part of my code:

    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
What happens if you remove columnspan=2 from self._image_set_type.grid? - kylieCatt
Nothing. It seems to be ignoring that parameter. The GUI did not change. - mike boldischar
Can you post a sample that I'm able to run? - kylieCatt

1 Answers

3
votes

The widgets are not all on the same grid. The radio buttons are specifically set with a parent of self, but your Label and Entry widgets are not created with any parent so the parent defaults to the root object.

Here's the fix:

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)