Button Feedback color python in maya?Calling an external command in PythonWhat are metaclasses in Python?Finding the index of an item given a list containing it in PythonWhat is the difference between Python's list methods append and extend?How can I safely create a nested directory?How to print colored text in terminal in Python?Does Python have a ternary conditional operator?How to get the current time in PythonHow can I make a time delay in Python?Does Python have a string 'contains' substring method?

How come I was asked by a CBP officer why I was in the US?

How can I repair scratches on a painted French door?

Does anycast addressing add additional latency in any way?

What would Earth look like at night in medieval times?

Impossible darts scores

Alphabet completion rate

What reason would an alien civilization have for building a Dyson Sphere (or Swarm) if cheap Nuclear fusion is available?

Gare du Nord to Gare de Lyon transfer time for a family

What is this particular type of chord progression, common in classical music, called?

Why is Madam Hooch not a professor?

What happens when your group is victim of a surprise attack but you can't be surprised?

Why is C++ initial allocation so much larger than C's?

How should I behave to assure my friends that I am not after their money?

Find smallest index that is identical to the value in an array

As an Operations Research professional, how is your time divided when working on an optimization project?

How can Charles Proxy change settings without admin rights after first time?

Does ultrasonic bath cleaning damage laboratory volumetric glassware calibration?

Can a US President have someone sent to prison?

Ending: accusative or not?

Swapping rooks in a 4x4 board

Does Marvel have an equivalent of the Green Lantern?

Would a two-seat light aircaft with a landing speed of 20 knots and a top speed of 180 knots be technically possible?

Can ADFS connect to other SSO services?

How to append a matrix element by element?



Button Feedback color python in maya?


Calling an external command in PythonWhat are metaclasses in Python?Finding the index of an item given a list containing it in PythonWhat is the difference between Python's list methods append and extend?How can I safely create a nested directory?How to print colored text in terminal in Python?Does Python have a ternary conditional operator?How to get the current time in PythonHow can I make a time delay in Python?Does Python have a string 'contains' substring method?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I'm a beginner to python. I'm creating a UI that select objects in my scene.
I want the button to change color when it's clicked from default gray to white and remain white and back to gray when deselected.
Kindly make it simple for me to understand,Thanks!
The button code:



import maya.cmds as cmds
def MyWindow():
#delete existing window
if cmds.window("GuiWindow", exists = True):
cmds.deleteUI("GuiWindow")
#create window
window = cmds.window("GuiWindow", title = "Object Selecter",
w = 400, h = 600, sizeable = False, mxb = False)
column = cmds.columnLayout(w = 400, h = 600)
form = cmds.formLayout(w = 400, h = 600)
#background image
BGimage = cmds.internalVar(upd = True)+"icons/picker_bg01.jpg"
cmds.image(w = 400, h = 600, image = BGimage)
#create button
object1 = cmds.button(label = "", w = 100, h = 50,
bgc = [0.5,0.5,0.5],command=lambda x: cmds.select("object1"))
# More buttons to be created
cmds.formLayout(form, e = True,af = (object1,"top",100))
cmds.formLayout(form, e = True,af = (object1,"left",150))
MyWindow()

cmds.showWindow(window)









share|improve this question






























    0















    I'm a beginner to python. I'm creating a UI that select objects in my scene.
    I want the button to change color when it's clicked from default gray to white and remain white and back to gray when deselected.
    Kindly make it simple for me to understand,Thanks!
    The button code:



    import maya.cmds as cmds
    def MyWindow():
    #delete existing window
    if cmds.window("GuiWindow", exists = True):
    cmds.deleteUI("GuiWindow")
    #create window
    window = cmds.window("GuiWindow", title = "Object Selecter",
    w = 400, h = 600, sizeable = False, mxb = False)
    column = cmds.columnLayout(w = 400, h = 600)
    form = cmds.formLayout(w = 400, h = 600)
    #background image
    BGimage = cmds.internalVar(upd = True)+"icons/picker_bg01.jpg"
    cmds.image(w = 400, h = 600, image = BGimage)
    #create button
    object1 = cmds.button(label = "", w = 100, h = 50,
    bgc = [0.5,0.5,0.5],command=lambda x: cmds.select("object1"))
    # More buttons to be created
    cmds.formLayout(form, e = True,af = (object1,"top",100))
    cmds.formLayout(form, e = True,af = (object1,"left",150))
    MyWindow()

    cmds.showWindow(window)









    share|improve this question


























      0












      0








      0








      I'm a beginner to python. I'm creating a UI that select objects in my scene.
      I want the button to change color when it's clicked from default gray to white and remain white and back to gray when deselected.
      Kindly make it simple for me to understand,Thanks!
      The button code:



      import maya.cmds as cmds
      def MyWindow():
      #delete existing window
      if cmds.window("GuiWindow", exists = True):
      cmds.deleteUI("GuiWindow")
      #create window
      window = cmds.window("GuiWindow", title = "Object Selecter",
      w = 400, h = 600, sizeable = False, mxb = False)
      column = cmds.columnLayout(w = 400, h = 600)
      form = cmds.formLayout(w = 400, h = 600)
      #background image
      BGimage = cmds.internalVar(upd = True)+"icons/picker_bg01.jpg"
      cmds.image(w = 400, h = 600, image = BGimage)
      #create button
      object1 = cmds.button(label = "", w = 100, h = 50,
      bgc = [0.5,0.5,0.5],command=lambda x: cmds.select("object1"))
      # More buttons to be created
      cmds.formLayout(form, e = True,af = (object1,"top",100))
      cmds.formLayout(form, e = True,af = (object1,"left",150))
      MyWindow()

      cmds.showWindow(window)









      share|improve this question
















      I'm a beginner to python. I'm creating a UI that select objects in my scene.
      I want the button to change color when it's clicked from default gray to white and remain white and back to gray when deselected.
      Kindly make it simple for me to understand,Thanks!
      The button code:



      import maya.cmds as cmds
      def MyWindow():
      #delete existing window
      if cmds.window("GuiWindow", exists = True):
      cmds.deleteUI("GuiWindow")
      #create window
      window = cmds.window("GuiWindow", title = "Object Selecter",
      w = 400, h = 600, sizeable = False, mxb = False)
      column = cmds.columnLayout(w = 400, h = 600)
      form = cmds.formLayout(w = 400, h = 600)
      #background image
      BGimage = cmds.internalVar(upd = True)+"icons/picker_bg01.jpg"
      cmds.image(w = 400, h = 600, image = BGimage)
      #create button
      object1 = cmds.button(label = "", w = 100, h = 50,
      bgc = [0.5,0.5,0.5],command=lambda x: cmds.select("object1"))
      # More buttons to be created
      cmds.formLayout(form, e = True,af = (object1,"top",100))
      cmds.formLayout(form, e = True,af = (object1,"left",150))
      MyWindow()

      cmds.showWindow(window)






      python maya






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 26 at 6:28







      pro nerd

















      asked Mar 25 at 10:55









      pro nerdpro nerd

      32 bronze badges




      32 bronze badges






















          1 Answer
          1






          active

          oldest

          votes


















          0














          You can always edit your UI elements by using the command with the argument edit set to true. e.g.



          button = cmds.button(bgc=[.5, .5, .5])
          cmds.button(button, edit=True, bgc=[1,1,1])


          In your case, you can create a button command and switch the color there. To make it simpler you can even get the current value with the query argument set to true.



          currentColor = cmds.button(button, query=True, bgc=True)


          This way you can check the current color and switch if needed to the other one.






          share|improve this answer























          • Thanks haggi krey for your answer,Just awesome. Okay so buttons will used to select objects and the idea is when a button click (object is selected) the button color should switch to white automatically to indicate that object is selected and when the object is deselected the button should switch back to default color to indicate that objecting is no longer selected. More like a button color feedback. How do I achieve this? Thanks again!

            – pro nerd
            Mar 25 at 14:01






          • 1





            you should put a cmds.scriptJob while your ui is running to change the color of the button if a certain element is selected. Do you have some code to show ?

            – DrWeeny
            Mar 25 at 15:37












          • Hello DrWeeny, here is the code so far. Kindly help with the scriptjob as simple as possible and you can attach the scriptjob to the code so I know how it how it all come together that will be a big help.Thanks

            – pro nerd
            Mar 26 at 6:01











          • ill try to do this tomorrow ! I dont have maya at home

            – DrWeeny
            Mar 26 at 12:11













          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55336194%2fbutton-feedback-color-python-in-maya%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          You can always edit your UI elements by using the command with the argument edit set to true. e.g.



          button = cmds.button(bgc=[.5, .5, .5])
          cmds.button(button, edit=True, bgc=[1,1,1])


          In your case, you can create a button command and switch the color there. To make it simpler you can even get the current value with the query argument set to true.



          currentColor = cmds.button(button, query=True, bgc=True)


          This way you can check the current color and switch if needed to the other one.






          share|improve this answer























          • Thanks haggi krey for your answer,Just awesome. Okay so buttons will used to select objects and the idea is when a button click (object is selected) the button color should switch to white automatically to indicate that object is selected and when the object is deselected the button should switch back to default color to indicate that objecting is no longer selected. More like a button color feedback. How do I achieve this? Thanks again!

            – pro nerd
            Mar 25 at 14:01






          • 1





            you should put a cmds.scriptJob while your ui is running to change the color of the button if a certain element is selected. Do you have some code to show ?

            – DrWeeny
            Mar 25 at 15:37












          • Hello DrWeeny, here is the code so far. Kindly help with the scriptjob as simple as possible and you can attach the scriptjob to the code so I know how it how it all come together that will be a big help.Thanks

            – pro nerd
            Mar 26 at 6:01











          • ill try to do this tomorrow ! I dont have maya at home

            – DrWeeny
            Mar 26 at 12:11















          0














          You can always edit your UI elements by using the command with the argument edit set to true. e.g.



          button = cmds.button(bgc=[.5, .5, .5])
          cmds.button(button, edit=True, bgc=[1,1,1])


          In your case, you can create a button command and switch the color there. To make it simpler you can even get the current value with the query argument set to true.



          currentColor = cmds.button(button, query=True, bgc=True)


          This way you can check the current color and switch if needed to the other one.






          share|improve this answer























          • Thanks haggi krey for your answer,Just awesome. Okay so buttons will used to select objects and the idea is when a button click (object is selected) the button color should switch to white automatically to indicate that object is selected and when the object is deselected the button should switch back to default color to indicate that objecting is no longer selected. More like a button color feedback. How do I achieve this? Thanks again!

            – pro nerd
            Mar 25 at 14:01






          • 1





            you should put a cmds.scriptJob while your ui is running to change the color of the button if a certain element is selected. Do you have some code to show ?

            – DrWeeny
            Mar 25 at 15:37












          • Hello DrWeeny, here is the code so far. Kindly help with the scriptjob as simple as possible and you can attach the scriptjob to the code so I know how it how it all come together that will be a big help.Thanks

            – pro nerd
            Mar 26 at 6:01











          • ill try to do this tomorrow ! I dont have maya at home

            – DrWeeny
            Mar 26 at 12:11













          0












          0








          0







          You can always edit your UI elements by using the command with the argument edit set to true. e.g.



          button = cmds.button(bgc=[.5, .5, .5])
          cmds.button(button, edit=True, bgc=[1,1,1])


          In your case, you can create a button command and switch the color there. To make it simpler you can even get the current value with the query argument set to true.



          currentColor = cmds.button(button, query=True, bgc=True)


          This way you can check the current color and switch if needed to the other one.






          share|improve this answer













          You can always edit your UI elements by using the command with the argument edit set to true. e.g.



          button = cmds.button(bgc=[.5, .5, .5])
          cmds.button(button, edit=True, bgc=[1,1,1])


          In your case, you can create a button command and switch the color there. To make it simpler you can even get the current value with the query argument set to true.



          currentColor = cmds.button(button, query=True, bgc=True)


          This way you can check the current color and switch if needed to the other one.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 25 at 12:40









          haggi kreyhaggi krey

          6183 silver badges7 bronze badges




          6183 silver badges7 bronze badges












          • Thanks haggi krey for your answer,Just awesome. Okay so buttons will used to select objects and the idea is when a button click (object is selected) the button color should switch to white automatically to indicate that object is selected and when the object is deselected the button should switch back to default color to indicate that objecting is no longer selected. More like a button color feedback. How do I achieve this? Thanks again!

            – pro nerd
            Mar 25 at 14:01






          • 1





            you should put a cmds.scriptJob while your ui is running to change the color of the button if a certain element is selected. Do you have some code to show ?

            – DrWeeny
            Mar 25 at 15:37












          • Hello DrWeeny, here is the code so far. Kindly help with the scriptjob as simple as possible and you can attach the scriptjob to the code so I know how it how it all come together that will be a big help.Thanks

            – pro nerd
            Mar 26 at 6:01











          • ill try to do this tomorrow ! I dont have maya at home

            – DrWeeny
            Mar 26 at 12:11

















          • Thanks haggi krey for your answer,Just awesome. Okay so buttons will used to select objects and the idea is when a button click (object is selected) the button color should switch to white automatically to indicate that object is selected and when the object is deselected the button should switch back to default color to indicate that objecting is no longer selected. More like a button color feedback. How do I achieve this? Thanks again!

            – pro nerd
            Mar 25 at 14:01






          • 1





            you should put a cmds.scriptJob while your ui is running to change the color of the button if a certain element is selected. Do you have some code to show ?

            – DrWeeny
            Mar 25 at 15:37












          • Hello DrWeeny, here is the code so far. Kindly help with the scriptjob as simple as possible and you can attach the scriptjob to the code so I know how it how it all come together that will be a big help.Thanks

            – pro nerd
            Mar 26 at 6:01











          • ill try to do this tomorrow ! I dont have maya at home

            – DrWeeny
            Mar 26 at 12:11
















          Thanks haggi krey for your answer,Just awesome. Okay so buttons will used to select objects and the idea is when a button click (object is selected) the button color should switch to white automatically to indicate that object is selected and when the object is deselected the button should switch back to default color to indicate that objecting is no longer selected. More like a button color feedback. How do I achieve this? Thanks again!

          – pro nerd
          Mar 25 at 14:01





          Thanks haggi krey for your answer,Just awesome. Okay so buttons will used to select objects and the idea is when a button click (object is selected) the button color should switch to white automatically to indicate that object is selected and when the object is deselected the button should switch back to default color to indicate that objecting is no longer selected. More like a button color feedback. How do I achieve this? Thanks again!

          – pro nerd
          Mar 25 at 14:01




          1




          1





          you should put a cmds.scriptJob while your ui is running to change the color of the button if a certain element is selected. Do you have some code to show ?

          – DrWeeny
          Mar 25 at 15:37






          you should put a cmds.scriptJob while your ui is running to change the color of the button if a certain element is selected. Do you have some code to show ?

          – DrWeeny
          Mar 25 at 15:37














          Hello DrWeeny, here is the code so far. Kindly help with the scriptjob as simple as possible and you can attach the scriptjob to the code so I know how it how it all come together that will be a big help.Thanks

          – pro nerd
          Mar 26 at 6:01





          Hello DrWeeny, here is the code so far. Kindly help with the scriptjob as simple as possible and you can attach the scriptjob to the code so I know how it how it all come together that will be a big help.Thanks

          – pro nerd
          Mar 26 at 6:01













          ill try to do this tomorrow ! I dont have maya at home

          – DrWeeny
          Mar 26 at 12:11





          ill try to do this tomorrow ! I dont have maya at home

          – DrWeeny
          Mar 26 at 12:11



















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55336194%2fbutton-feedback-color-python-in-maya%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

          용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

          155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해