Skip to content

Conversation

@Akuli
Copy link
Collaborator

@Akuli Akuli commented Jun 6, 2021

Most invoke methods return whatever the corresponding command of the widget returns, but passed through Tcl. So ints and strings and a few other things are returned as is, but everything else (such as collections.deque) becomes strings:

>>> import collections, tkinter
>>> b = tkinter.Button()
>>> b.invoke()
''
>>> b['command'] = lambda: 123
>>> b.invoke()
123
>>> b['command'] = lambda: collections.deque([1, 2, 3])
>>> b.invoke()
'deque([1, 2, 3])'

This doesn't apply to tkinter.Spinbox. I couldn't get it to return non-empty strings even by setting a custom command. The Tcl documentation doesn't mention anything about its return value, so it makes sense that it is always the empty string; it's similar to None as the default return value in Python.

@github-actions

This comment has been minimized.

@github-actions
Copy link
Contributor

github-actions bot commented Jun 6, 2021

Diff from mypy_primer, showing the effect of this PR on open source code:

porcupine (https://github.com/Akuli/porcupine.git)
+ porcupine/utils.py:694: error: unused "type: ignore" comment

@srittau srittau merged commit 4b66a9c into python:master Jun 6, 2021
@Akuli Akuli deleted the invoke branch June 6, 2021 20:34
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.

2 participants