Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6032301
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T05:18:50+00:00 2026-05-23T05:18:50+00:00

When I draw a rectangle at global scope: c = Canvas(width=IMAGE_WIDTH, height=IMAGE_HEIGHT, bg=’black’) c.create_rectangle([100,

  • 0

When I draw a rectangle at global scope:

c = Canvas(width=IMAGE_WIDTH, height=IMAGE_HEIGHT, bg='black') 
c.create_rectangle([100, 100, 110, 110], fill='white')
c.pack()
root = Tk() 

and follow this by drawing multiple rectangles in a loop

class gDrawer :
    def __init__(self) :
        self.rect_array = []
        self.x = 0
        self.y = 0

    def incr_counter(self,c,event=None): 
        one_pixel_loc = [self.x, self.y, self.x+5, self.y+5]
        self.rect_array.append(c.create_rectangle(one_pixel_loc, fill='white'))
        self.x += 1

gd = gDrawer()

for xx in range(100) :
    print xx
    gd.incr_counter(c)

root.mainloop()

The single drawn rectangle stays on the canvas while the loop drawn rectangle moves rather than creating a trail of rectangles. I’d like to draw a trail of rectangles and not a moving one, so what is going on here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T05:18:50+00:00Added an answer on May 23, 2026 at 5:18 am

    The default color for the outline of a rectangle is black. This makes it seem like the other rectangles aren’t being drawn when their outline is just overlapping.

    Try changing:

    self.rect_array.append(c.create_rectangle(one_pixel_loc, fill='white'))
    

    to this:

    self.rect_array.append(c.create_rectangle(one_pixel_loc, fill='white', outline='white')
    

    Not sure if this is exactly what you’re looking for, hope it helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I draw a rectangle on a canvas, fill it with a solid colour.
canvas.drawRect(left, top, right, bottom, paint); Say I want to draw rectangle x=30 to x=35
I want to draw a rectangle using canvas which change its size with different
i draw 4 lines (canvas.drawLine) in order to draw a rectangle. Is there any
I want to fill the area outside a rectangle on a canvas. I use
how to draw empty rectangle with etc. borderWidth=3 and borderColor=black and part within rectangle
Whats going on is i need to draw a black rectangle over the image.
Now I can draw rectangle in canvas using a mousedown and mousemove events I
I need to draw rotated rectangle on Canvas. I have x and y of
I'm trying to draw a rectangle on the canvas with the center at the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.