Skip to content
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

digit-only tag values are mishandled in Tkinter #41677

Closed
isandler mannequin opened this issue Mar 10, 2005 · 5 comments
Closed

digit-only tag values are mishandled in Tkinter #41677

isandler mannequin opened this issue Mar 10, 2005 · 5 comments
Assignees

Comments

@isandler
Copy link
Mannequin

isandler mannequin commented Mar 10, 2005

BPO 1160383
Nosy @loewis

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = 'https://github.com/loewis'
closed_at = <Date 2008-09-16.01:11:37.238>
created_at = <Date 2005-03-10.04:32:14.000>
labels = ['expert-tkinter']
title = 'digit-only tag values are mishandled in Tkinter'
updated_at = <Date 2008-09-16.01:11:37.225>
user = 'https://bugs.python.org/isandler'

bugs.python.org fields:

activity = <Date 2008-09-16.01:11:37.225>
actor = 'gpolo'
assignee = 'loewis'
closed = True
closed_date = <Date 2008-09-16.01:11:37.238>
closer = 'gpolo'
components = ['Tkinter']
creation = <Date 2005-03-10.04:32:14.000>
creator = 'isandler'
dependencies = []
files = []
hgrepos = []
issue_num = 1160383
keywords = []
message_count = 5.0
messages = ['24517', '24518', '24519', '24520', '73287']
nosy_count = 5.0
nosy_names = ['loewis', 'effbot', 'jepler', 'isandler', 'gpolo']
pr_nums = []
priority = 'normal'
resolution = 'wont fix'
stage = None
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue1160383'
versions = ['Python 2.4']

@isandler
Copy link
Mannequin Author

isandler mannequin commented Mar 10, 2005

It appears that most Tkinter tag operations fail on
digit-only tag values

>>> from Tkinter import *
>>> root=Tk()
>>> c=Canvas(root)
>>> c.create_line(0,0,100,100, tags="123")
1
>>> c.gettags(1)
('123',)
>>> c.pack()       
>>> c.find_withtag("123")
()

tkinter docs:
http://www.pythonware.com/library/tkinter/introduction/x2017-concepts.htm

only say this about tag values:
"Tags are ordinary strings, and they can contain
anything except whitespace."

So this behaviour seems like a bug.

@isandler isandler mannequin assigned loewis Mar 10, 2005
@isandler isandler mannequin added the topic-tkinter label Mar 10, 2005
@isandler isandler mannequin assigned loewis Mar 10, 2005
@isandler isandler mannequin added the topic-tkinter label Mar 10, 2005
@jepler
Copy link
Mannequin

jepler mannequin commented Mar 19, 2005

Logged In: YES
user_id=2772

This is a documentation bug. The Tk documentation says
(canvas, section "ITEM IDS AND TAGS"):
Each item may also have any number of tags
associated with it. A tag
is just a string of characters, and it may take any
form except that
of an integer. For example, ‘‘x123’’ is OK but
‘‘123’’ isn’t. The
same tag may be associated with many different items.

Furthermore, the site www.pythonware.com is a third-party
site not run by the Python developers. The official Python
documentation
(http://docs.python.org/lib/module-Tkinter.html and 'pydoc
Tkinter') doesn't explain the syntax of an item tag anywhere
that I could see)

I recommend closing this bug and notifying pythonware.com /
Fredrik Lundh about the problem via e-mail.

@effbot
Copy link
Mannequin

effbot mannequin commented Mar 19, 2005

Logged In: YES
user_id=38376

Here's the text before the quoted line:

"Everywhere a method expects an item specifier, you can
use one of the following: * item handles * tags /.../ Item
handles are integer values that are used to identify a specific
item on the canvas /.../ Item handles can be passed to the
various canvas methods either as integers or as strings. /.../"

Note the use of "one of", and the fact that item handles are
described before tags. (Writing documentation for people who
only reads random sentences is pretty much impossible...)

@isandler
Copy link
Mannequin Author

isandler mannequin commented Mar 20, 2005

Logged In: YES
user_id=971153

".. Item handles can be passed to the various canvas methods
either as integers or as strings..." (from effbot posting)

While I can see how a very careful reader might notice that
there is a potential conflict between this "handles as
strings" statement and "tags can contain anything", I still
think that at the very least this conflict needs to be
mentioned explicitly.

Furthermore, the site www.pythonware.com is a third-party
site not run by the Python developers (from jepler posting)

Actually for whatever reason I thought that pythonware.com
is the authorative source for tkinter docs....

I guess it does bring an interesting question for Fredrik...
Would you consider merging your Tkinter docs (which seem to
be reasonably complete) with python.org docs which seem to
be very spotty?

@gpolo
Copy link
Mannequin

gpolo mannequin commented Sep 16, 2008

I don't see the bug here. items in a Canvas may be named either as id or
as a tag. If you specify items by something that is actually accepted as
an integer ("123" for instance) then it is assumed to refer to a single
item with id 123.

In your case you have an item with id "1", and when you do:

c.find_withtag("123")

Tk tries to find an item with that id, which doesn't exist and returns
an empty tuple.

@gpolo gpolo mannequin closed this as completed Sep 16, 2008
@gpolo gpolo mannequin closed this as completed Sep 16, 2008
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

0 participants