Community
    • Login

    Pythonscript plugin / console not working

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    19 Posts 6 Posters 1.6k 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.
    • Fuel DZNF
      Fuel DZN @Mark Olson
      last edited by

      @Mark-Olson Can it do multiple files at once? I also can’t quite figure out how to divide with it.

      CoisesC 1 Reply Last reply Reply Quote 0
      • Fuel DZNF
        Fuel DZN @Alan Kilborn
        last edited by

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

        1 Reply Last reply Reply Quote 0
        • CoisesC
          Coises @Fuel DZN
          last edited by

          @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
          • Fuel DZNF
            Fuel DZN @Coises
            last edited by Fuel DZN

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

            PeterJonesP 1 Reply Last reply Reply Quote 0
            • PeterJonesP
              PeterJones @Fuel DZN
              last edited by

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

              print(notepad.getCurrentFilename()

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

              Alan KilbornA 1 Reply Last reply Reply Quote 3
              • Alan KilbornA
                Alan Kilborn @PeterJones
                last edited by

                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…

                PeterJonesP 1 Reply Last reply Reply Quote 2
                • PeterJonesP
                  PeterJones @Alan Kilborn
                  last edited by

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

                  Fuel DZNF 1 Reply Last reply Reply Quote 2
                  • Fuel DZNF
                    Fuel DZN @PeterJones
                    last edited by

                    @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

                    EkopalypseE 1 Reply Last reply Reply Quote 0
                    • EkopalypseE
                      Ekopalypse @Fuel DZN
                      last edited by

                      @Fuel-DZN

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

                      PeterJonesP 1 Reply Last reply Reply Quote 1
                      • PeterJonesP
                        PeterJones @Ekopalypse
                        last edited by PeterJones

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

                        Fuel DZNF 1 Reply Last reply Reply Quote 3
                        • Fuel DZNF
                          Fuel DZN @PeterJones
                          last edited by Fuel DZN

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

                          PeterJonesP 1 Reply Last reply Reply Quote 0
                          • PeterJonesP
                            PeterJones @Fuel DZN
                            last edited by PeterJones

                            <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

                            Fuel DZNF 1 Reply Last reply Reply Quote 2
                            • Fuel DZNF
                              Fuel DZN @PeterJones
                              last edited by

                              @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