Possible bug in Tkinter - Python 2.6

E

Eric Brunel

Hi all,

I found a behaviour that might be a bug in Tkinter for Python 2.6. Here is
the script:

-----------------------------
from Tkinter import *
from tkMessageBox import *
from tkFileDialog import *

root = Tk()

def ask_file():
file_name = askopenfilename()
print file_name

def ask_confirm():
answer = askyesno()
print answer

Button(root, text='Ask file', command=ask_file).pack()
Button(root, text='Ask confirm', command=ask_confirm).pack()

root.mainloop()
-----------------------------

Scenario:
- Run the script.
- Click the 'Ask confirm' button and answer 'Yes'; it should print True,
which is the expected answer.
- Click the 'Ask file' button, select any file and confirm.
- Click the 'Ask confirm' button and answer 'Yes'.

At the last step, the script prints 'False' for me, which is quite wrong..
Can anybody confirm this?

I reproduced this problem on Linux Fedora Core 4 and Suse Enterprise
Server 9, and on Solaris 8 for Sparc and Solaris 10 for Intel. However, it
seems to work correctly on Windows 2000. I could only test with Python
2.6, and not 2.6.1. But I didn't see any mention of this problem in the
release notes.

And BTW, if this is actually a bug, where can I report it?

TIA
 
B

bieffe62

Hi all,

I found a behaviour that might be a bug in Tkinter for Python 2.6. Here is  
the script:

-----------------------------
 from Tkinter import *
 from tkMessageBox import *
 from tkFileDialog import *

root = Tk()

def ask_file():
   file_name = askopenfilename()
   print file_name

def ask_confirm():
   answer = askyesno()
   print answer

Button(root, text='Ask file', command=ask_file).pack()
Button(root, text='Ask confirm', command=ask_confirm).pack()

root.mainloop()
-----------------------------

Scenario:
- Run the script.
- Click the 'Ask confirm' button and answer 'Yes'; it should print True,  
which is the expected answer.
- Click the 'Ask file' button, select any file and confirm.
- Click the 'Ask confirm' button and answer 'Yes'.

At the last step, the script prints 'False' for me, which is quite wrong.  
Can anybody confirm this?

I reproduced this problem on Linux Fedora Core 4 and Suse Enterprise  
Server 9, and on Solaris 8 for Sparc and Solaris 10 for Intel. However, it  
seems to work correctly on Windows 2000. I could only test with Python  
2.6, and not 2.6.1. But I didn't see any mention of this problem in the  
release notes.

And BTW, if this is actually a bug, where can I report it?

TIA

It works here (no bug), python 2.6.1 on Windows XP.
If it is a bag, maybe it is platform-specific ...


Ciao
 
R

r

First of all be very careful using from "module" import * or you will
have name conflicts. Tkinter is made to be imported this way and i do
it all the time. for the others do.

import tkMessageBox as MB
import tkFileDialog as FD
or whatever floats your boat.

Secondly i hear all the time about problems with fedora distros, so
that would explain the issue to me.
 
J

José Matos

First of all be very careful using from "module" import * or you will
have name conflicts. Tkinter is made to be imported this way and i do
it all the time. for the others do.

import tkMessageBox as MB
import tkFileDialog as FD
or whatever floats your boat.

Importing explicitly works for me in Fedora 11 (rawhide):
-----------------------------
from Tkinter import *
from tkMessageBox import askyesno
from tkFileDialog import askopenfilename

root = Tk()

def ask_file():
file_name = askopenfilename()
print file_name

def ask_confirm():
answer = askyesno()
print answer

Button(root, text='Ask file', command=ask_file).pack()
Button(root, text='Ask confirm', command=ask_confirm).pack()

root.mainloop()
-----------------------------
Secondly i hear all the time about problems with fedora distros, so
that would explain the issue to me.

That seems a long jump in the reasoning since OP reported the same behavior in
Suse and Solaris.
 
T

Terry Reedy

Eric said:
Hi all,

I found a behaviour that might be a bug in Tkinter for Python 2.6. Here
is the script:

-----------------------------
from Tkinter import *
from tkMessageBox import *
from tkFileDialog import *

root = Tk()

def ask_file():
file_name = askopenfilename()
print file_name

def ask_confirm():
answer = askyesno()
print answer

Button(root, text='Ask file', command=ask_file).pack()
Button(root, text='Ask confirm', command=ask_confirm).pack()

root.mainloop()
-----------------------------

Scenario:
- Run the script.
- Click the 'Ask confirm' button and answer 'Yes'; it should print True,
which is the expected answer.
- Click the 'Ask file' button, select any file and confirm.
- Click the 'Ask confirm' button and answer 'Yes'.

At the last step, the script prints 'False' for me, which is quite
wrong. Can anybody confirm this?

I reproduced this problem on Linux Fedora Core 4 and Suse Enterprise
Server 9, and on Solaris 8 for Sparc and Solaris 10 for Intel. However,
it seems to work correctly on Windows 2000. I could only test with
Python 2.6, and not 2.6.1. But I didn't see any mention of this problem
in the release notes.

And BTW, if this is actually a bug, where can I report it?

bugs.python.org
 
E

Eric Brunel

Importing explicitly works for me in Fedora 11 (rawhide):
[snip]

What do you mean by 'works'...? You don't have the problem? It doesn't
change a thing for me...
 
T

Terry Reedy

Eric said:
Eric Brunel wrote:
[snip]>> And BTW, if this is actually a bug, where can I report it?
bugs.python.org

Thanks. I reported the problem.

When you report that you reported to problem to the tracker (a good
idea), please include link so anyone reading this thread can jump there
to continue with followup there.
 
J

José Matos

What do you mean by 'works'...?

The usual meaning, I think. :)

Click "Yes" and the program prints True, click "No" and the programs prints
"False".
You don't have the problem? It doesn't  
change a thing for me...

Notice that I am running the system python, that at least is different.
 
E

Eric Brunel

The usual meaning, I think. :)

Click "Yes" and the program prints True, click "No" and the programs
prints
"False".

This is not the procedure I describe in the original post. The first time,
it works for me too. It's only after I used the file dialog that it stops
working.
Notice that I am running the system python, that at least is different.

Well, unless you're on a platform where a modified Python version is
installed, it shouldn't. If you have the same version as mine, the bug
should be there too...
 
J

José Matos

This is not the procedure I describe in the original post. The first time,
  it works for me too. It's only after I used the file dialog that it stops
working.

You are right, my mistake.
 

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

Staff online

Members online

Forum statistics

Threads
473,769
Messages
2,569,577
Members
45,054
Latest member
LucyCarper

Latest Threads

Top