Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

Question regarding Callback & [NOTIFICATION.FILEOPENED]

Help
2013-06-02
2013-08-18
  • Sascha Offe
    Sascha Offe
    2013-06-02

    Hi there,

    first of all, thanks for PythonScript, great plug-in!

    I've written a script that scans for ".LOG" at the beginning of a text file, and if it's found, appends a timestamp to the file. It works fine if I call the scipt manually and also if I put it directly in my custom startup.py.

    But my plan was actually to use the callback feature, so that each opened file will be automatically checked -- but either I misunderstood the use of Callback or I'm missing something else.

    import datetime
    
    def updateLog():
            [...]
    
    notepad.callback(updateLog, [NOTIFICATION.FILEOPENED])
    

    A test with "if" returns true, so the registration seems to work.
    I've also change the initialisation from LAZY to ATSTARTUP.
    But nothing happens when I open my test file, neither via double click nor File -> Open...

    Using
    - Notepad++ 6.3.2 (Unicode)
    - PythonScript 0.9.2

    Thanks in advance for your help!

    s.

     
    • I'm not in a place to check at the moment, but I think your callback
      function needs an argument (just one called, for example "args").
      The console may show a better error message.

       
  • Sascha Offe
    Sascha Offe
    2013-08-18

    You were right, the argument was missing; thanks.