473,395 Members | 1,972 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

unexplained behavior of tkMessageBox.askyesno (2)


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?
--
Peter Kleiweg L:NL,af,da,de,en,ia,nds,no,sv,(fr,it) S:NL,de,en,(da,ia)
info: http://www.let.rug.nl/~kleiweg/ls.html

Jul 18 '05 #1
1 2641
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

--
Peter Kleiweg L:NL,af,da,de,en,ia,nds,no,sv,(fr,it) S:NL,de,en,(da,ia)
info: http://www.let.rug.nl/~kleiweg/ls.html

Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: newgene | last post by:
Hi, group, A weird clipboard behavior for your help: ==============Code============== from Tkinter import * import tkMessageBox root=Tk() root.withdraw() root.clipboard_clear()
4
by: Peter Kleiweg | last post by:
I have a program with these fragments: from Tkinter import * import tkFileDialog import tkMessageBox def openProject(): filepath = tkFileDialog.askopenfilename(filetypes=(("project...
1
by: Ajay | last post by:
hi! my application consists of a GUI with a number of functions. One of these runs a server in a separate thread. the thread is started and given the function start_server to execute the...
2
by: Nathan | last post by:
Hi, I've been testing the standard dialog boxes in tkMessageBox under IDLE. If I type for example, tkMessageBox.askyesno('test', 'test'), the dialog box comes up fine but another window also...
0
by: billmiami2 | last post by:
We are having trouble with an MS Access 2000 application. The application is set up in the standard fashion with a database mdb and a user interface mdb with links from the user to the data file. ...
3
by: peter | last post by:
I have a weird problem in some code I am writing. The user selects a number of files from a list and then can select an option which will rename the selected files. Before the process starts, a...
5
by: rahulnag22 | last post by:
Hi, Is there a way to resize the width of the "tkMessageBox.askyesno" dialog box, so that the text does not wrap to the next line. Thanks Rahul
0
by: dudeja.rajat | last post by:
Hi, I'm working on Windows Platform I'm facing some problem with the tkMessageBox. My code is as below: import tkMessageBox import Tix from Tkinter import * if len(installedLibPath) !=...
0
by: Guilherme Polo | last post by:
On Thu, Aug 28, 2008 at 10:29 AM, <dudeja.rajat@gmail.comwrote: It is good to post a short code sample that demonstrates the problem, but it has to run by itself at least. tkMessageBox...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.