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,yor byanchor_pointandanchored_position.These two methods could be inconsistent, so I coded this so that setting
anchored_positionactually updates just the x,y locations. That way we don't have inconsistencies betwee the two. And theanchored_positiongetter just calculates the value based on the storedx,yvalue.However, that means that the positioning of the label will depend upon the order of setting the position. For example, if you set
x,ydirectly, then it will go to that position until you setanchored_positionto another value.In order to keep the
anchored_positionconsistent, thetextsetter 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_pointto allow a value of None. That way, if theanchor_pointis None, then theanchored_positionis also invalid. That will ensure that thex,yvalues are not changed when theanchor_pointis not set and then the text is changed. I hope this is solution is generic enough to resolve most issues like this.