• Login
Community
  • Login

Pythonscript plugin / console not working

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
19 Posts 6 Posters 1.7k 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.
  • C
    Coises @Fuel DZN
    last edited by Oct 4, 2023, 5:09 AM

    @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))

    1 Reply Last reply Reply Quote 1
    • F
      Fuel DZN @Coises
      last edited by Fuel DZN Oct 4, 2023, 8:09 AM Oct 4, 2023, 6:30 AM

      @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.)

      P 1 Reply Last reply Oct 4, 2023, 12:58 PM Reply Quote 0
      • P
        PeterJones @Fuel DZN
        last edited by Oct 4, 2023, 12:58 PM

        @Fuel-DZN said in Pythonscript plugin / console not working:

        print(notepad.getCurrentFilename()

        unbalanced parentheses. It should be print(notepad.getCurrentFilename())

        A 1 Reply Last reply Oct 4, 2023, 4:02 PM Reply Quote 3
        • A
          Alan Kilborn @PeterJones
          last edited by Oct 4, 2023, 4:02 PM

          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…

          P 1 Reply Last reply Oct 4, 2023, 5:29 PM Reply Quote 2
          • P
            PeterJones @Alan Kilborn
            last edited by Oct 4, 2023, 5:29 PM

            @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)

            F 1 Reply Last reply Oct 12, 2023, 6:15 AM Reply Quote 2
            • F
              Fuel DZN @PeterJones
              last edited by Oct 12, 2023, 6:15 AM

              @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?

              a1.png

              E 1 Reply Last reply Oct 12, 2023, 6:54 AM Reply Quote 0
              • E
                Ekopalypse @Fuel DZN
                last edited by Oct 12, 2023, 6:54 AM

                @Fuel-DZN

                Can you take the same screenshot but with the whole npp window?

                P 1 Reply Last reply Oct 12, 2023, 1:33 PM Reply Quote 1
                • P
                  PeterJones @Ekopalypse
                  last edited by PeterJones Oct 12, 2023, 1:35 PM Oct 12, 2023, 1:33 PM

                  @Ekopalypse said in Pythonscript plugin / console not working:

                  @Fuel-DZN

                  Can you take the same screenshot but with the whole npp window?

                  @Fuel-DZN ,

                  While you’re at it, also File > Open %AppData%\Notepad++\config.xml , search for GUIConfig 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.)

                  F 1 Reply Last reply Oct 21, 2023, 9:20 AM Reply Quote 3
                  • F
                    Fuel DZN @PeterJones
                    last edited by Fuel DZN Oct 21, 2023, 9:35 AM Oct 21, 2023, 9:20 AM

                    @PeterJones

                    Sorry for the late reply.

                    Screenshot (105).png

                    <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.

                    P 1 Reply Last reply Oct 21, 2023, 4:18 PM Reply Quote 0
                    • P
                      PeterJones @Fuel DZN
                      last edited by PeterJones Oct 21, 2023, 5:09 PM Oct 21, 2023, 4:18 PM

                      <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.
                      797e3acf-d3bf-4fe1-907a-d6edc9a97fb8-image.png

                      F 1 Reply Last reply Oct 22, 2023, 11:08 AM Reply Quote 2
                      • F
                        Fuel DZN @PeterJones
                        last edited by Oct 22, 2023, 11:08 AM

                        @PeterJones Thank you, resizing the panel just fixed it. I don’t know why it didn’t work before.

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