Tkinter: how to color the outline of a rectangular canvas canvas?

I draw a rectangle on canvas:

 canvas = Canvas(parent,  cursor="cross")   
 rect = canvas.create_rectangle(20,20, 1, 1, fill="")

I just want to draw a border, leaving the inside transparent (that's why I set fill=""it as indicated here ).

My problem:

I want the rectangle to have a red border. How can i do this?

+6
source share
2 answers

By default, the inside of the rectangle is empty, and you can also get this behavior from fill='', rather than just leaving it.

If you want to highlight the rectangle, just add the keyword argument with the name outlineto the call create_rectangle():

rect = canvas.create_rectangle(20,20, 1, 1, outline='red')

, width=xxx . - 1 .

+9

:

=
. "".

+1

Source: https://habr.com/ru/post/1583990/


All Articles