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

Discussion in 'Python' started by vincent wehren, Jan 6, 2004.

  1. "Sam" <> schrieb im Newsbeitrag
    news:...
    | 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






    |
    |
    ****************************************************************************
    ******
    | import os
    | import sys
    | import tkCommonDialog
    |
    | def me():
    | dir_name = ""
    |
    | getfileDLG = tkCommonDialog.Dialog()
    | getfileDLG.command = "tk_chooseDirectory"
    | getfileDLG.__init__()
    | dir_name = getfileDLG.show( )
    |
    | print dir_name
    |
    |
    ****************************************************************************
    ******
    |
    | The other think is that the dialog does not get focus.
    |
    | Must admit I was little more confortable with the HTML help in Python 2.3
    | however less informative ( which I only installed a week before 2.3.3)
    | The help server in 2.3.3 just produces blank pages (most of the time) and
    | eventualy locks up. I think it has to do with the loopback, I read about
    | somewhere, but I can't be dialed to my ISP all the time.
    |
    |
    | Thanks, Sam.
    |
    vincent wehren, Jan 6, 2004
    #1
    1. Advertising

  2. vincent wehren

    Sam Guest

    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?

    **********************************************************************************
    import os
    import sys
    import tkCommonDialog

    def me():
    dir_name = ""

    getfileDLG = tkCommonDialog.Dialog()
    getfileDLG.command = "tk_chooseDirectory"
    getfileDLG.__init__()
    dir_name = getfileDLG.show( )

    print dir_name

    **********************************************************************************

    The other think is that the dialog does not get focus.

    Must admit I was little more confortable with the HTML help in Python 2.3
    however less informative ( which I only installed a week before 2.3.3)
    The help server in 2.3.3 just produces blank pages (most of the time) and
    eventualy locks up. I think it has to do with the loopback, I read about
    somewhere, but I can't be dialed to my ISP all the time.


    Thanks, Sam.
    Sam, Jan 7, 2004
    #2
    1. Advertising

  3. vincent wehren

    Guest

    (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 <> 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" <> schrieb im Newsbeitrag
    >> news:...
    >> | 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
    >>
    >>
    >>

    >
    , Jan 7, 2004
    #3
  4. vincent wehren

    Sambo Guest

    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" <> schrieb im Newsbeitrag
    > news:...
    > | 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
    >
    >
    >
    Sambo, Jan 7, 2004
    #4
  5. vincent wehren

    Sambo Guest

    Well, I was hopeful but no luck under w2000 and python 2.3.3
    The window is just as obscured as under w95
    Must be p2.3.3, oh well 9Mb of junk, good think I upgraded to UNLIMITED access,
    hehe.

    Ciao.


    wrote:

    > (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!
    Sambo, Jan 7, 2004
    #5
  6. "Sambo" <> schrieb im Newsbeitrag
    news:...
    | Well, I was hopeful but no luck under w2000 and python 2.3.3
    | The window is just as obscured as under w95
    | Must be p2.3.3, oh well 9Mb of junk, good think I upgraded to UNLIMITED
    access,
    | hehe.

    The example should work absolutely fine on 2.3.3 - which is what I am
    running. So there's someting at your end that is causing this. How do you
    invoke the script? Have you tried invoking the script directly from the
    command line?
    Vincent

    |
    | Ciao.
    |
    |
    | wrote:
    |
    | > (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!
    |
    vincent wehren, Jan 7, 2004
    #6
  7. vincent wehren

    Sam Guest

    Hooooly macaroni, spaghetti... worms.
    Someone is to blame, and I intend to find out who! !&R#^&#% Netscape is next or
    could be explorer too, seam to remember starting some applications in the past
    and the explorer window would stay on top.

    Ok I tried running from dos prompt and eventually on a second or third try..
    Because the scripts did not seam to run when I imported them (in GUI),
    I started putting only functions in them and then call the main entry from the
    python prompt.
    I have since tried to recreate the "script not executing" scenario without any
    luck, so it is possible that my script was initializing some var, but when I
    tried to print it interactively,( before I knew I need to preceded it with the
    module name,) I had problems.


    When I finally modified it to include "print me()" and closed everything except
    my 2 explorer windows it popped up on top( and ever since, even with netscape
    running).


    The command line version is indeed finding my init script ( which currently only
    imports "sys" and "os", hmm... I'll have gather up the bits and pieces on the
    subject and re-read.

    I thought there was more funny stuff and differences between PYTHON and PYTHONW
    but I guess it was mostly the OOPsy syndrome.

    Thanks, Sam.


    vincent wehren wrote:

    > "Sambo" <> schrieb im Newsbeitrag
    > news:...
    > | Well, I was hopeful but no luck under w2000 and python 2.3.3
    > | The window is just as obscured as under w95
    > | Must be p2.3.3, oh well 9Mb of junk, good think I upgraded to UNLIMITED
    > access,
    > | hehe.
    >
    > The example should work absolutely fine on 2.3.3 - which is what I am
    > running. So there's someting at your end that is causing this. How do you
    > invoke the script? Have you tried invoking the script directly from the
    > command line?
    > Vincent
    >
    > | > 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!
    > |
    >
    >
    >
    Sam, Jan 7, 2004
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. D. Shane Fowlkes

    Taking the plunge - first .net question

    D. Shane Fowlkes, Nov 6, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    322
    D. Shane Fowlkes
    Nov 6, 2003
  2. Etienne Desautels

    Reading from socket file handle took too long

    Etienne Desautels, Feb 24, 2006, in forum: Python
    Replies:
    1
    Views:
    410
    Ben Sizer
    Feb 27, 2006
  3. Replies:
    0
    Views:
    502
  4. Kevin Schultz

    how do I know how long my function call took?

    Kevin Schultz, Jul 18, 2005, in forum: C Programming
    Replies:
    4
    Views:
    386
  5. Sean McIlroy

    considering taking the plunge

    Sean McIlroy, Sep 15, 2008, in forum: C++
    Replies:
    4
    Views:
    355
Loading...

Share This Page