Set logical status of CheckBox in matplotlib without triggering callbacks?










0















Is there a way to set the logical status of CheckButtons in matplotlib withput triggering onclick() callbacks?



Here is my scenario:



I am displaying a graph with a large number of traces (50+) and want to give the user the option of displaying a subset of these on the basis of some fixed queries, which the user selects via CheckButton. Every time a button is clicked the the script gets the status of all present CheckButtons via get_status(), computes the indices of the traces that meet the selected criteria, and updates the display accordingly.



In order to make life easier for the user I want to also have a "Select all" and "Clear all" buttons. The best way I can come up with to implement these is to force the logical state of all CheckButtons to True or False without triggering an on_click() callback, then set the visibility of the traces accordingly.



However, CheckButton() does not have a set_status() method
https://matplotlib.org/api/widgets_api.html#matplotlib.widgets.CheckButtons



There is a set_active() method but according the documetnation it triggers a callback if eventson is true.



Can someone give me a couple of pointers how to go about doing this? Do I need to set eventson=False for the wdget, then set_active()=True followed by eventson=True? Seems rather clunky, but I can't figure a more elegant way, even after spending way too many hours.



Thanks!










share|improve this question


























    0















    Is there a way to set the logical status of CheckButtons in matplotlib withput triggering onclick() callbacks?



    Here is my scenario:



    I am displaying a graph with a large number of traces (50+) and want to give the user the option of displaying a subset of these on the basis of some fixed queries, which the user selects via CheckButton. Every time a button is clicked the the script gets the status of all present CheckButtons via get_status(), computes the indices of the traces that meet the selected criteria, and updates the display accordingly.



    In order to make life easier for the user I want to also have a "Select all" and "Clear all" buttons. The best way I can come up with to implement these is to force the logical state of all CheckButtons to True or False without triggering an on_click() callback, then set the visibility of the traces accordingly.



    However, CheckButton() does not have a set_status() method
    https://matplotlib.org/api/widgets_api.html#matplotlib.widgets.CheckButtons



    There is a set_active() method but according the documetnation it triggers a callback if eventson is true.



    Can someone give me a couple of pointers how to go about doing this? Do I need to set eventson=False for the wdget, then set_active()=True followed by eventson=True? Seems rather clunky, but I can't figure a more elegant way, even after spending way too many hours.



    Thanks!










    share|improve this question
























      0












      0








      0








      Is there a way to set the logical status of CheckButtons in matplotlib withput triggering onclick() callbacks?



      Here is my scenario:



      I am displaying a graph with a large number of traces (50+) and want to give the user the option of displaying a subset of these on the basis of some fixed queries, which the user selects via CheckButton. Every time a button is clicked the the script gets the status of all present CheckButtons via get_status(), computes the indices of the traces that meet the selected criteria, and updates the display accordingly.



      In order to make life easier for the user I want to also have a "Select all" and "Clear all" buttons. The best way I can come up with to implement these is to force the logical state of all CheckButtons to True or False without triggering an on_click() callback, then set the visibility of the traces accordingly.



      However, CheckButton() does not have a set_status() method
      https://matplotlib.org/api/widgets_api.html#matplotlib.widgets.CheckButtons



      There is a set_active() method but according the documetnation it triggers a callback if eventson is true.



      Can someone give me a couple of pointers how to go about doing this? Do I need to set eventson=False for the wdget, then set_active()=True followed by eventson=True? Seems rather clunky, but I can't figure a more elegant way, even after spending way too many hours.



      Thanks!










      share|improve this question














      Is there a way to set the logical status of CheckButtons in matplotlib withput triggering onclick() callbacks?



      Here is my scenario:



      I am displaying a graph with a large number of traces (50+) and want to give the user the option of displaying a subset of these on the basis of some fixed queries, which the user selects via CheckButton. Every time a button is clicked the the script gets the status of all present CheckButtons via get_status(), computes the indices of the traces that meet the selected criteria, and updates the display accordingly.



      In order to make life easier for the user I want to also have a "Select all" and "Clear all" buttons. The best way I can come up with to implement these is to force the logical state of all CheckButtons to True or False without triggering an on_click() callback, then set the visibility of the traces accordingly.



      However, CheckButton() does not have a set_status() method
      https://matplotlib.org/api/widgets_api.html#matplotlib.widgets.CheckButtons



      There is a set_active() method but according the documetnation it triggers a callback if eventson is true.



      Can someone give me a couple of pointers how to go about doing this? Do I need to set eventson=False for the wdget, then set_active()=True followed by eventson=True? Seems rather clunky, but I can't figure a more elegant way, even after spending way too many hours.



      Thanks!







      python python-2.7 matplotlib matplotlib-widget






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 13 '18 at 7:51









      GroovyGeekGroovyGeek

      11




      11






















          1 Answer
          1






          active

          oldest

          votes


















          0














          I knew it, as soon as I post a question I figure out the answer. Here is what I came up with for anyone else that wants to do something like this




           check.eventson = False
          status = check.get_status()
          for i,stat in enumerate(status):
          if ((enable and not stat) or (not enable and stat)):
          check.set_active(i)
          check.eventson = True



          here check is a reference to the CheckBox() object and enable is a variable set to True if you want to enable all checkboxes, or False otherwise.






          share|improve this answer






















            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%2f53276214%2fset-logical-status-of-checkbox-in-matplotlib-without-triggering-callbacks%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














            I knew it, as soon as I post a question I figure out the answer. Here is what I came up with for anyone else that wants to do something like this




             check.eventson = False
            status = check.get_status()
            for i,stat in enumerate(status):
            if ((enable and not stat) or (not enable and stat)):
            check.set_active(i)
            check.eventson = True



            here check is a reference to the CheckBox() object and enable is a variable set to True if you want to enable all checkboxes, or False otherwise.






            share|improve this answer



























              0














              I knew it, as soon as I post a question I figure out the answer. Here is what I came up with for anyone else that wants to do something like this




               check.eventson = False
              status = check.get_status()
              for i,stat in enumerate(status):
              if ((enable and not stat) or (not enable and stat)):
              check.set_active(i)
              check.eventson = True



              here check is a reference to the CheckBox() object and enable is a variable set to True if you want to enable all checkboxes, or False otherwise.






              share|improve this answer

























                0












                0








                0







                I knew it, as soon as I post a question I figure out the answer. Here is what I came up with for anyone else that wants to do something like this




                 check.eventson = False
                status = check.get_status()
                for i,stat in enumerate(status):
                if ((enable and not stat) or (not enable and stat)):
                check.set_active(i)
                check.eventson = True



                here check is a reference to the CheckBox() object and enable is a variable set to True if you want to enable all checkboxes, or False otherwise.






                share|improve this answer













                I knew it, as soon as I post a question I figure out the answer. Here is what I came up with for anyone else that wants to do something like this




                 check.eventson = False
                status = check.get_status()
                for i,stat in enumerate(status):
                if ((enable and not stat) or (not enable and stat)):
                check.set_active(i)
                check.eventson = True



                here check is a reference to the CheckBox() object and enable is a variable set to True if you want to enable all checkboxes, or False otherwise.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 13 '18 at 8:16









                GroovyGeekGroovyGeek

                11




                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%2f53276214%2fset-logical-status-of-checkbox-in-matplotlib-without-triggering-callbacks%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

                    Use pre created SQLite database for Android project in kotlin

                    Darth Vader #20

                    Ondo