BhavyeMathur / goopylib-v1

A simple-yet-powerful 2D graphics framework built on top of Tkinter capable of creating good-looking & modern GUIs, games, and simple animations.

Home Page:https://pypi.org/project/goopylib

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

BhavyeMathur opened this issue · 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!