Python and Tkinter : image border when button is selected

Hi all,

I am developing a GUI interface using python and Tkinter. I dynamically generate buttons and text boxes and the user would be able to move them around.

My requirement is, when the use selects a button, I need to give it a border with small rectangles on 4 of its edges. (To give an impression to the user that this is the button which is actually selected. ).

I tried to use a fixed size image to do this. But some how this is not working. Also the user has option to resize the button (change width and height). If he do this, then enlarging will cause the fixed image not to display correctly.

Is there any general solution to this problem which I can apply to buttons, text boxes or any other widgets the user drags on the screen.

Thanks
LVL 5
techbieAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

peprCommented:
OT: Is Tkinter the right toolkit to use these days?
ron_westCommented:
If you need to be able to select multiple widgets, the most flexible way to do it is to make the widgets part of a Canvas widget, and use the Canvas widget to draw the rectangle.
This also allows you to create other shapes around the widget like resize handles and such.

Setting borderwidth is another way to do it, but it will not give you the right results on all operating system.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Python

From novice to tech pro — start learning today.