For Programmers: Free Programming Magazines  


Home > Archive > Tcl > January 2008 > Display returned path in entry widget?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Display returned path in entry widget?
Niv

2008-01-23, 4:36 am

I'm using tk_chooseDirectory to get a directory path into a variable,
but I would like to then display this path somehow. Do I use a text
entry or label widget, and how do I fill the entry widget when te proc
that returns the path completes?

Regards, Kev P.
Niv

2008-01-23, 4:36 am

On 23 Jan, 09:01, Niv <kev.pars...@mbda.co.uk> wrote:
> I'm using tk_chooseDirectory to get a directory path into a variable,
> but I would like to then display this path somehow. =A0Do I use a text
> entry or label widget, and how do I fill the entry widget when te proc
> that returns the path completes?
>
> Regards, Kev P.


Sussed it.
It seems I just use the same variable for the entry widget as for the
tk_chooseDirectory returns.
How easy was that.
billposer@alum.mit.edu

2008-01-25, 7:26 pm

One reason you might NOT want to do it this way is to avoid displaying
long paths when they aren't necessary, i.e. when the file you choose
is in the current directory. Before inserting the path into a label or
entry, I process it with MinimizeFileName, which removes the leading
part of the path if the file is in the current directory. See:
http://wiki.tcl.tk/15168.
Typical usage is something like this:

proc SelectInputFile {} {
set InputFile [tk_getOpenFile];
if {$InputFile == ""} {
ShowMessage [_ "File selection aborted."]
} else {
$::INPUT.ent delete 0 end
$::INPUT.ent insert 0 [MinimizeFileName $InputFile]
}
}
Niv

2008-01-28, 4:57 am

On 25 Jan, 18:48, billpo...@alum.mit.edu wrote:
> One reason you might NOT want to do it this way is to avoid displaying
> long paths when they aren't necessary, i.e. when the file you choose
> is in the current directory. Before inserting the path into a label or
> entry, I process it with MinimizeFileName, which removes the leading
> part of the path if the file is in the current directory. See:http://wiki.=

tcl.tk/15168.
> Typical usage is something like this:
>
> proc SelectInputFile {} {
> =A0 =A0 set InputFile [tk_getOpenFile];
> =A0 =A0 if {$InputFile =3D=3D ""} {
> =A0 =A0 =A0 =A0 ShowMessage [_ "File selection aborted."]
> =A0 =A0 } else {
> =A0 =A0 =A0 =A0 $::INPUT.ent delete 0 end
> =A0 =A0 =A0 =A0 $::INPUT.ent insert 0 [MinimizeFileName $InputFile]
> =A0 =A0 }
>
>
> }- Hide quoted text -
>
> - Show quoted text -


OK, thanks for that.
What I'm doing is creating a (complex(ish)) directory structure for a
project, so all projects have the same structure pattern, so there is
no file as such, just a top level dir under which the new project
structure will be built.

Regards, Kev Parsons.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com