Community
    • Login

    PythonScript 2.0

    Scheduled Pinned Locked Moved Notepad++ & Plugin Development
    19 Posts 4 Posters 4.1k 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.
    • Alan KilbornA
      Alan Kilborn @Ekopalypse
      last edited by

      @Ekopalypse

      The existing Pythonscript plugin is an awesome piece of work. It sure seems like it is worth it for it to continue living on in its current incarnation.

      1 Reply Last reply Reply Quote 6
      • chcgC
        chcg
        last edited by

        Hi, I’m still maintaining pythonscript, but at a rather low rate. Unfortunately @Claudia-Frank left N++, so a big part of contributions is missing. Currently the probably biggest blocker is the compatibility with the new plugin structure required for N++ 7.6.x and PluginAdmin to search/find the python.dll within the plugin dir, see https://github.com/bruderstein/PythonScript/issues/109

        Additionally the next step would be https://github.com/bruderstein/PythonScript/issues/36
        with initial work ar https://github.com/chcg/PythonScript/tree/python36_test

        And additionally get the webpage corrected https://github.com/bruderstein/PythonScript/issues/113

        Meta ChuhM EkopalypseE 2 Replies Last reply Reply Quote 4
        • Meta ChuhM
          Meta Chuh moderator @chcg
          last edited by Meta Chuh

          hi @chcg

          Currently the probably biggest blocker is the compatibility with the new plugin structure required for N++ 7.6.x and PluginAdmin to search/find the python.dll within the plugin dir

          a very, very theoretical quick and dirty plugins admin single target deployment solution for pythonscript, could be:

          • deploy all files, including python.dll, to plugins\PythonScript as single folder target.
          • the plugin itself then checks for existence of instDir\python.dll at every startup.
          • if instDir\python.dll does not exist and notepad++ is not elevated, show an alert popup: “Please restart Notepad++ in Administrator mode, to initialise PythonScript.”
          • if instDir\python.dll does not exist and notepad++ runs elevated, copy plugins\PythonScript\python.dll to instDir\python.dll, and make an alert: “PythonScript initialisation complete. Please restart Notepad++ for the changes to take effect.”
          1 Reply Last reply Reply Quote 3
          • EkopalypseE
            Ekopalypse @chcg
            last edited by Ekopalypse

            @chcg

            thx for all the work you’ve and other have done to keep this alive.
            I’m very much enjoying this plugin.
            Concerning the open issues, at least the second part, custom dialogs,
            could be ignored when including pywin32 into PythonScript.

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

              @Ekopalypse

              custom dialogs…could be ignored when including pywin32 into PythonScript.

              In PS, I do some basic UI stuff that is missing from PS with the techniques shown here:

              http://www.averdevelopment.com/python/EasyDialogs.html

              Granted these are simple standard dialogs, but they fill gap.

              Of course I think the custom dialogs mentioned would be a little different, but I thought I’d share my way of doing File Open, Save etc dialogs in PS when needed.

              EkopalypseE 1 Reply Last reply Reply Quote 3
              • EkopalypseE
                Ekopalypse @Alan Kilborn
                last edited by

                @Alan-Kilborn

                thank you, didn’t know about this site.
                pywin32 advantage is not only the easy to build uis but although the already defined win api functions.
                No need to check and see which function/structure needs to be create how but
                have to admit, that the usage of a few functions is a little bit different to what msdn states.

                I think the custom dialogs mentioned would be a little different,

                For example

                Alan KilbornA 1 Reply Last reply Reply Quote 2
                • Alan KilbornA
                  Alan Kilborn @Ekopalypse
                  last edited by

                  @Ekopalypse

                  Yea, I believe I tried pywin32 at some point and found it strange.

                  1 Reply Last reply Reply Quote 0
                  • chcgC
                    chcg
                    last edited by

                    Example for ctypes:
                    https://github.com/bruderstein/PythonScript/blob/master/scripts/Samples/ReplaceDefaultReplaceDialog.py

                    Currently already available is https://github.com/bruderstein/PythonScript/releases/download/v1.3.0/PythonScript_TclTk_1.3.0.0.zip
                    , see https://github.com/bruderstein/PythonScript/blob/master/scripts/Samples/Sorter.py

                    Alan KilbornA EkopalypseE 2 Replies Last reply Reply Quote 3
                    • Alan KilbornA
                      Alan Kilborn @chcg
                      last edited by

                      @chcg

                      Yea…except that Tk sucks. :(

                      In fact, most Python GUIs except PyQt and wxPython (or whatever it is called now) are so bad they aren’t useful. My opinions only, people, don’t go nuts on me.

                      1 Reply Last reply Reply Quote 1
                      • EkopalypseE
                        Ekopalypse @chcg
                        last edited by Ekopalypse

                        @chcg

                        you are absolutely right and I would say, there is a MUST DO READ those samples
                        for everyone starting investing pythonscript plugin as it nearly covers any aspect of
                        manipulating either notepad++ or scintilla or how to extend npp - as far as I can see.

                        But using ctypes is … uncomfortable, as you have to declare every piece,
                        with the risk of making it wrong. pywin32 did this already for you and Tk is a different beast.
                        I haven’t found out how one can create a Tk UI which can be docked.
                        Please don’t get me wrong - not having pywin32 isn’t a showstopper at all - it is just convenient.
                        And, at any time, one could install a local python and replace the python dll with the one of the local installation and can benefit from pip.

                        Alan KilbornA 1 Reply Last reply Reply Quote 0
                        • Alan KilbornA
                          Alan Kilborn @Ekopalypse
                          last edited by

                          @Ekopalypse

                          You mean like this stuff is “uncomfortable” when doing ctypes?:

                                  self.WNDENUMPROC = ctypes.WINFUNCTYPE(BOOL, HWND, LPARAM)
                                  self.FindWindow = ctypes.windll.user32.FindWindowW
                                  self.EnumChildWindows = ctypes.windll.user32.EnumChildWindows
                                  self.GetClassName = ctypes.windll.user32.GetClassNameW
                                  self.GetWindowText = ctypes.windll.user32.GetWindowTextW
                                  self.GetWindowTextLength = ctypes.windll.user32.GetWindowTextLengthW
                                  self.SetWindowText = ctypes.windll.user32.SetWindowTextW
                                  self.GetACP = ctypes.windll.kernel32.GetACP
                                  self.create_unicode_buffer = ctypes.create_unicode_buffer
                          

                          It really isn’t that bad, once you get some boilerplate (word of the day!) worked up. :)

                          EkopalypseE 1 Reply Last reply Reply Quote 3
                          • EkopalypseE
                            Ekopalypse @Alan Kilborn
                            last edited by Ekopalypse

                            @Alan-Kilborn

                            yes, but the real pain starts when you have to do something like this ;-)

                            LVS_ICON = 0x0
                            LVS_REPORT = 0x1
                            LVS_SMALLICON = 0x2
                            LVS_LIST = 0x3
                            LVS_TYPEMASK = 0x3
                            LVS_SINGLESEL = 0x4
                            LVS_SHOWSELALWAYS = 0x8
                            LVS_SORTASCENDING = 0x10
                            LVS_SORTDESCENDING = 0x20
                            LVS_SHAREIMAGELISTS = 0x40
                            LVS_NOLABELWRAP = 0x80
                            LVS_AUTOARRANGE = 0x100
                            LVS_EDITLABELS = 0x200
                            LVS_OWNERDATA = 0x1000
                            LVS_NOSCROLL = 0x2000
                            LVS_TYPESTYLEMASK = 0xFC00
                            LVS_ALIGNTOP = 0x0
                            LVS_ALIGNLEFT = 0x800
                            LVS_ALIGNMASK = 0xC00
                            LVS_OWNERDRAWFIXED = 0x400
                            LVS_NOCOLUMNHEADER = 0x4000
                            LVS_NOSORTHEADER = 0x8000
                            
                            LVS_EX_GRIDLINES = 0x1
                            LVS_EX_SUBITEMIMAGES = 0x2
                            LVS_EX_CHECKBOXES = 0x4
                            LVS_EX_TRACKSELECT = 0x8
                            LVS_EX_HEADERDRAGDROP = 0x10
                            LVS_EX_FULLROWSELECT = 0x20    # applies to report mode only
                            LVS_EX_ONECLICKACTIVATE = 0x40
                            LVS_EX_TWOCLICKACTIVATE = 0x80
                            LVS_EX_FLATSB = 0x100          # cannot be cleared - Win32 & IE4 and later
                            LVS_EX_REGIONAL = 0x200
                            LVS_EX_INFOTIP = 0x400
                            
                            LVM_FIRST = 0x1000
                            
                            # ListView Messages
                            LVM_GETBKCOLOR = LVM_FIRST + 0
                            LVM_SETBKCOLOR = LVM_FIRST + 1
                            LVM_GETIMAGELIST = LVM_FIRST + 2
                            LVM_SETIMAGELIST = LVM_FIRST + 3
                            LVM_GETITEMCOUNT = LVM_FIRST + 4
                            
                            LVM_DELETEITEM = LVM_FIRST + 8
                            LVM_DELETEALLITEMS = LVM_FIRST + 9
                            LVM_GETCALLBACKMASK = LVM_FIRST + 10
                            LVM_SETCALLBACKMASK = LVM_FIRST + 11
                            LVM_GETNEXTITEM = LVM_FIRST + 12
                            
                            LVM_SETITEMPOSITION = LVM_FIRST + 15
                            LVM_GETITEMPOSITION = LVM_FIRST + 16
                            
                            LVM_HITTEST = LVM_FIRST + 18
                            LVM_ENSUREVISIBLE = LVM_FIRST + 19
                            LVM_SCROLL = LVM_FIRST + 20
                            LVM_REDRAWITEMS = LVM_FIRST + 21
                            LVM_ARRANGE = LVM_FIRST + 22
                            
                            LVM_GETEDITCONTROL = LVM_FIRST + 24
                            
                            LVM_DELETECOLUMN = LVM_FIRST + 28
                            LVM_GETCOLUMNWIDTH = LVM_FIRST + 29
                            LVM_SETCOLUMNWIDTH = LVM_FIRST + 30
                            
                            LVM_GETHEADER = LVM_FIRST + 31
                            
                            LVM_CREATEDRAGIMAGE = LVM_FIRST + 33
                            LVM_GETVIEWRECT = LVM_FIRST + 34
                            LVM_GETTEXTCOLOR = LVM_FIRST + 35
                            LVM_SETTEXTCOLOR = LVM_FIRST + 36
                            LVM_GETTEXTBKCOLOR = LVM_FIRST + 37
                            LVM_SETTEXTBKCOLOR = LVM_FIRST + 38
                            LVM_GETTOPINDEX = LVM_FIRST + 39
                            LVM_GETCOUNTPERPAGE = LVM_FIRST + 40
                            LVM_GETORIGIN = LVM_FIRST + 41
                            LVM_UPDATE = LVM_FIRST + 42
                            LVM_SETITEMSTATE = LVM_FIRST + 43
                            LVM_GETITEMSTATE = LVM_FIRST + 44
                            LVM_SETITEMCOUNT = LVM_FIRST + 47
                            LVM_SORTITEMS = LVM_FIRST + 48
                            LVM_SETITEMPOSITION32 = LVM_FIRST + 49
                            LVM_GETSELECTEDCOUNT = LVM_FIRST + 50
                            LVM_GETITEMSPACING = LVM_FIRST + 51
                            
                            LVM_SETICONSPACING = LVM_FIRST + 53
                            LVM_SETEXTENDEDLISTVIEWSTYLE = LVM_FIRST + 54
                            LVM_GETEXTENDEDLISTVIEWSTYLE = LVM_FIRST + 55
                            LVM_GETSUBITEMRECT = LVM_FIRST + 56
                            LVM_SUBITEMHITTEST = LVM_FIRST + 57
                            LVM_SETCOLUMNORDERARRAY = LVM_FIRST + 58
                            LVM_GETCOLUMNORDERARRAY = LVM_FIRST + 59
                            LVM_SETHOTITEM = LVM_FIRST + 60
                            LVM_GETHOTITEM = LVM_FIRST + 61
                            LVM_SETHOTCURSOR = LVM_FIRST + 62
                            LVM_GETHOTCURSOR = LVM_FIRST + 63
                            LVM_APPROXIMATEVIEWRECT = LVM_FIRST + 64
                            LVM_SETWORKAREA = LVM_FIRST + 65
                            LVM_GETSELECTIONMARK = LVM_FIRST + 66
                            LVM_SETSELECTIONMARK = LVM_FIRST + 67
                            LVM_GETWORKAREA = LVM_FIRST + 70
                            LVM_SETHOVERTIME = LVM_FIRST + 71
                            LVM_GETHOVERTIME = LVM_FIRST + 72
                            
                            LVM_GETITEM = LVM_FIRST + 75
                            LVM_SETITEM = LVM_FIRST + 76
                            LVM_INSERTITEMW = LVM_FIRST + 77
                            LVM_INSERTITEM = LVM_INSERTITEMW
                            LVM_FINDITEMW = LVM_FIRST + 83
                            LVM_FINDITEM = LVM_FINDITEMW
                            LVM_GETSTRINGWIDTHW = LVM_FIRST + 87
                            LVM_GETSTRINGWIDTH = LVM_GETSTRINGWIDTHW
                            LVM_EDITLABELW = LVM_FIRST + 118
                            LVM_EDITLABEL = LVM_EDITLABELW
                            LVM_GETCOLUMNW = LVM_FIRST + 95
                            LVM_GETCOLUMN = LVM_GETCOLUMNW
                            LVM_SETCOLUMNW = LVM_FIRST + 96
                            LVM_SETCOLUMN = LVM_SETCOLUMNW
                            LVM_INSERTCOLUMNW = LVM_FIRST + 97
                            LVM_INSERTCOLUMN = LVM_INSERTCOLUMNW
                            LVM_GETITEMTEXTW = LVM_FIRST + 115
                            LVM_GETITEMTEXT = LVM_GETITEMTEXTW
                            LVM_SETITEMTEXTW = LVM_FIRST + 116
                            LVM_SETITEMTEXT = LVM_SETITEMTEXTW
                            LVM_GETISEARCHSTRINGW = LVM_FIRST + 117
                            LVM_GETISEARCHSTRING = LVM_GETISEARCHSTRINGW
                            LVM_GETBKIMAGEW = LVM_FIRST + 139
                            LVM_SETBKIMAGEW = LVM_FIRST + 138
                            # LVBKIMAGE = LVBKIMAGEW
                            # LPLVBKIMAGE = LPLVBKIMAGEW
                            LVM_SETBKIMAGE = LVM_SETBKIMAGEW
                            LVM_GETBKIMAGE = LVM_GETBKIMAGEW
                            
                            LVCF_FMT = 0x1
                            LVCF_WIDTH = 0x2
                            LVCF_TEXT = 0x4
                            LVCF_SUBITEM = 0x8
                            LVCF_IMAGE = 0x10
                            LVCF_ORDER = 0x20
                            
                            LVCFMT_LEFT = 0x0
                            LVCFMT_RIGHT = 0x1
                            LVCFMT_CENTER = 0x2
                            LVCFMT_JUSTIFYMASK = 0x3
                            LVCFMT_IMAGE = 0x800
                            LVCFMT_BITMAP_ON_RIGHT = 0x1000
                            LVCFMT_COL_HAS_IMAGES = 0x8000
                            
                            LVIF_TEXT = 0x1
                            LVSCW_AUTOSIZE = -1
                            
                            class LVCOLUMN(ctypes.Structure):
                                _fields_ = [('mask',        wintypes.UINT),
                                            ('fmt',         wintypes.INT),
                                            ('cx',          wintypes.INT),
                                            ('pszText',     wintypes.LPWSTR),
                                            ('cchTextMax',  wintypes.INT),
                                            ('iSubItem',    wintypes.INT),
                                            ('iImage',      wintypes.INT),
                                            ('iOrder',      wintypes.INT),
                                            ('cxMin',       wintypes.INT),
                                            ('cxDefault',   wintypes.INT),
                                            ('cxIdeal',     wintypes.INT),
                                            ]
                            
                            class LVITEM(ctypes.Structure):
                                _fields_ = [('mask',       wintypes.UINT),
                                            ('iItem',      wintypes.INT),
                                            ('iSubItem',   wintypes.INT),
                                            ('state',      wintypes.UINT),
                                            ('stateMask',  wintypes.UINT),
                                            ('pszText',    wintypes.LPWSTR),
                                            ('cchTextMax', wintypes.INT),
                                            ('iImage',     wintypes.INT),
                                            ('lParam',     wintypes.LPARAM),
                                            ('iIndent',    wintypes.INT),
                                            ('iGroupId',   wintypes.INT),
                                            ('cColumns',   wintypes.UINT),
                                            ('puColumns',  PUINT),
                                            ('piColFmt',   wintypes.INT),
                                            ('iGroup',     wintypes.INT),
                                            ]
                            
                            class NMITEMACTIVATE(ctypes.Structure):
                                _fields_ = [('hdr',       LPNMHDR),
                                            ('iItem',     wintypes.INT),
                                            ('iSubItem',  wintypes.INT),
                                            ('uNewState', wintypes.UINT),
                                            ('uOldState', wintypes.UINT),
                                            ('uChanged',  wintypes.UINT),
                                            ('ptAction',  wintypes.POINT),
                                            ('lParam',    wintypes.LPARAM),
                                            ('uKeyFlags', wintypes.UINT),
                                            ]
                            LPNMITEMACTIVATE = ctypes.POINTER(NMITEMACTIVATE)
                            ...
                            
                            Alan KilbornA 1 Reply Last reply Reply Quote 2
                            • Alan KilbornA
                              Alan Kilborn @Ekopalypse
                              last edited by Alan Kilborn

                              @Ekopalypse

                              Even that isn’t that bad (all in a separate file that is imported), but I admit it will get a bit tedious when posting scripts here and just going to get the ones needed for the scripts. But overall I find ctypes an amazing thing. And the things that you can use it for in a PS under Notepad++…also amazing. :)

                              But some of the constructs get pretty tricky. I’ve used nulledge to find examples I need.

                              EkopalypseE 1 Reply Last reply Reply Quote 2
                              • EkopalypseE
                                Ekopalypse @Alan Kilborn
                                last edited by

                                @Alan-Kilborn

                                … and just going to get the ones needed for the scripts …

                                at the end that’s exactly where it is handy to have it already defined.
                                Of course, now that I have made it, I can use it but if I want to post a script which
                                would use it, it isn’t that easy anymore as I might have to undo some parts to make it work …

                                But some of the constructs get pretty tricky. I’ve used nulledge to find examples I need.

                                To be honest, if I don’t understand how it should work I’m looking for VB6 examples :-)
                                Most of the time those can be used just by converting and using the right python syntax.

                                Alan KilbornA 1 Reply Last reply Reply Quote 1
                                • chcgC
                                  chcg
                                  last edited by

                                  So if you have some example scripts worth sharing guys you could create a PR at pythonscript and I will merge them.

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

                                    @Ekopalypse

                                    The beauty of the code on nulledge is that it is already in Python. But oops, it appears that nulledge has gone 404. :( Maybe my future needs will have VB6 searches involved.

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