|
|
Question : 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
|
Answer : Python and Tkinter : image border when button is selected
|
|
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.
|
|
|
|
|