Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I use Python and PyQt4 to start a default application

I am using Python 3 and PyQt4 (and Kubuntu 12.04).

I often use QtCore.Qprocess.startDetached (QString program, QStringList arguments) to start a program to process a file specified in the arguments.

I want a corresponding manner to start processing the specified file without specifying which program to use. Rather I want to start the default program available, e.g. OpenOffice or LibreOffice or any other program designated as the default word processor for an .odt document file.

Alternatively, is there a way to ask the system which is the default program to use?

/ingemar

like image 356
ingemar Avatar asked Oct 22 '22 11:10

ingemar


1 Answers

QDesktopServices.openUrl(QUrl('file:///home/test/test_document.odt'))

Alternatively, you can use the system commands xdg-open (Linux) and start (Windows).

like image 128
Oleh Prypin Avatar answered Oct 31 '22 19:10

Oleh Prypin