Need some guidance to make a colour sampler plugin

Here’s an excerpt of my plugin’s code to get the brush tool button.

from PyQt5.QtWidgets import QDockWidget, QToolButton

def loadTool(self):
        toolBox = Application.activeWindow().qwindow().findChild(QDockWidget, 'ToolBox')
        self.brushTool = toolBox.findChild(QToolButton, 'KritaShape/KisToolBrush')

The buttons are QToolButton class so you can use isChecked() or pressed() etc depending on your needs.

To find the names of the tool button objects for use with toolBox.findChild(), you can paste this onto the scripter and run it.

from PyQt5.QtWidgets import QDockWidget, QToolButton

toolBox = Application.activeWindow().qwindow().findChild(QDockWidget, 'ToolBox')
buttons = toolBox.findChildren(QToolButton)
for button in buttons:
  print(button.objectName())

I forgotten which plugin I learned this from, may be Buli Brush Switch? But you can always research the available plugins to see how others implement a similar function.