<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    Hi Luke,<br>
    <br>
    It works with setDisabled on action_item.<br>
    Be careful not to call setDisabled on every action of a category,
    then yes, it disables the entire icon.<br>
    <br>
    Updated snippet for example:<br>
    <br>
    actions_list = []<br>
    sdtb = iface.shapeDigitizeToolBar()<br>
    for i, action_widget_item in enumerate(sdtb.actions()):<br>
        if action_widget_item.defaultWidget().menu() is None:<br>
           
    actions_list.append(action_widget_item.defaultWidget().defaultAction())<br>
            continue<br>
        actions_list +=
    action_widget_item.defaultWidget().menu().actions()<br>
    <br>
    actions_ids = ['rectangle-from-extent', 'circle-from-3-points']  #
    actions ids to disable<br>
    [a.setDisabled(True) for a in actions_list if a.data() in
    actions_ids]  # disable the actions<br>
    <br>
    <img src="cid:part1.pFJ0AmYV.KezpMP2c@oslandia.com" alt=""><br>
    <br>
    <pre class="moz-signature" cols="72">
Jacky Volpes

Ingénieur SIG - Oslandia</pre>
    <div class="moz-cite-prefix"><br>
      <br>
      <br>
      Le 05/03/2024 à 19:32, Catania, Luke A ERDC-RDE-GRL-VA CIV a
      écrit :<br>
    </div>
    <blockquote type="cite"
      cite="mid:37135e310a0d4665b198814ee787b55c@erdc.dren.mil">
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <meta name="Generator"
        content="Microsoft Word 15 (filtered medium)">
      <!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]-->
      <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;}@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}@font-face
        {font-family:Ubuntu;
        panose-1:0 0 0 0 0 0 0 0 0 0;}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;
        margin-bottom:.0001pt;
        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.EmailStyle21
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;
        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">When I use setDisabled on either  <span
            style="font-family:"Ubuntu",serif">action_widget_item.defaultWidget
            or action_item it sets the disables the entire icon as
            opposed to the specific action item found.  Maybe I am
            missing something.  Like I don’t want the user to be able to
            draw an Ellipse from Foci so I disable that, but it disables
            the entire icon of menus for drawing Elipses.</span><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> Jacky Volpes
              <a class="moz-txt-link-rfc2396E" href="mailto:jacky.volpes@oslandia.com"><jacky.volpes@oslandia.com></a> <br>
              <b>Sent:</b> Tuesday, February 27, 2024 5:29 AM<br>
              <b>To:</b> 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>;
              <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] Access to
              shapeDigitizeToolBar menu's text<o:p></o:p></p>
          </div>
        </div>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p class="MsoNormal"><span
            style="font-family:"Ubuntu",serif">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 style="width:4.8833in;height:1.7416in"
              id="Picture_x0020_1"
              src="cid:part2.7EO4emCt.FOguMqJT@oslandia.com" class=""
              width="469" height="167"><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>
            <br>
          </span><o:p></o:p></p>
        <pre>Jacky Volpes<o:p></o:p></pre>
        <pre><o:p> </o:p></pre>
        <pre>Ingénieur SIG - Oslandia<o:p></o:p></pre>
        <div>
          <p class="MsoNormal"><br>
            Le 27/02/2024 à 04:10, Catania, Luke A ERDC-RDE-GRL-VA CIV
            via QGIS-Developer a écrit :<o:p></o:p></p>
        </div>
        <blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
          <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>
          <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 class="MsoNormal"><o:p> </o:p></p>
      </div>
    </blockquote>
    <br>
  </body>
</html>