[Tutor] Tkinter grid layout question

Phil phillor9 at gmail.com
Fri Oct 27 20:40:42 EDT 2023


On 27/10/23 19:08, Alan Gauld via Tutor wrote:

Thank you Alan for taking the time to reply.

> Or do you mean the buttons are positioned to the right of
> the image but with the image horizontally level with the
> centre of the buttons? In which case the image surely
> can't be top-left? Or is it a big image, bigger than
> the 4 buttons?

Yes to both.

> Can you use ASCII art to show what you are aiming for?

  |-------------------|  |------------------|
  |                        |  |   frame 2     |
  |    image         |  |                      |
  |                        |  |           X         |
  |   250 x 230    |  |        X   X       |
  |                        |  |          X          |
  |   frame 1       |  |                      |
  |-------------------|  |------------------|

The Xes represent the four direction buttons. There is a label
in the blank space between the up and down buttons that shows
which button was pressed.

I thought about using two frames when the positioning of the
buttons became difficult but I persisted. The buttons kept
splitting apart until I hit upon the idea of using rowspan on
image. I thought this was a bogie idea, but it worked and I didn't
really understand the reason why it worked, hence my message
to the list.

Using two frames is a far better approach which worked
without any editing at all. Just a bit of copying and pasting
from the original code.

Of course I don't know what use I can put to, it was just an exercise to 
create an image to put on a button.

By the way, each button is 50 x 50 and not the usual rectangular shape.

-- 
Regards,
Phil


More information about the Tutor mailing list