<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<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 Definitions */
@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;}
/* Style Definitions */
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;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
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]-->
</head>
<body lang="EN-US" link="blue" vlink="purple" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal">So this works but if the action I want to disable  happens to be the default action of the button it disables the entire button.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Also trying to capture what action the user selects and I tried<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">shape_digitize_tool_bar = iface.shapeDigitizeToolBar()<o:p></o:p></p>
<p class="MsoNormal">shape_digitize_tool_bar.actionTriggered[QAction].connect(self.shape_digitize_tool_bar_clicked)<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">but is never fired when I click on any of the buttons or select the menus<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 <jacky.volpes@oslandia.com> <br>
<b>Sent:</b> Wednesday, March 6, 2024 4:12 AM<br>
<b>To:</b> Catania, Luke A ERDC-RDE-GRL-VA CIV <Luke.A.Catania@erdc.dren.mil>; qgis-developer@lists.osgeo.org<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">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 width="351" height="152" style="width:3.6583in;height:1.5833in" id="_x0000_i1026" src="cid:image001.png@01DA773B.F4AAC8E0"><br>
<br>
<br>
<o:p></o:p></p>
<pre><o:p> </o:p></pre>
<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>
<br>
<br>
Le 05/03/2024 à 19:32, Catania, Luke A ERDC-RDE-GRL-VA CIV a écrit :<o:p></o:p></p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal">When I use setDisabled on either  <span style="font-family:Ubuntu">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 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 href="mailto:Luke.A.Catania@erdc.dren.mil">
<Luke.A.Catania@erdc.dren.mil></a>; <a 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">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 border="0" width="469" height="167" style="width:4.8833in;height:1.7416in" id="Picture_x0020_1" src="cid:image002.png@01DA773B.F4AAC8E0"><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>
<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>
<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">QGIS-Developer@lists.osgeo.org</a><o:p></o:p></pre>
<pre>List info: <a href="Blockedhttps://lists.osgeo.org/mailman/listinfo/qgis-developerBlocked">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">Blockedhttps://lists.osgeo.org/mailman/listinfo/qgis-developerBlocked</a><o:p></o:p></pre>
</blockquote>
<p class="MsoNormal"> <o:p></o:p></p>
</blockquote>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</body>
</html>