unexplained behavior of tkMessageBox.askyesno (2)

P

Peter Kleiweg

Here is a minimal example that produces the strange results:


#### begin code ####

#!/usr/bin/env python

from Tkinter import *
import tkFileDialog
import tkMessageBox

def openFile():
r = tkFileDialog.askopenfilename(filetypes=(("some","*.ini"), ("all","*")))
print 'openFile():', type(r), r

def askYesNo():
r = tkMessageBox._show('yes/no', "Do or don't?", 'question', 'yesno')
print 'askYesNo():', type(r), r

root = Tk()
top = Menu(root)
root.config(menu=top)
mFile = Menu(top)
mFile.add_command(label='Open...', command=openFile)
mFile.add_command(label='YesNo', command=askYesNo)
mFile.add_command(label='Quit', command=root.quit)
top.add_cascade(label='File', menu=mFile, underline=0)

root.mainloop()

#### end code ####

In the code above, I unpacked the original function
tkMessageBox.askyesno(), which looks like this:


def askyesno(title=None, message=None, **options):
"Ask a question; return true if the answer is yes"
s = _show(title, message, QUESTION, YESNO, **options)
return s == YES


A session on a machine that goes fine:
askYesNo(): <type 'str'> yes
askYesNo(): <type 'str'> no
openFile(): <type 'str'> # selected 'cancel'
openFile(): <type 'str'> /home/peter/leven/L04/pyL04/Project.ini
askYesNo(): <type 'str'> yes
askYesNo(): <type 'str'> no

And here on another machine were things don't go as they should:
askYesNo(): <type 'str'> yes
askYesNo(): <type 'str'> no
openFile(): <type 'unicode'> # selected 'cancel'
openFile(): <type 'str'> /users3/kleiweg/pyL04/Project.ini
askYesNo(): <type 'bool'> True # causes problems, because True != 'yes'
askYesNo(): <type 'str'> no

Both are Linux machines running Python 2.3.4
The machine with problems has tcl/tk 8.4
The other machine has tcl/tk 8.3

Is this a bug I should report? Is it a bug in Python, or in tk?
 
P

Peter Kleiweg

Peter Kleiweg schreef:

Is this a bug I should report? Is it a bug in Python, or in tk?

I already found a bug report about this on SourceForge:

[ 807871 ] tkMessageBox.askyesno wrong result
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,049
Latest member
Allen00Reed

Latest Threads

Top