toolBar Switch for PythonScript plugin
-
đ
# -*- 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()
-
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. -
@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. -
Hello, @westyles, @alan-kilborn and All,
@westyles, see also my post, below :
https://community.notepad-plus-plus.org/post/93258
Best Regards,
guy038
-
@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.