Basic Question on MenuCommand with python script

Help
2014-02-25
2014-02-26
  • Bart Nederland

    Bart Nederland - 2014-02-25

    sorry in advance if this is very basic. I have researched around and cannot find an answer.
    I am adapting a python script I found elsewhere here to batch convert lineendings.
    I wanted to run a two step process:
    1) save with mac lineendings and save
    2) save with windows lineendings and save and close

    I could not find correct syntax for flyout options, so:

    notepad.MenuCommand("Edit", "EOL Conversion", "Mac Format")
    notepad.save()
    notepad.MenuCommand("Edit", "EOL Conversion", "Windows Format")
    notepad.save()
    notepad.close()

    can someone advise what I am doing wrong here.
    Very much appreciated in advance

     
  • Dave Brotherstone

    There are three ways to do what you want:

    1) With runMenuCommand, which takes the menu name, and the menu item

    notepad.runMenuCommand("EOL Conversion", "Mac Format")
    

    2) With menuCommand, which takes the menu item ID (one of the MENUCOMMAND constants)

    notepad.menuCommand(MENUCOMMAND.FORMAT_TOMAC)
    

    3) Use the explicit setFormatType method, which takes the FORMATTYPE enum

    notepad.setFormatType(FORMATTYPE.MAC)
    

    Option 1 may or may not work with version 0.9.2. There was an issue it for various combinations of menu options. Version 1.0 is due out any moment which fixes that (probably next week, but not 100% sure). The syntax is that the first parameter is the menu that contains the option (whether it's a top level menu like "Edit", or a submenu like "EOL Conversion"). The other two options should be identical.

    Hope that helps.
    Dave.

     
  • Bart Nederland

    Bart Nederland - 2014-02-26

    HI Dave

    thanks very much for the feedback.
    Neither option are working for me however.
    I have 0.9.2. installed so I will keep an eye out for the 1.0 release next week and see if that solves the issue.
    One other strange thing I had was when I installed the plug-in with my latest version of Notepad++ 6.5.3 Unicode, I received a warning for the plugin being ANSI and incompatible even though I chose the correct option. I then installed and have been testing the above scripts with an older version of Notepad++ 6.1.3 Unicode (but I get no warnings for ANSI on this version).
    Another script that I run and from which the above was adapted to change encoding, works fine so in principle the plugin is working on the 6.1.3 version.

    cheers
    Bart

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks