Skip to content

bpo-23831: Add moveto method to the tkinter.Canvas widget #9768

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 4 commits into from
Oct 12, 2018

Conversation

j4321
Copy link
Contributor

@j4321 j4321 commented Oct 9, 2018

Add the moveto method (tk >= 8.6.0) to the tkinter.Canvas widget.

https://bugs.python.org/issue23831

@@ -745,6 +745,28 @@ def test_yscrollincrement(self):
self.checkPixelsParam(widget, 'yscrollincrement',
10, 0, 11.2, 13.6, -10, '0.1i')

def test_moveto(self):
Copy link
Member

Choose a reason for hiding this comment

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

Decorate this test as requiring Tk 8.6.

@@ -2589,6 +2589,15 @@ def tag_lower(self, *args):
def move(self, *args):
"""Move an item TAGORID given in ARGS."""
self.tk.call((self._w, 'move') + args)
def moveto(self, tagOrId, xPos, yPos):
Copy link
Member

Choose a reason for hiding this comment

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

Please add empty lines around a new method to conform PEP 8. This file is far from conforming PEP 8, but let use PEP 8 for new code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, good to know, I usually conform with PEP 8 but I followed the file style here.

Copy link
Member

Choose a reason for hiding this comment

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

Oh, I wanted to add empty lines just around the new method.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It looked strange to me to have empty lines around one method only so I did the whole class. I can remove the extra ones I added if you want.

Copy link
Member

Choose a reason for hiding this comment

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

Agree, this looks weird. But this is a large change not related to this issue. I have opened a new issue just for adding empty lines: bpo-34964. After merging that change you will need to merge your branch with master.

@@ -2589,6 +2589,15 @@ def tag_lower(self, *args):
def move(self, *args):
"""Move an item TAGORID given in ARGS."""
self.tk.call((self._w, 'move') + args)
def moveto(self, tagOrId, xPos, yPos):
Copy link
Member

Choose a reason for hiding this comment

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

I wondering whether it is worth to make coordinates optional: def moveto(self, tagOrId, x='', y='').

Then you could specify just x or y argument: canvas.moveto('group', y=100).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I think it is a good idea, canvas.moveto('group', y=100) is more natural than passing an empty string to the x argument.

@@ -0,0 +1,2 @@
Add ``moveto`` method to the ``tkinter.Canvas`` widget. Patch by Juliette
Copy link
Member

Choose a reason for hiding this comment

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

It is common to add () after the method name: ``moveto()``. The :meth: and :func: role adds it automatically.

@serhiy-storchaka serhiy-storchaka merged commit bf03471 into python:master Oct 12, 2018
@j4321 j4321 deleted the fix-issue-23831 branch October 18, 2018 19:05
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.

4 participants