On Thu, Oct 31, 2019, 7:27 AM kiteh <kiteh.0...@gmail.com> wrote:

> Hi Tim,
>
> Thanks for the info, nonetheless! Glad to know that the scriptJob command
> gets updated with new args in Maya 2019.
>
> I have this tool written in PyQt Gui (accessed by clicking on the shelf
> button icon), in which it has a checkbox within that allows/ tells user
> whether the "Auto" mode is enabled or not.
> Checked means enabled, unchecked means disabled.
>
> Because this checkbox can only be navigate only when the UI is open (it
> uses an optionVar, eg. `myToolMode`), and so I thought it may be easier if
> I either:
>
>    - Create a right click menu where the sub-menu (aka menuItem) will
>    have a checkbox functionality so that it associates with the state of the
>    optionVar.
>    - Or, change the shelf icon image, eg. bg color of the icon will be
>    colored red to signify that the mode is enabled.
>
> As mentioned, the shelf + its icons are generated by mel code, initially I
> tried the first approach (menuItem with checkbox), unfortunately it fails,
> as it does not works in the manner I had wanted to.
> And so, I tried out the second method, changing of the shelf icon where
> part of the mel code goes as:
> global proc myToolButton(string $parent)
> {
>     string  $parentLayout = `setParent -q`,
>             $shelfButtons[] = `layout -q -childArray $parentLayout`,
>             $autoMode = $shelfButtons[`size $shelfButtons` - 1];
>
>     // Script Job creation
>     scriptJob -parent $autoMode -event "RecentCommandChanged"
> ("myToolIconChange(\"" + $autoMode + "\")");
> }
>
>
> global proc myToolIconChange(string $shelfButton)
> {
>     string  $image = "myToolIconDisabled.png",
>             $autoMode = `optionVar -q "myToolMode"`;
>     int $myMode = 0;
>
>
>     if ($autoMode == 1){
>         $image = ("myToolIconEnabled.png"); // this will have a red bg
> color
>         $myMode = 1;
>
>     }else{
>         $image = ("myToolIconDisabled.png");
>         $myMode = 0;
>     }
>     if(`shelfButton -q -exists $shelfButton`)
>         // Update the button with the image we chose.
>         catchQuiet(`shelfButton -edit -image $image $shelfButton`);
> }
>
>
> By default, the optionVar/ the tool mode is in disabled state in first
> maya session. Currently the issue I had is:
>
>    - I enabled the mode via the popup menu (shelf icon with red bg color)
>    - Launch the tool (the pyqt checkbox is checked, which is correct)
>    - Disabled the mode within the pyqt tool but the shelf icon did not
>    gets updated
>    - Shelf icon only gets updated (to non-red bg) unless I perform other
>    actions within Maya context itself eg. creating a new locator
>
> Could you just set a callback for your shelf buttons
popupMenu postMenuCommand to update the check state from the optionVar?
Then it would be accurate every time you show the menu.


> Apologize for the long list of details.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to python_inside_maya+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/d9d515e0-2c0e-479f-917f-ecb6cc67ff19%40googlegroups.com
> <https://groups.google.com/d/msgid/python_inside_maya/d9d515e0-2c0e-479f-917f-ecb6cc67ff19%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to python_inside_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA0jVmam8SV_6wYOSfsNFMRoSFwrkqEHid-1soVA_MrMPA%40mail.gmail.com.

Reply via email to