Code Beautifier 1.0 (PythonScript)
-
@Khundian-Twitch said in Code Beautifier 1.0 (PythonScript):
…normally the Tkinter module should be available in the standard PythonScript 2 plugin.
This is not correct…or, at least, it’s not my experience.
I just tried installing the PythonScript plugin (v.2.0.0.0) via Plugins Admin into a fresh Notepad++.
Then I tried to import Tkinter (or even tkinter) in the PS console:It’s pretty clear that it isn’t there with a Plugins admin install.
-
@Lycan-Thrope said in Code Beautifier 1.0 (PythonScript):
did an install and followed the instructions to find out if the tkinter is installed correctly, but the installer has no specific option to install tkinter and the IDLE, even though I’ve checked them in the installer that is supposed to install them all. I then look and I see… _tkinter in the lib directory, so I know it’s there, I’m guessing that the installer doesn’t install it per se, so I’m trying to figure out what to do next to get it just to work with a Python install, let alone the NPP PythonScript.
To be clear, nothing I’m talking about is relating to getting Tkinter into a non-PythonScript situation (i.e., getting it into a standard/standalone Python). Discussion of that is really outside of the scope of this forum and should be discussed elsewhere, if needed.
So…if we’re talking only about PythonScript… (and we are):
First (and I thought this was totally clear from earlier posting where I said To get Tkinter, you MUST install that manually, by extracting a “TclTk” zip file into the appropriate folder of your existing PS plugin directory structure), there is no installer for Tkinter on PS. Period. End of story. Let’s stop talking about installers (ugh!).
What you want to do is to grab
PythonScript_TclTk_2.0.0.0_x64.zip
(if using 64-bit N++) and unzip that into your N++ folder (where you can see the existingplugins
folder in it).Restart Notepad++ and try an
import Tkinter
in the PS console window and it should not fail (i.e. no red error messages):At that point you should (obviously) be good to go from a Tkinter standpoint.
I don’t know what problems you’ll encounter (if any) with the Code Beautifier script, as I haven’t tried that myself. -
@Alan-Kilborn @Lycan-Thrope
Alan is right, I forgot I have the full Python 2.7.18 release installed on my workstation. Hence the reason why it worked out of the box for me. Apologies for the confusion.You can install/enable the Tkinter module as Alan described above or you can install the full Python 2.7.18 release version from here. Either of these options should enable you to use the Tkinter module.
-
@Khundian-Twitch A relative path of
settings_folder = "plugins/Config/PythonScript/scripts/Code Beautifier" # Folder containing language settings files
will operate in the current working directory (cwd). The cwd can be the root of where notepad.exe is located. This may work for portable, though Notepad++ installed in
C:\Program Files\Notepad++
can cause the errorWindowsError: [Error 5] Access is denied
as unable to create folders or files in that location.I suggest an absolute path to the plugin config directory to ensure a writable location:
settings_folder = os.path.join(notepad.getPluginConfigDir(), r"PythonScript\scripts\Code Beautifier") # Folder containing language settings files
The change suggested is with line 28 .
-
@Khundian-Twitch said in Code Beautifier 1.0 (PythonScript):
you can install the full Python 2.7.18 release version
But you neglected to say that you must change your PS Configuration in order to use this. I’m not on my PC right now, so I can’t give the exact name of the setting for this.
It is best, when possible, to NOT demand that users have a standalone Python on their system in order to use scripts with Notepad++ – users that don’t already do Python are probably 0% likely to do this anyway. In this case (for the script in this thread), it is possible, as Tkinter does have a PS way to be run (discussed ad nauseum in this thread already).
-
@mpheath said in Code Beautifier 1.0 (PythonScript):
@Khundian-Twitch A relative path of
settings_folder = "plugins/Config/PythonScript/scripts/Code Beautifier" # Folder containing language settings files
will operate in the current working directory (cwd). The cwd can be the root of where notepad.exe is located. This may work for portable, though Notepad++ installed in
C:\Program Files\Notepad++
can cause the errorWindowsError: [Error 5] Access is denied
as unable to create folders or files in that location.I suggest an absolute path to the plugin config directory to ensure a writable location:
settings_folder = os.path.join(notepad.getPluginConfigDir(), r"PythonScript\scripts\Code Beautifier") # Folder containing language settings files
The change suggested is with line 28 .
Thanks for the suggestion, when I have some time I’ll have a look at the script to ensure compatibility with the installer version of Notepad++. Probably over the weekend.
@Alan-Kilborn said in Code Beautifier 1.0 (PythonScript):
@Khundian-Twitch said in Code Beautifier 1.0 (PythonScript):
you can install the full Python 2.7.18 release version
But you neglected to say that you must change your PS Configuration in order to use this. I’m not on my PC right now, so I can’t give the exact name of the setting for this.
It is best, when possible, to NOT demand that users have a standalone Python on their system in order to use scripts with Notepad++ – users that don’t already do Python are probably 0% likely to do this anyway. In this case (for the script in this thread), it is possible, as Tkinter does have a PS way to be run (discussed ad nauseum in this thread already).
I agree that your method is preferred over installing a standalone version of Python, but I didn’t have to change any PythonScript configuration to be able to use Tkinter.
-
@Alan-Kilborn,
Thanks @Alan-Kilborn . I apparently went awry somewhere along the way, followed your instructions, and had to retrace the installation of the script’s placement in the NPP directory, rather than the user directory, and then I changed the path at line 28, restarted NPP, and although I still had a problem getting it to work, I finally put the “quotes” around the keyword and got it to finally show the UI aspects. I’ll play more later.This brings up, @Khundian-Twitch , that you have to write instructions for an idiot like me, so I don’t screw them up. Which means you need to (as I did for my own dBASEPlus installer) assume nothing and either make it so the install is brain dead simple, or the instructions are written to a neophyte understanding level. As @Alan-Kilborn points out, the more difficult and detailed and with missing details the process is, the less likely you’ll have users to use it.
I’m a programmer, but not a Python or PythonScript programmer. I only use it because the scripts you guys write, need them to work, otherwise I’d be fine not bothering with Python at all. I’m slowly looking to do some programming in Python/PythonScript eventually, but not today. :-) Write for the idiot in us. :-)
-
@Khundian-Twitch ,
Have an issue I’m not sure of if is your plug in issue. I have two dBASE UDL’s. One for DarkMode and one for non-DarkMode. Named differently and when I tried to trigger the Beautifier in the non-DarkMode, it ignores it as another UDL. It would be in the same Alphabetic lettering, but is named, dBASEPlus and the DarkMode is…of course Dark_dBASEPlus. Only the DarkMode version is showing up in your Alphabetic listing.
Just an FYI. -
@Lycan-Thrope said in Code Beautifier 1.0 (PythonScript):
@Khundian-Twitch ,
Have an issue I’m not sure of if is your plug in issue. I have two dBASE UDL’s. One for DarkMode and one for non-DarkMode. Named differently and when I tried to trigger the Beautifier in the non-DarkMode, it ignores it as another UDL. It would be in the same Alphabetic lettering, but is named, dBASEPlus and the DarkMode is…of course Dark_dBASEPlus. Only the DarkMode version is showing up in your Alphabetic listing.
Just an FYI.Thanks for reporting your issue.
The script doesn’t pick up the non-dark version because “D” doesn’t equal “d”, make sure your language name starts with a capital letter and it will work without an issue.
When I have some time off, I’ll have a look at the script to make it case insensitive.
-
@Khundian-Twitch said in Code Beautifier 1.0 (PythonScript):
The script doesn’t pick up the non-dark version because “D” doesn’t equal “d”, make sure your language name starts with a capital letter and it will work without an issue.
When I have some time off, I’ll have a look at the script to make it case insensitive.
Thanks for verifying that, and taking a look to possibly change it. It actually is the products proper name, “dBASE”, so it’s more recognizable to people that know about it. Dark_ was just added so they could know the difference and setup their color scheme differently depending on the option they chose.
They use the same functionList and overrideMap .xml files, but each version has it’s own autoComplete.xml file and UDL language .xml file for coloring accordingly. Still playing and finding things out as I go. :-)
-
@Khundian-Twitch ,
More bad news, I’m afraid. Even using the capitalized language, option in your beautifier, it is not working on my code. I tried it straight from the IDE that generates code, and then I wrote one in Notepad++, with no formatting at all (all text was flush left), initiated your script, chose my language and all the settings that I had in there last time I made the beautifier settings, it did not carry them over, apparently. So, I redid some of them and then saved the file…and nothing.So, I either have bad settings here, somehow, although your script is apparently working to call up the dialog box, but it’s not doing any beautifying at all. :-(
-
@Lycan-Thrope said in Code Beautifier 1.0 (PythonScript):
@Khundian-Twitch ,
More bad news, I’m afraid. Even using the capitalized language, option in your beautifier, it is not working on my code. I tried it straight from the IDE that generates code, and then I wrote one in Notepad++, with no formatting at all (all text was flush left), initiated your script, chose my language and all the settings that I had in there last time I made the beautifier settings, it did not carry them over, apparently. So, I redid some of them and then saved the file…and nothing.So, I either have bad settings here, somehow, although your script is apparently working to call up the dialog box, but it’s not doing any beautifying at all. :-(
Can you go in a bit more detail what exactly isn’t working? Each language should have its own button in the alphabetical language list and a settings file, no settings are “carried over” between languages.
Does each “version” of the language have a seperate button in the alphabetical language list? If this is not the case, most probably the language settings file with the lowercase starting letter is still in the settings folder “\plugins\Config\PythonScript\scripts\Code Beautifier”. Make sure the settings file starts wiith a capital letter, and that you have configured the settings for each language through the GUI. When this is done, the script should beautify your code in both “versions” of the language. Let me know if this fixes your issue.
I will get around to fixing this annoying case sensitive thing, but between work and family there isn’t any time left atm.
-
@Khundian-Twitch ,
A picture is worth a thousand words, so below is a screen capture showing thekeyword_groups_Dark_dBASEPlus.txt
file that your script creates with my beautifier keyword settings in front of a program file with a.prg
file extension that is part of my UDL and recognized by it. I saved the file prior and after putting all the text to the left side, and then saved it, and…this is the result. Your script is not working with my UDL.As I mentioned, perhaps there is something amiss. Every time I open the settings file, it is erasing what was there, and waiting for new input. I even erased the non-capitalized normal
keyword_groups_dBASEPlus.txt
file, because although it doesn’t display it in your UI box, it did exist in the directory, so I deleted it as a safety precaution, however, upon opening a file when your script is runninng, and I open a file which defaults to normal mode and has to be switched to Dark mode, your script recreated the file again for this screenshot with nothing in it.I’m going to remove all the script aspects, because as of now, I normally type my own beautification as part of my normal typing, as I’m a touch typist and can easily write my code with formatting I’m used to without a beautifier, but if you get this working again later, I may try it again, but for right now it’s pretty much ineffective for me, and if you don’t have the time to work on it, I understand…but I also won’t be playing with it anymore either. ;-)
-
@Lycan-Thrope
I understand completely, I shouldn’t have made it public unless I have time to provide support for it.