Hi Alan, thanks for the reply and my apologies for not realizing there was a Tkinter-discuss group. After even more searching, this seems to be something weird with my version of Tkinter and/or my installation. I can eliminate this effect on my machine (linux, python 2.6) by explicitly creating and destroying a toplevel window after the askdirectory() dialog, as such:<br>
<br>import tkFileDialog,tkMessageBox<br>import Tkinter<br>toplevel=Tkinter.Tk()<br>addDirectory=tkMessageBox.askyesno('a dialog','Add a directory?')<br>print addDirectory<br>theDirectory=tkFileDialog.askdirectory()<br>
toplevel.destroy()<br>addDirectory=tkMessageBox.askyesno('a dialog','Add a directory?')<br>print addDirectory<br><br>If I remove the "toplevel.destroy()" call, I get incorrect behavior. However, if I run the same program on my windows installation (python 2.5), I get correct behavior regardless of the presence of this destroy() command, which I'm pretty sure must be the expected behavior. I will look into my tkinter version and file a bug report if I convince myself my install's not goofy- I get the same behavior with my 3.1 installation on my linux box.<br>
<br>Regarding teh print statements, I was using python 3 syntax but running python 2.6...I just like the 3 syntax better, sorry for the confusion. The extra prints were just me getting carried away with debugging, I love printing stuff.<br>
<br>Kirk<br><br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
"Kirk Vander Meulen" <<a href="mailto:kvander11@gmail.com">kvander11@gmail.com</a>> wrote<br>
<br>
> I'm working on a program partly to get the hang of gui programming. I'm<br>
> a<br>
> bit puzzled by the behavior of simple dialogs- I wonder why, in the<br>
> following code, the second call to tkMessageBox.askyesno always returns<br>
> 'False' (either 'yes' or 'no' return False!). If I take out the call to<br>
> tkFileDialog.askdirectory(), the second call works as expected<br>
> (yes->True,no->False). I would really appreciate if someone could take a<br>
> look at this and tell me what I'm missing. Thanks,<br>
<br>
After converting the imports for Python 3 it worked perfectly for me<br>
<br>
>>> ================================ RESTART<br>
>>> ================================<br>
>>><br>
True<br>
True<br>
H:/PROJECTS/Python/Tutor3<br>
True<br>
H:/PROJECTS/Python/Tutor3<br>
>>> ================================ RESTART<br>
>>> ================================<br>
>>><br>
<br>
> import tkFileDialog,tkMessageBox<br>
> addDirectory=tkMessageBox.askyesno('a dialog','Add a directory?')<br>
> print(addDirectory)<br>
> theDirectory=tkFileDialog.askdirectory()<br>
> print(addDirectory)<br>
<br>
Any reason why you print it a second time even though there has been no<br>
change?<br>
<br>
> print(theDirectory)<br>
> addDirectory=tkMessageBox.askyesno('a dialog','Add a directory?')<br>
> print(addDirectory)<br>
> print(theDirectory)<br>
<br>
And the same here?<br>
<br>
<br>
--<br>
Alan Gauld<br>
Author of the Learn to Program web site<br>
<a href="http://www.alan-g.me.uk/" target="_blank">http://www.alan-g.me.uk/</a><br>
<br></blockquote></div>