I created a file mymime.xml

<?xml version='1.0' encoding='utf-8'?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
    <mime-type type="text/myapp">
        <comment>my format</comment>
        <glob pattern="*.myformat"/>

and a file myapp.desktop

[Desktop Entry]
GenericName=My Generic Name 
Comment=a comment

Now when I right click on a file that has myformat ending, it suggests opening with MyApp, which is the behavior I was looking! But on the python3 code (I am using PyQt5), how do I take the loading argument when there is a file loaded like this? (right click open or double click on a file.myformat)

  • Wtf is happening with this site? Second question I asked placed on hold with little effort from a great number of people who are not interested in the least to help or offer some explanation. I have no idea how things work in any other distro or operating system, I have no idea how to set file types or whatever, this is made from observation of Ubuntu from having used it a long time. If you have a smart-ass comment, please do and help me to understand to which extent informing mime-type works. I just feel it won't work the same on Windows.
    – eri0o
    Jun 16, 2016 at 9:18
  • We closed this because it wasn't about Ubuntu enough - it was a programming language.
    – Tim
    Jun 17, 2016 at 22:54
  • @Tim you know you kind of have the power to move questions instead of closing. I don't have this power.
    – eri0o
    Jun 17, 2016 at 23:03
  • No I don't. Only moderators can migrate to other sites on the network.
    – Tim
    Jun 17, 2016 at 23:04
  • @Tim I also can't delete my question.
    – eri0o
    Jun 17, 2016 at 23:23

1 Answer 1


Ok, I solved this with the following code:

class MainWindow(QMainWindow):
    def __init__(self, filelist, **kwargs):


    def openFileAtStart(self, filelist):
        matching = [s for s in filelist if ".myformat" in s]
        if len(matching) > 0:

if __name__ == "__main__":
    from sys import argv, exit
    from PyQt5.QtWidgets import QApplication
    a = QApplication(argv)

Basically, at opening, QApplication needs to read the argv arguments, and removes anything related to Qt. Than I pass the remaining arguments to my application ("MainWindow"), which will handle the list checking for items that match my format and will throw this list to my function that handles opening files.

Not the answer you're looking for? Browse other questions tagged .