1

I've made an UI and I've used relheight,relwidth,relx,rely as the parameters for all my labels such as:

panel = Label(window, image=img,bg="#e8f3ff") 
panel.image = img
panel.place(relheight=.15,relwidth=0.0425,relx=0.785,rely=0.51)

But for creating rectangles, I'm using:

    canvas = Canvas()
    canvas.create_rectangle(0,0,2000,2000,fill="#e8f3ff")     
    canvas.create_rectangle(0,5,8000,100,outline="#110f71", fill="#004091") 
    canvas.create_rectangle(20,210,575,542,outline="#000000")                  
    canvas.create_rectangle(600,380, 750,850,outline="#000000")
    canvas.create_rectangle(600,100,778,542,outline="#000000")                    
    canvas.pack(fill=BOTH, expand=1)

I tried using rel parameters for create_retangle and it gave an error, so is it possible to create rectangles with borders and bg fills using relative parameters? This is because i want my UI to auto align itself when maximized.

Krishnakumar M
  • 109
  • 1
  • 5
  • 12

1 Answers1

1

so is it possible to create rectangles with borders and bg fills using relative parameters?

No, it is not. Canvas items require absolute coordinates. You'll have to do the math yourself.

Bryan Oakley
  • 370,779
  • 53
  • 539
  • 685