askopenfilename()

Ulli Horlacher framstag at rus.uni-stuttgart.de
Sat Nov 28 07:48:43 EST 2015


Christian Gollwitzer <auriocus at gmx.de> wrote:

> Am 28.11.15 um 11:29 schrieb Ulli Horlacher:
> > One of my Windows test users reports, that the file dialog window of
> > askopenfilename() starts behind the console window and has no focus.
> > On Linux (XFCE) I do not have this problem.
> >
> > I start it with:
> >
> >    Tk().withdraw()
> >    file = askopenfilename(title='select a file',initialdir=HOME)
> >    set_window_focus() # give focus back to console window
> >
> > Can one force askopenfilename() to start in foreground with focus?
> 
> I can't test it right now, but I think it /should/ go into the 
> foreground by itself. 

This is what I think, too :-)
But my test user reports me, it is not so.


> I see two thingd:
> 
> 1) Tk().withdraw()
> 
> - this seems odd to me, because you don't keep a reference to the Tk 
> object around. 

I thought, I need it for Tk initialization.
But true, it is superfluous


> I think that you are curing a lot of symptoms with the focus setting to 
> the console etc.

This is done after the file selection window is closed. This works.


> Many problems would simply go away if you wrote the whole thing as a GUI
> program.

Too much hassle.
The predecessor was a Perl/Tk program and I have had to invest 90% of the 
programming work into the GUI handling. No fun at all.
Now, with fexit in Python, I skipped most of these problems.
The only GUI part is the file selection.


> If I understand correctly, what you want - a program to select files and
> folders to upload to your server 

This is only one of the tasks. The main menu looks:

[s]  send a file or directory
[g]  get a file
[c]  change login data (user, server, auth-ID)
[l]  login with webbrowser
[u]  update fexit
[h]  help
[q]  quit

(with more features to come in the future)

And the CLI:

framstag at juhu:~: ./fexit.py -h
usage: fexit [-C "comment"] [-a container] file(s) recipient[,...]
example: fexit flupp.avi framstag at rus.uni-stuttgart.de
example: fexit -C "more data" -a labdata *.png x1 at flupp.org,x2 at flupp.org

usage: fexit FEX-download-URL
example: fexit http://fex.rus.uni-stuttgart.de/fop/jHn34yp7/flupp.avi


-- 
Ullrich Horlacher              Server und Virtualisierung
Rechenzentrum IZUS/TIK         E-Mail: horlacher at tik.uni-stuttgart.de
Universitaet Stuttgart         Tel:    ++49-711-68565868
Allmandring 30a                Fax:    ++49-711-682357
70550 Stuttgart (Germany)      WWW:    http://www.tik.uni-stuttgart.de/



More information about the Python-list mailing list