how to open a file in some application using Tkinter i am using TKINTER to create GUI application i want to know how to open a word document in open office or any other applicatio

Paul Boddie paul at boddie.org.uk
Wed Jan 9 05:40:16 EST 2008


On 9 Jan, 09:24, Fredrik Lundh <fred... at pythonware.com> wrote:
>

[Opening files in applications]

> on windows, you can use the "os.startfile" function:
>
>       import os
>       os.startfile("mydocument.doc")
>
> (this is the same as double-clicking on a document in the file explorer)
>
> on other platforms, use os.system() and specify what application to run:
>
>       import os
>       os.system("someapp mydocument.doc")

Or try the desktop module which uses os.startfile on Windows, but
employs mechanisms appropriate for other desktop environments
elsewhere:

  http://www.python.org/pypi/desktop

This code should do the trick:

  import desktop
  desktop.open("mydocument.doc")

This assumes that your desktop environment knows how to handle .doc
files, of course.

Paul



More information about the Python-list mailing list