Community
    • Login

    toolBar Switch for PythonScript plugin

    Scheduled Pinned Locked Moved General Discussion
    5 Posts 3 Posters 343 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • W
      westyles
      last edited by westyles

      🙃

      notepad++toolbar.gif

      # -*- coding: utf-8 -*-
      """
         toolBar Switch
      
         Author:  westlife | ru-board.com
           Date:  2014-09-28
      
         Script for PythonScript plugin
         It is required to bind "toolBar_Switch.py" for example to "F6" key.
      
      """
      
      ##### all imports added to startup.py
      #from Npp import notepad
      
      def toolBar_Switch():
          if notepad.isToolBarHidden(): notepad.hideToolBar(False)
          else: notepad.hideToolBar(True)
      
      if __name__ == '__main__':
          toolBar_Switch()
      
      Alan KilbornA 1 Reply Last reply Reply Quote 0
      • Alan KilbornA
        Alan Kilborn @westyles
        last edited by Alan Kilborn

        @westyles


        COMMENTS ON POSTING SCRIPTS HERE:

        It is customary, when posting a script here that you think others might find useful, to describe what your script does, instead of just posting it and assuming others will obviously be tuned-into its function.

        Your script here is short, but it might be far from obvious; example:

        “toolbar switch”, hmmm, okay, does this switch out the existing toolbar for a different one?

        Only after a bit more study does one see that it toggles the visibility of the existing toolbar, on and off.

        Of course, if you don’t describe it, only someone familiar with coding would understand this – a noob that might like to have the functionality the script provides, would probably not bother (because they wouldn’t know).


        COMMENTS ON THE SPECIFIC SCRIPT POSTED:

        Your script is interesting because it uses the return value from the notepad.hideToolBar() function. There is no documented return value from this function, so you shouldn’t use it. In fact, as I experimented with it, I was confused about what it returns.

        You should use the notepad.isToolBarHidden() function instead, when trying to test to see the current state of toolbar visibility.

        W 1 Reply Last reply Reply Quote 1
        • W
          westyles @Alan Kilborn
          last edited by

          @Alan-Kilborn said in toolBar Switch for PythonScript plugin:

          There is no documented return value from this function, so you shouldn’t use it.

          Thanks for the tip.
          I try to write the fastest and shortest code possible. I’ve redone it.

          1 Reply Last reply Reply Quote 0
          • guy038G
            guy038
            last edited by guy038

            Hello, @westyles, @alan-kilborn and All,

            @westyles, see also my post, below :

            https://community.notepad-plus-plus.org/post/93258

            Best Regards,

            guy038

            W 1 Reply Last reply Reply Quote 2
            • W
              westyles @guy038
              last edited by

              @guy038 said in toolBar Switch for PythonScript plugin:

              see also my post, below :

              A good option.
              The site does not allow me to like your post without reputation.

              1 Reply Last reply Reply Quote 1
              • First post
                Last post
              The Community of users of the Notepad++ text editor.
              Powered by NodeBB | Contributors