python - Open multiple files from file managers -
i've built (linux) gui application can launched terminal , accepts undefined number of files arguments. app reads sys.argv , lists name of these files in qlistwidget.
the code like:
import sys pyqt4.qtgui import qapplication, qmainwindow, qcoreapplication class mainwindow(qmainwindow): def __init__(self, parent=none): super(mainwindow, self).__init__(parent) # parse command line arguments in qcoreapplication.argv()[1:]: ... def main(): app = qapplication(sys.argv) ...
what want able select multiple files file manager , open them app through "open with..." option provided file managers. how can achieved?
with current code, when try 1 of selected files shown on qlistwidget.
edit:
it seems depends file manager. tried few file managers and...
pcmanfm: opens 1 of selected files.
spacefm: works properly!
dolphin: opens each file different instance of program. if select 3 files open app 3 times, 1 each file.
nautilus: didn't manage open files it. program not listed in suggested applications , didn't find way it.
there's not enough information give definite answer, but...
first, have checked print sys.argv
@ top of code looks expecting?
if so, work if change line...
for in qcoreapplication.argv()[1:]:
...to...
for in sys.argv[1:]:
for debugging purposes, might include line...
assert qcoreapplication.argv()[1:] == sys.argv[1:]
...just before start for-loop.
Comments
Post a Comment