1

I would like to open a PDF document via a button. I don't seem to find what I need. When the button is clicked, it will open the document based on the path provided (i.e. "c:\test\abc.pdf").

Is there a main command that would open any document type as long as you have the full path (i.e. "c:\test\abc.jpg", "c:\test\abc.txt", etc...)?

Tim Gerlach
  • 3,390
  • 3
  • 20
  • 39
FNW
  • 11
  • 2

1 Answers1

1

Assuming you're running on Windows, you could just run system commands directly to open the files. If you were to directly "run" the file, the associated process will open it.

import os
os.system(r'c:\test\abc.jpg')

This will however block until the process is closed, but you could call the start process to open the file for you.

os.system(r'start c:\test\abc.jpg')

On the other hand, this is IronPython and you have direct access to the .Net framework. You could use the System.Diagnostics.Process class to do the same in a relatively safer manner.

from System.Diagnostics import Process
Process.Start(r'start c:\test\abc.jpg')
Jeff Mercado
  • 129,526
  • 32
  • 251
  • 272