1

Please see link : http://www.qgistutorials.com/en/docs/building_a_python_plugin.html

I am using the same process for uploading a CSV file in a folder but it gives me an error.

I am using this code:

def select_output_file(self):

    filename = QFileDialog.getSaveFileName(self.dlg, "Select output file ","", '*.txt')
    self.dlg.lineEdit.setText(filename)

It gives the error:

Couldn't load plugin Importtool due to an error when calling its classFactory() method

Traceback (most recent call last):

File "C:/PROGRA~1/QGISWI~1/apps/qgis/./python\qgis\utils.py", line 219, in startPlugin plugins[packageName] = package.classFactory(iface)

File "C:/Users/n/.qgis2/python/plugins\Importtool__init__.py", line 34, in classFactory from .Import_tool import Importtool File "C:/PROGRA~1/QGISWI~1/apps/qgis/./python\qgis\utils.py", line 478, in _import

mod = _builtin_import(name, globals, locals, fromlist, level)

File "C:/Users/n/.qgis2/python/plugins\Importtool\Import_tool.py", line 71 self.dlg.lineEdit.clear()

IndentationError: unexpected indent

Please see below image. enter image description here

  • The error relates to your indentation, try fixing that and see how it goes? I've edited your question and correctly fixed the indentation. – Joseph Jul 21 '15 at 13:22
  • Hi Joseph , thanks for your reply . I didn't get you . what do you mean by indentation eroor ? I am not able to rectify the error . Please tell me in detail . – Ashwin Bhayal Jul 22 '15 at 6:36
  • 2
    The indentation is the "space" at the beginning of a line code. If you compare the code just above yours, you see that the line just after the "def unload" is indented, with a tab. Try this with your code. – Vale Jul 22 '15 at 9:30
  • Hi vale, I have removed "space" at the beginning of a line code. But still its give same error. – Ashwin Bhayal Jul 22 '15 at 10:12
  • 1
    You need to add spaces at the beginning of your line codes below the def line. Check your picture above: the code you wrote hasn't "space" at the beginning of the lines below the "def select_output". Compare with the other def statements in the code – Vale Jul 22 '15 at 10:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.