-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
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
Conversation
@@ -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): |
There was a problem hiding this comment.
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.
Lib/tkinter/__init__.py
Outdated
@@ -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): |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Lib/tkinter/__init__.py
Outdated
@@ -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): |
There was a problem hiding this comment.
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)
.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
Add the
moveto
method (tk >= 8.6.0) to thetkinter.Canvas
widget.https://bugs.python.org/issue23831