Pythonscript plugin / console not working
-
@Mark-Olson said in Pythonscript plugin / console not working:
off-topic, but I should also note that this specific task (doing math in a regex/replace) seems like the sort of thing that the Columns++ plugin is good for.
I have now updated the Math Replacement FAQ to include a section about the Columns++ Plugin, because that is definitely a viable alternative to scripting plugin (Thanks @Coises : BTW, when are you going to submit Columns++ to the Plugins Admin list? It will be much easier for people to install your plugin if it’s in the official list.)
-
@PeterJones said in Pythonscript plugin / console not working:
BTW, when are you going to submit Columns++ to the Plugins Admin list ? It will be much easier for people to install your plugin if it’s in the official list.
I want to feel confident that it is unlikely to misbehave for most people under most circumstances, and very unlikely to do something like hang and make a user force-close Notepad++, losing work in progress. I’m not yet confident of that — bugs are still turning up.
I also want to feel confident that I am unlikely to make “architectural” changes which could introduce new instability, or user interface changes that could disrupt routines of anyone who had already come to rely on it working the way it does. I’m close to considering that part acceptable, though I’m still a little troubled that the Elastic tabstops feature is not as efficient as I’d like. (Variable-pitch fonts are one major cause of inefficiency, but I doubt people use those a lot in Notepad++ anyway, so I’m willing to accept the idea that if you have a large file and you’re not monospaced, don’t expect Elastic tabstops to perform well. However, large rectangular selections, as in thousands of lines, are a problem even in fixed-pitch, and I wish I could make them faster. As I recall, the “old” version of the Elastic tabstops plugin just let unexpected-to-useless results occur when you did something like click near the beginning of a file, scroll to the end, and then Shift+Alt+click to make a rectangular selection; and the “new” version of Elastic tabstops was apparently abandoned by its author shortly after he pushed to get it accepted as a replacement for the old official plugin.)
I know I won’t get the amount of field testing I would like to make it official, though, until after I’ve made it official…
-
@Mark-Olson Can it do multiple files at once? I also can’t quite figure out how to divide with it.
-
@Alan-Kilborn Sorry I should have mentioned that ‘Show Console’ would be on in the plugin menu but nothing is visible. When when I activate it after opening n++ I see something very briefly flash but that’s it.
-
@Fuel-DZN said in Pythonscript plugin / console not working:
@Mark-Olson Can it do multiple files at once? I also can’t quite figure out how to divide with it.
The Search in indicated region function in Columns++ only works on a region (which can be the entire file) in the active tab. The initial motivation for this function was to be able to search within a rectangular selection. It is unlikely that I’ll extend it to processing multiple tabs or files at once, since the notion of an “indicated region” wouldn’t make sense in that context.
If I’m following the intent of your Python, you would want:
Find what :
(?<=development = )\d+
Replace with :(?=ceil(this/2))
-
@Coises Thank you, I didn’t see that - it works now.
Since I need it for multiple files, I used this, but it doesn’t work:
from Npp import * import math def divide_2(m): return str(int(float(math.ceil((float(m.group(1)) / 2))))) for (filename, bufferID, index, view) in notepad.getFiles(): notepad.activateBufferID(bufferID) print(notepad.getCurrentFilename() editor.rereplace(r'(?<=development = )(\d+)', divide_2); notepad.save()
If anyone with experience in python (or an eye for typos) sees what’s wrong with this please let me know. (I’m not sure if I’m supposed to create a new post for this.)
-
@Fuel-DZN said in Pythonscript plugin / console not working:
print(notepad.getCurrentFilename()
unbalanced parentheses. It should be
print(notepad.getCurrentFilename())
-
OP really needs to get the console window working, because if other forum members have to spot such simple typos as
print(notepad.getCurrentFilename()
then we’ve got a problem… -
@Fuel-DZN said,
‘Show Console’ would be on in the plugin menu but nothing is visible
Can you show a screenshot of the Plugins > Python Script menu, showing the checkmark really is on the Show Console entry?
Also, I think you should read the FAQ on Find Results – don’t be confused: that FAQ focuses on the Search Results window, but all the information about docking (where the docking resize are when a docked panel is tiny, or resetting the docking by editing the config file) are applicable to the PythonScript console as well, since it uses the same docking interface as other panels. (The only thing that’s not applicable from that FAQ is that F7 won’t toggle you to get into the PythonScript console panel, unlike the Search Results)
-
@PeterJones said in Pythonscript plugin / console not working:
Can you show a screenshot of the Plugins > Python Script menu, showing the checkmark really is on the Show Console entry?
-
Can you take the same screenshot but with the whole npp window?
-
@Ekopalypse said in Pythonscript plugin / console not working:
Can you take the same screenshot but with the whole npp window?
While you’re at it, also File > Open
%AppData%\Notepad++\config.xml
, search forGUIConfig name="DockingManager"
and then copy the DockingManager section from that file, paste it into your reply, select it and click the</>
toolbar button in the forum edit-your-post window, which will make it look something like this in your post:<GUIConfig name="DockingManager" leftWidth="200" rightWidth="200" topHeight="200" bottomHeight="200"> <PluginDlg pluginName="Notepad++::InternalFunction" id="42052" curr="0" prev="-1" isVisible="yes" /> <PluginDlg pluginName="Notepad++::InternalFunction" id="44084" curr="1" prev="-1" isVisible="yes" /> <PluginDlg pluginName="Notepad++::InternalFunction" id="44080" curr="3" prev="-1" isVisible="yes" /> <ActiveTabs cont="0" activeTab="0" /> <ActiveTabs cont="1" activeTab="0" /> <ActiveTabs cont="2" activeTab="-1" /> <ActiveTabs cont="3" activeTab="0" /> </GUIConfig>
That section will tell us whether the problem was, as I suspected, that you have just shrunk your PythonScript console panel too small for you to notice. (Please note, the FAQ I linked you to above already told you to go looking in that file, and told you how to reset that section so that it will likely fix your problem; given your lack of mention in your reply, I am going to assume that you didn’t notice that piece of advice from my previous post.)
-
Sorry for the late reply.
<GUIConfig name="DockingManager" leftWidth="247" rightWidth="200" topHeight="373" bottomHeight="0"> <FloatingWindow cont="4" x="13" y="173" width="1635" height="966" /> <PluginDlg pluginName="Notepad++::InternalFunction" id="44070" curr="0" prev="-1" isVisible="yes" /> <PluginDlg pluginName="Python Script" id="-1" curr="3" prev="-1" isVisible="yes" /> <PluginDlg pluginName="Notepad++::InternalFunction" id="0" curr="2" prev="4" isVisible="no" /> <PluginDlg pluginName="Notepad++::InternalFunction" id="44084" curr="1" prev="-1" isVisible="no" /> <PluginDlg pluginName="NppExec.dll" id="5" curr="3" prev="4" isVisible="yes" /> <PluginDlg pluginName="Explorer.dll" id="0" curr="0" prev="-1" isVisible="no" /> <ActiveTabs cont="0" activeTab="0" /> <ActiveTabs cont="1" activeTab="-1" /> <ActiveTabs cont="2" activeTab="-1" /> <ActiveTabs cont="3" activeTab="-1" /> </GUIConfig>
(Indentation is messed up but I don’t know how to fix that.)
I tried the FAQ suggestions which did not solve it.
In case it is helpful, earlier I said:
When when I activate it after opening n++ I see something very briefly flash but that’s it.
-
<GUIConfig name="DockingManager" leftWidth="247" rightWidth="200" topHeight="373" bottomHeight="0">
I tried the FAQ suggestions which did not solve it.
Do you see that
bottomHeight="0"
? That is the culprit, and the FAQ explains how to fix it.Also, the up-down arrow in the right place would have fixed it also. This gap from your screenshot is exacty the gap I was referencing in the FAQ. I have added the arrow to show you where to hover your mouse cursor to find it.
-
@PeterJones Thank you, resizing the panel just fixed it. I don’t know why it didn’t work before.