[PIPython] Aprire un file con applicazione di default
carlo C8E miron
carlo.miron
Ven 19 Nov 2004 15:16:44 CET
> Salve,
> sto creando un'applicazione con wxPython ed ho questo
problema: l'utente
> deve selezionare un file dal suo pc e poi aprirlo con
l'applicazione di
> default (esempio un .pdf con acrobat, un .doc con word).
Come posso
> fare?
>
> Gianluca
su windoze (che assumo utilizzi dato che citi word):
import os
os.startfile(path)
Start a file with its associated application. This acts like
double-clicking the file in Windows Explorer, or giving the
file name as an argument to the start command from the
interactive command shell: the file is opened with whatever
application (if any) its extension is associated.
startfile() returns as soon as the associated application is
launched. There is no option to wait for the application to
close, and no way to retrieve the application's exit status.
The path parameter is relative to the current directory. If
you want to use an absolute path, make sure the first
character is not a slash ("/"); the underlying Win32
ShellExecute() function doesn't work if it is. Use the
os.path.normpath() function to ensure that the path is
properly encoded for Win32. Availability: Windows. New in
version 2.0.
(c)
More information about the Python
mailing list