This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Tkinter rowconfigure and columnconfigure functions crash if minsize, pad, or weight is not None
Type: behavior Stage:
Components: Tkinter Versions: Python 3.3, Python 3.4, Python 2.7
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: aoi.leslie, georg.brandl, gpolo, serhiy.storchaka, terry.reedy
Priority: normal Keywords:

Created on 2011-12-02 09:11 by aoi.leslie, last changed 2022-04-11 14:57 by admin. This issue is now closed.

File name Uploaded Description Edit aoi.leslie, 2011-12-02 09:11 A python file to reproduce the problem
Messages (5)
msg148752 - (view) Author: aoi.leslie (aoi.leslie) Date: 2011-12-02 09:11
When use tkinter Widget class's rowconfigure or columnconfigure function (The two functions are defined in baseclass Misc.) to get the setting for a row or column (The setting is a dict containing fields 'minsize', 'pad', 'weight', and 'uniform'.), if field value of 'minsize', 'pad', or 'weight' is a positive integer instead of None, then error |TypeError: argument of type 'int' is not iterable| is raised. Field value of 'uniform' does not matter.

File |tkinter.__init__|, function |_grid_configure|, line 1279, code |elif '.' in value| caused this error. The code assumes the value is a str, but the value can be int.

Suggested Fix:
Change the code block around line 1279 to handle int value as well.
msg148779 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2011-12-02 23:18
Running on Win 7, 3.2.2, IDLE, I get
Traceback (most recent call last):
  File "F:\Python\mypy\", line 19, in <module>
    the_rowconfigure_info = the_frame.rowconfigure(the_row_index)
  File "C:\Programs\Python32\lib\tkinter\", line 1326, in grid_rowconfigure
    return self._grid_configure('rowconfigure', index, cnf, kw)
  File "C:\Programs\Python32\lib\tkinter\", line 1279, in _grid_configure
    elif '.' in value:
TypeError: argument of type 'int' is not iterable
(For tracker purposes, this is a graceful exit, not a crash - as in *nix segfault or equivalent Windows error box.)
>>> help(Frame.rowconfigure)
Help on function grid_rowconfigure in module tkinter:

grid_rowconfigure(self, index, cnf={}, **kw)
    Configure row INDEX of a grid.
    Valid resources are minsize (minimum size of the row),
    weight (how much does additional space propagate to this row)
    and pad (how much space to let additionally).
The above implies that setting uniform=1 (in your code) works because it is ignored. From docs on the web, it appears that 'uniform' is valid and is just missing from our doc string. It is different from the other three, though, in jperhaps not being restricted to int values.

You are right that (line 1259)
    def _grid_configure(self, command, index, cnf, kw):
expects strings (which is what tcl uses). I do not know enough, though, to know where the bug is. I do notice, however, that setting with a Python int matches online Python examples and that the code runs without the attempt to read the config.
msg148785 - (view) Author: aoi.leslie (aoi.leslie) Date: 2011-12-03 03:35
Setting the config has no problem. Only reading has.

The config is read from Tk at line 1270 by code

            res ='grid',
                       command, self._w, index)

. If each of the four options (minsize, pad, uniform, and weight) has been set to value 1, |res|'s value after the tk call would be a tuple |('-minsize', 1, '-pad', 1, '-uniform', '1', '-weight', 1)|. This explains why |uniform|'s value does not cause problem, because it is a str, while the other three's are int. Also int 0 does not cause problem because it is handled at line 1277 by code

                if not value:
                    value = None

so the resulting option value appears as None in rowconfigure or columnconfigure's resulting dict.

In my speculation, the bug is that, when converting from the tuple returned by tk call into the resulting dict to be returned by rowconfigure or columnconfigure, the converting code assumes that the option values in the tuple returned by tk call are all str. But somehow only |uniform|'s value is str, while other three's are int.
msg197763 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-09-15 11:18
I think this was fixed in issue16809.
msg199741 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2013-10-13 18:08
I agree.
Date User Action Args
2022-04-11 14:57:24adminsetgithub: 57728
2013-10-13 18:08:03georg.brandlsetstatus: pending -> closed

nosy: + georg.brandl
messages: + msg199741

resolution: fixed
2013-09-15 11:18:33serhiy.storchakasetstatus: open -> pending
nosy: + serhiy.storchaka
messages: + msg197763

2013-06-15 18:45:07terry.reedysetversions: + Python 3.4, - Python 3.2
2011-12-03 03:35:57aoi.lesliesetmessages: + msg148785
2011-12-02 23:18:47terry.reedysetversions: + Python 2.7, Python 3.3
nosy: + gpolo, terry.reedy

messages: + msg148779

type: crash -> behavior
2011-12-02 09:11:10aoi.lesliecreate