<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <div class="moz-cite-prefix">
      <pre>This working for me

layer_tree = iface.layerTreeView()</pre>
      <pre>layer_tree_dock = layer_tree.parent().parent()</pre>
      <pre>toolbar = layer_tree_dock.findChildren(QToolBar)[0]</pre>
      <pre>
</pre>
      <pre>def my_function():</pre>
      <pre>    print("ook")</pre>
      <pre>
my_icon = QIcon("D:\Frequency.svg")</pre>
      <pre>my_tooltip = "Description (text menu or action tooltip)"</pre>
      <pre>my_action = QAction(my_icon, my_tooltip)</pre>
      <pre>my_action.triggered.connect(my_function)</pre>
      <pre>
toolbar.addAction(my_action)</pre>
      <pre>
# toolbar.removeAction(my_action)

Best Regards
</pre>
    </div>
    <div class="moz-cite-prefix"><br>
    </div>
    <div class="moz-cite-prefix">Il 27/04/2023 16:37, Catania, Luke A
      ERDC-RDE-GRL-VA CIV ha scritto:<br>
    </div>
    <blockquote type="cite"
      cite="mid:a81e90d3875f497b9b7a26efd730d39d@erdc.dren.mil">
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <meta name="Generator" content="Microsoft Word 15 (filtered
        medium)">
      <style>@font-face
        {font-family:Helvetica;
        panose-1:2 11 6 4 2 2 2 2 2 4;}@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}@font-face
        {font-family:"Segoe UI Emoji";
        panose-1:2 11 5 2 4 2 4 2 2 3;}@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}pre
        {mso-style-priority:99;
        mso-style-link:"HTML Preformatted Char";
        margin:0in;
        font-size:10.0pt;
        font-family:"Courier New";}span.HTMLPreformattedChar
        {mso-style-name:"HTML Preformatted Char";
        mso-style-priority:99;
        mso-style-link:"HTML Preformatted";
        font-family:Consolas;}span.y2iqfc
        {mso-style-name:y2iqfc;}span.EmailStyle21
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}div.WordSection1
        {page:WordSection1;}</style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
      <div class="WordSection1">
        <p class="MsoNormal">Another user posted this solution to add an
          icon. I tried it, but not getting any additional icon showing
          up in the layer’s panel..<o:p></o:p></p>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p class="MsoNormal" style="line-height:15.0pt"><span
            style="font-size:11.5pt;font-family:Consolas;color:#001080">toolbar</span><span
            style="font-size:11.5pt;font-family:Consolas;color:black"> =
            iface.mainWindow().findChild(QDockWidget,
          </span><span
            style="font-size:11.5pt;font-family:Consolas;color:#A31515">"Layers"</span><span
            style="font-size:11.5pt;font-family:Consolas;color:black">).findChild(QToolBar)<o:p></o:p></span></p>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p class="MsoNormal"><span
            style="font-family:"Arial",sans-serif">Then you
            can just add QAction to this toolbar :</span><o:p></o:p></p>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p class="MsoNormal" style="line-height:15.0pt"><span
            style="font-size:11.5pt;font-family:Consolas;color:#001080">my_wonderful_action</span><span
            style="font-size:11.5pt;font-family:Consolas;color:black"> =
            QAction(QIcon(</span><span
            style="font-size:11.5pt;font-family:Consolas;color:#A31515">"path/to/icon.svg"</span><span
            style="font-size:11.5pt;font-family:Consolas;color:black">),
          </span><span
            style="font-size:11.5pt;font-family:Consolas;color:#A31515">"Description
            (text menu or action tooltip)"</span><span
            style="font-size:11.5pt;font-family:Consolas;color:black">)<o:p></o:p></span></p>
        <p class="MsoNormal" style="line-height:15.0pt"><span
            style="font-size:11.5pt;font-family:Consolas;color:#001080">my_wonderful_action</span><span
            style="font-size:11.5pt;font-family:Consolas;color:black">.triggered.connect(my_awesome_processing_function)<o:p></o:p></span></p>
        <p class="MsoNormal" style="line-height:15.0pt"><span
            style="font-size:11.5pt;font-family:Consolas;color:#001080">toolbar</span><span
            style="font-size:11.5pt;font-family:Consolas;color:black">.addAction(</span><span
            style="font-size:11.5pt;font-family:Consolas;color:#001080">my_wonderful_action</span><span
            style="font-size:11.5pt;font-family:Consolas;color:black">)<o:p></o:p></span></p>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p class="MsoNormal"><o:p> </o:p></p>
        <div>
          <div style="border:none;border-top:solid #E1E1E1
            1.0pt;padding:3.0pt 0in 0in 0in">
            <p class="MsoNormal"><b>From:</b> Giulio Fattori
              <a class="moz-txt-link-rfc2396E" href="mailto:giulio.fattori@tin.it"><giulio.fattori@tin.it></a> <br>
              <b>Sent:</b> Thursday, April 27, 2023 7:09 AM<br>
              <b>To:</b> Nyall Dawson <a class="moz-txt-link-rfc2396E" href="mailto:nyall.dawson@gmail.com"><nyall.dawson@gmail.com></a>;
              Catania, Luke A ERDC-RDE-GRL-VA CIV
              <a class="moz-txt-link-rfc2396E" href="mailto:Luke.A.Catania@erdc.dren.mil"><Luke.A.Catania@erdc.dren.mil></a><br>
              <b>Cc:</b> <a class="moz-txt-link-abbreviated" href="mailto:qgis-developer@lists.osgeo.org">qgis-developer@lists.osgeo.org</a><br>
              <b>Subject:</b> Re: [QGIS-Developer] Customizing Layer
              Panel<o:p></o:p></p>
          </div>
        </div>
        <p class="MsoNormal"><o:p> </o:p></p>
        <div>
          <p class="MsoNormal"><span class="y2iqfc"><span
                style="font-family:"Helvetica",sans-serif"
                lang="EN">Great, what if I want an icon too?</span></span><o:p></o:p></p>
        </div>
        <div>
          <p class="MsoNormal">Thanks in advance for any help<o:p></o:p></p>
        </div>
        <div>
          <p class="MsoNormal"><span class="y2iqfc"><span
                style="font-family:"Helvetica",sans-serif"
                lang="EN">Giulio</span></span><o:p></o:p></p>
        </div>
        <div>
          <p class="MsoNormal"><o:p> </o:p></p>
        </div>
        <div>
          <p class="MsoNormal">Il 27/04/2023 00:06, Nyall Dawson via
            QGIS-Developer ha scritto:<o:p></o:p></p>
        </div>
        <blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
          <div>
            <p class="MsoNormal"><br>
              <br>
              On Thu, 27 Apr 2023 at 07:42, Catania, Luke A
              ERDC-RDE-GRL-VA CIV via QGIS-Developer <<a
                href="mailto:qgis-developer@lists.osgeo.org"
                moz-do-not-send="true" class="moz-txt-link-freetext">qgis-developer@lists.osgeo.org</a>>
              wrote:<br>
              ><br>
              > But I am looking to access the dock widget and add
              two icons in its row of icons or maybe a menu.<br>
              <br>
              It's not available via the stable API, but let's not let
              that stop us! <span style="font-family:"Segoe UI
                Emoji",sans-serif">😆</span><br>
              <br>
              layer_tree = iface.layerTreeView()<br>
              layer_tree_dock = layer_tree.parent().parent()<br>
              toolbar = layer_tree_dock.findChildren(QToolBar)[0]<br>
              <br>
              my_action = QAction('something')<br>
              toolbar.addAction(my_action) <o:p></o:p></p>
            <div>
              <p class="MsoNormal"><o:p> </o:p></p>
            </div>
            <div>
              <p class="MsoNormal">Nyall<o:p></o:p></p>
            </div>
            <div>
              <p class="MsoNormal"><o:p> </o:p></p>
            </div>
            <div>
              <p class="MsoNormal"><br>
                ><br>
                >  <br>
                ><br>
                > Thanks in advance for any help,<br>
                ><br>
                > Luke<br>
                ><br>
                > _______________________________________________<br>
                > QGIS-Developer mailing list<br>
                > <a href="mailto:QGIS-Developer@lists.osgeo.org"
                  moz-do-not-send="true" class="moz-txt-link-freetext">QGIS-Developer@lists.osgeo.org</a><br>
                > List info: <a
href="Blockedhttps://lists.osgeo.org/mailman/listinfo/qgis-developerBlocked"
                  moz-do-not-send="true">
Blockedhttps://lists.osgeo.org/mailman/listinfo/qgis-developerBlocked</a><br>
                > Unsubscribe: <a
href="Blockedhttps://lists.osgeo.org/mailman/listinfo/qgis-developerBlocked"
                  moz-do-not-send="true">
Blockedhttps://lists.osgeo.org/mailman/listinfo/qgis-developerBlocked</a><o:p></o:p></p>
            </div>
          </div>
          <p class="MsoNormal"><br>
            <br>
            <o:p></o:p></p>
          <pre>_______________________________________________<o:p></o:p></pre>
          <pre>QGIS-Developer mailing list<o:p></o:p></pre>
          <pre><a href="mailto:QGIS-Developer@lists.osgeo.org" moz-do-not-send="true" class="moz-txt-link-freetext">QGIS-Developer@lists.osgeo.org</a><o:p></o:p></pre>
          <pre>List info: <a href="Blockedhttps://lists.osgeo.org/mailman/listinfo/qgis-developerBlocked" moz-do-not-send="true">Blockedhttps://lists.osgeo.org/mailman/listinfo/qgis-developerBlocked</a><o:p></o:p></pre>
          <pre>Unsubscribe: <a href="Blockedhttps://lists.osgeo.org/mailman/listinfo/qgis-developerBlocked" moz-do-not-send="true">Blockedhttps://lists.osgeo.org/mailman/listinfo/qgis-developerBlocked</a><o:p></o:p></pre>
        </blockquote>
        <p><o:p> </o:p></p>
      </div>
    </blockquote>
    <p><br>
    </p>
  </body>
</html>