Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

This might sound like a silly question.

Is there a way that from running a custom plugin made for QGIS that a Python Shell can appear along when the plugin is run, like a debug screen. I'm asking this to know if there is a way to see print commands through a Python Script while programming a plugin for QGIS.

share|improve this question
    
Other than a tag of pyqgis this question seems to have no connection to GIS. Would you be able to re-phrase it to say why you think it is a GIS question rather than one more suited to StackOverflow, please? –  PolyGeo Apr 18 '13 at 0:34
    
I edited, how about now? –  NothingToSay Apr 18 '13 at 1:00
1  
Looks much better but I also turned your title into a question and added some extra tags to help attract the right audience. –  PolyGeo Apr 18 '13 at 2:18
add comment

1 Answer 1

You send log messages to the QGIS log window using:

QgsMessageLog.logMessage(message, tag, level)

Tag is the title of the tab that will be displayed in the QGIS log window. Level is the message level (defaults to 0).

For example:

QgsMessageLog.logMessage('My message', 'MyPlugin')

See the QGIS API documentation for QgsMessageLog for details.

The log window can be made visible from the View->Panel->Log Messages menu.

The other way is to create a class that captures stdout and directs it to a log window within your plugin (the Script Runner plugin does this). Output from all print statements will be displayed in your log window, although this method is much more involved if you just want to display a few messages during development. You have to be careful doing this, as all print statements from other plugins will be sent to your plugin unless you capture and restore stdout as needed.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.