BhavyeMathur/goopylib-v1

Bug: Rectangle's Width not being set to zero even though specified

BhavyeMathur opened this issue · 3 comments

When I am trying to create a rectangle and setting its width to 0, it doesn't reflect in the actual window. My code:

from goopy import *

setStyle("dark gui")
window = GraphWin(title="Example GUI Design", height=800, width=900, autoflush=False)

Rectangle(Point(20, 70), Point(295, 385), isRounded=True, fill="primary fill", width=0).draw(window)

while True:
    window.updateWin()

and the output:

image

This seems to be an internal issue with how Tkinter creates polygons (what goopy currently uses for creating rounded rectangles). If the code for drawing the rectangle is changed from:

return canvas.create_polygon(points, options, smooth=self.isRounded)

to:

return canvas.create_rectangle(self.p1.x, self.p1.y, self.p2.x, self.p2.y, options)

it works fine (except we don't get rounded edges anymore).

This has been temporarily fixed by setting the outline of the rectangle to its fill colour if the width is 0...

Alright, here's an answer: https://stackoverflow.com/questions/62740726/tkinter-polygons-width-not-being-set-to-zero-even-though-specified/62741739#62741739

So this is weird, but it works differently for rectangles & polygons... but it's been fixed now!