Skip to content

use extended Group instead of property #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Aug 13, 2020

Conversation

FoamyGuy
Copy link

This is the beginning of a resolution for the issue raised by #22 .

I have done basic testing with a slightly modified simpletest and it seems to be working as intended so far. It does need some more thorough testing though. And the example scripts should be updated to use the the API without accessing group property.

However in making these changes and testing them out I got to thinking about the ramifications a bit more. This change as it is now breaks any existing user code that uses the button since the group property will no longer exist.

Maybe it would be good to provide backwards compatibility for some time by returning the correct thing from a group property along with printing a deprecation warning message?

I will work on getting this tested more and updating the examples this week. I wanted to get this PR created to see if anyone else has thoughts about making this change and/or the deprecation considerations.

@tannewt
Copy link
Member

tannewt commented Aug 10, 2020

I think you could use a property to have .group return self and print a warning.

@FoamyGuy FoamyGuy marked this pull request as ready for review August 12, 2020 02:50
@FoamyGuy
Copy link
Author

I think this is ready to go now. I have added a group property that returns self and prints a warning. The example scripts have also been updated to use new API for adding the button to other Groups.

Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more set of suggestions. I don't think the zeroes help going forwards.

Comment on lines 199 to 200
self._label.x = 0 + (self.width - dims[2]) // 2
self._label.y = 0 + self.height // 2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self._label.x = 0 + (self.width - dims[2]) // 2
self._label.y = 0 + self.height // 2
self._label.x = (self.width - dims[2]) // 2
self._label.y = self.height // 2

I think these zeroes will be confusing going forwards.

width - 2,
height - 2,
fill=self.fill_color,
outline=self.outline_color,
)
elif style == Button.SHADOWROUNDRECT:
self.shadow = RoundRect(
x + 2, y + 2, width - 2, height - 2, r=10, fill=self.outline_color
0 + 2, 0 + 2, width - 2, height - 2, r=10, fill=self.outline_color
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
0 + 2, 0 + 2, width - 2, height - 2, r=10, fill=self.outline_color
2, 2, width - 2, height - 2, r=10, fill=self.outline_color

@@ -148,32 +147,32 @@ def __init__(
)
elif style == Button.SHADOWRECT:
self.shadow = Rect(
x + 2, y + 2, width - 2, height - 2, fill=outline_color
0 + 2, 0 + 2, width - 2, height - 2, fill=outline_color
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
0 + 2, 0 + 2, width - 2, height - 2, fill=outline_color
2, 2, width - 2, height - 2, fill=outline_color

@FoamyGuy
Copy link
Author

Latest commit removes the usage of extra zeros in the calculations.

Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants