Finaly found a simple enough task for python, took the plunge, but.....

engsolnom at ipns.com engsolnom at ipns.com
Tue Jan 6 20:40:47 EST 2004


(top posting..sorry)

I tried  Vincent's suggested code and it works just fine with Win2000, Python2.3.
I did change the code to return the path to a selected file, rather than just a directory.
Shows the value of the newsgroups...I was unaware (of course us newbies are unaware of lots of
things) of tkFileDialog...and was about to write a tk interface to do the same thing. Saved a ton of
time, and probably newsgroup bandwidth.
Thanks, Vincent!
Norm

On Tue, 06 Jan 2004 19:43:45 -0800, Sambo <samirw at connection.com> wrote:

>It did get rid of the blank window but it also does not appear on the task bar( 
>or get focus), but I can ALT+TAB to it.
>maybe it is my Vind-Blows 95.
>
>Thanks , Sam.
>
>vincent wehren wrote:
>
>> "Sam" <Sambo at connection.com> schrieb im Newsbeitrag
>> news:3FFB5312.1030803 at connection.com...
>> | Only 2 weeks messing around with it ( thanks to programs like SYNCHRONEX
>> and
>> | BITORRENT ), and already trying to create windows ( the paths are just too
>> long
>> | for me to want to type them ).
>> | After much trial and error I finaly got the following code to open the
>> 'get dir'
>> | dialog , but I am getting another blank window titled 'tk' and "NOT
>> RESPONDING"
>> | When I kill it (end task), I get reiniit/restart (CTRL+F6) in my shell
>> window
>> | What am I doing wrong? Do I need to do anythink to clean up after using
>> the
>> | dialogs?
>> 
>> Take a look at the tkFileDialog module. Or better, use it for convenience.
>> It already provides some "standard" dialogs. You code would then look
>> similar to:
>> #-----------------------
>> import Tkinter
>> import tkFileDialog
>> 
>> def me():
>>     root = Tkinter.Tk()
>>     root.withdraw() # do this to remove the "blank screen" you mention
>>     dirname = tkFileDialog.askdirectory()
>>     return dirname
>> 
>> print me()
>> #------------------------
>> 
>> HTH
>> 
>> Vincent Wehren
>> 
>> 
>> 
>




More information about the Python-list mailing list