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

V

vincent wehren

| 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.
|
 
S

Sam

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.
 
E

engsolnom

(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
 
S

Sambo

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.
 
S

Sambo

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.
 
V

vincent wehren

| 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.
|
|
| (e-mail address removed) 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!
|
 
S

Sam

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.
 

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

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top