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.

classification
Title: tkinter Dialog fails when more than four buttons are used
Type: Stage:
Components: Tkinter Versions: Python 2.3
process
Status: closed Resolution: duplicate
Dependencies: Superseder:
Assigned To: loewis Nosy List: georg.brandl, hernanpd, loewis
Priority: normal Keywords:

Created on 2006-03-10 14:12 by hernanpd, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg27731 - (view) Author: Hernan P. Dacharry (hernanpd) Date: 2006-03-10 14:12
Example code:

#! /usr/bin/env python
import Dialog
from Tkinter import *
root = Tk()
Button(root, text="Hello!").pack()
root.update()
dialog = Dialog.Dialog(None, {'title': 'Test Dialog',
          'text': "Text...",
          'bitmap': '',
          'default': 0,
          'strings':
('Button0','Button1','Button2','Button3','Button4')})
print 'dialog: ', dialog.num


This example works well, except when clicking in
Button4 that fails:
Traceback (most recent call last):
  File "test.py", line 12, in ?
    dialog = Dialog.Dialog(None, {'title': 'Test Dialog',
  File "/usr/lib/python2.3/lib-tk/Dialog.py", line 21,
in __init__
    cnf['bitmap'], cnf['default'],
TypeError: getint() argument 1 must be string, not tuple

I tried to trace the error (learning in the way a
little bit of python and tcl/tk ;)), mostly due to the
bizarre nature of this problem (note that in tcl/tk
there are no problems when creating dialogs with 4 or
more buttons).

In /usr/lib/python2.3/lib-tk/Dialog/py the exception is
raised because it expects a string as the result to the
call to 'tk_dialog', and for some 'obscure' reason (and
I mean it, I even inspected the Tcl/Tk sources looking
for a reason for this) if the call to 'tk_dialog' has
more than 4 buttons (more than 4 string arguments at
the end) it return a tuple with only one element, the
string result.

The impression I got after browsing the sources of
python/tkinter and Tcl/Tk is that this may be caused
because in tcl there is almost no difference between a
list and string, in this way in the tcl language a
string or a list containing only one string are not
really different.

I have this problem when using python2.3 or python2.4
with Tcl/Tk8.4 (in my particular case under
Debian/Testing distribution);

A quick workaround (although I 'm not sure if it would
cause some problems with other things) would be to
change 'workarounds = 1' to 'workarounds = 0' in
Tkinter.py.
Another option would be to change all calls to tk
functions within tkinter that allways expect as a
result a string...

Hernan
(my apologies for making the report so long) 
msg27732 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2006-03-10 22:30
Logged In: YES 
user_id=849994

Duplicate of #1447222.
History
Date User Action Args
2022-04-11 14:56:15adminsetgithub: 43010
2006-03-10 14:12:03hernanpdcreate