1

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)
3
  • What happens if you remove columnspan=2 from self._image_set_type.grid? Commented Jan 10, 2014 at 18:00
  • Nothing. It seems to be ignoring that parameter. The GUI did not change. Commented Jan 10, 2014 at 18:02
  • Can you post a sample that I'm able to run? Commented Jan 10, 2014 at 18:15

1 Answer 1

3

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)
Sign up to request clarification or add additional context in comments.

1 Comment

Bingo! I was playing with the self attribute when I added the radio button, but forgot about it. Thank you so much!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.