<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <font face="Ubuntu">Hi Luke,<br>
      <br>
      As you can see on the printed text, objects are QWigetAction, not
      QAction.<br>
      This is because you get each category of the tool bar, where then
      each one contains one or more digitizing QActions.<br>
      <img src="cid:part1.7ZJOl7ea.gT0wDkA0@oslandia.com" alt=""><br>
      <br>
      Here is a snippet that can help you explore the tool bar:<br>
      <br>
      <br>
      sdtb = iface.shapeDigitizeToolBar()<br>
      for i, action_widget_item in enumerate(sdtb.actions()):<br>
          print(f"{i}: {action_widget_item.defaultWidget().text()}")<br>
          for j, action_item in
      enumerate(action_widget_item.defaultWidget().menu().actions()):<br>
              print (f"\t{j}: {action_item.data()}")  # id like<br>
              print (f"\t\ttranslated text: {action_item.text()}")<br>
      <br>
      <br>
      Regards,<br>
    </font>
    <pre class="moz-signature" cols="72">Jacky Volpes

Ingénieur SIG - Oslandia</pre>
    <div class="moz-cite-prefix"><br>
      Le 27/02/2024 à 04:10, Catania, Luke A ERDC-RDE-GRL-VA CIV via
      QGIS-Developer a écrit :<br>
    </div>
    <blockquote type="cite"
      cite="mid:95416fc0fe394116ba65c26d7b1ef517@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:"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;}p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri",sans-serif;
        color:windowtext;}.MsoChpDefault
        {mso-style-type:export-only;
        mso-ligatures:none;}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">Trying to get access to the button menus in
          shapeDigitizeToolBar.<o:p></o:p></p>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p class="MsoNormal">from qgis.utils import iface<o:p></o:p></p>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p class="MsoNormal">from PyQt5.QtWidgets import QWidgetAction<o:p></o:p></p>
        <p class="MsoNormal">sdtb = iface.shapeDigitizeToolBar()<o:p></o:p></p>
        <p class="MsoNormal">i=0<o:p></o:p></p>
        <p class="MsoNormal">for action_item in sdtb.actions():<o:p></o:p></p>
        <p class="MsoNormal">    i=i+1<o:p></o:p></p>
        <p class="MsoNormal">    print (f"{i}: {action_item}")<o:p></o:p></p>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p class="MsoNormal">This prints:<o:p></o:p></p>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p class="MsoNormal">1: <PyQt5.QtWidgets.QWidgetAction object
          at 0x00000242801E98B0><o:p></o:p></p>
        <p class="MsoNormal">2: <PyQt5.QtWidgets.QWidgetAction object
          at 0x00000242F9E43F70><o:p></o:p></p>
        <p class="MsoNormal">3: <PyQt5.QtWidgets.QWidgetAction object
          at 0x00000242F9E590D0><o:p></o:p></p>
        <p class="MsoNormal">4: <PyQt5.QtWidgets.QWidgetAction object
          at 0x00000242F9E9E1F0><o:p></o:p></p>
        <p class="MsoNormal">5: <PyQt5.QtWidgets.QWidgetAction object
          at 0x00000242F9E274C0><o:p></o:p></p>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p class="MsoNormal">I want to access each button and the menus
          of the button so I can disable certain tools.  I need to get
          the text associated with the tools so I can key on that.<o:p></o:p></p>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p class="MsoNormal">I can’t figure out how to get to them from
          QWidgetAction. I called all the methods on QAction that
          returns a string: data, iconText, statusTip, whatsThis and
          they all return empty strings.  So how are these menus
          labeled.<o:p></o:p></p>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p class="MsoNormal">Thanks,<o:p></o:p></p>
        <p class="MsoNormal">Luke<o:p></o:p></p>
      </div>
      <br>
      <fieldset class="moz-mime-attachment-header"></fieldset>
      <pre class="moz-quote-pre" wrap="">_______________________________________________
QGIS-Developer mailing list
<a class="moz-txt-link-abbreviated" href="mailto:QGIS-Developer@lists.osgeo.org">QGIS-Developer@lists.osgeo.org</a>
List info: <a class="moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/qgis-developer">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a>
Unsubscribe: <a class="moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/qgis-developer">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>