2

I typically use pdb for debugging. However, when I follow the docs for debugging with pdb, I get the error:

input(): lost sys.stdin

I'm developing my plugin straight out of the load directory:

%APPDATA%\QGIS\QGIS3\profiles\default\python\plugins\my_tool

The minimal files are:

metadata.txt

[general]
name=My Tool
[email protected]
author=dood
qgisMinimumVersion=3.10
description=My Tool
about=Software for stuff
version=version 0.1
repository=http://www.itopen.it/repo

experimental=True

init.py

def classFactory(iface):
    from .my_tool import MyTool
    return MyTool(iface)

my_tool.py

import qgis
from qgis.PyQt import QtWidgets, QtGui, QtCore


class MyTool:

    def __init__(self, iface):
        self.iface = iface

    def initGui(self):
        self.action = QtWidgets.QAction("My Tool", self.iface.mainWindow())
        self.action.triggered.connect(self.run)
        self.iface.addToolBarIcon(self.action)

    def unload(self):
        self.iface.removeToolBarIcon(self.action)

    def run(self):
        print("Running my tool")

        import pdb
        from qgis.PyQt.QtCore import pyqtRemoveInputHook
        pyqtRemoveInputHook()
        pdb.set_trace()

I have First Aid installed. It works, but I can't type more than one line at a time. Commands like code stepping and 'interact' don't seem to exist.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.