Updated label.py to correct position of initial blank text #81
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is to resolve issue #80
Some background on label positioning:
There are two ways to specify a label's position, either by
x
,y
or byanchor_point
andanchored_position
.These two methods could be inconsistent, so I coded this so that setting
anchored_position
actually updates just the x,y locations. That way we don't have inconsistencies betwee the two. And theanchored_position
getter just calculates the value based on the storedx,y
value.However, that means that the positioning of the label will depend upon the order of setting the position. For example, if you set
x,y
directly, then it will go to that position until you setanchored_position
to another value.In order to keep the
anchored_position
consistent, thetext
setter first gets the currentanchored_position
, then updates the text (in case the size changes) and then resets theanchored_position
(which sets the appropriate x,y values).To solve this issue #80, I updated
anchor_point
to allow a value of None. That way, if theanchor_point
is None, then theanchored_position
is also invalid. That will ensure that thex,y
values are not changed when theanchor_point
is not set and then the text is changed. I hope this is solution is generic enough to resolve most issues like this.