Menu

Run Python scripts with wxPython (wxWidgets)

NppExec
cioma
2009-11-09
2013-05-21
  • cioma

    cioma - 2009-11-09

    I use NPP as an IDE for Python. And I use NppExec to run scripts directly from NPP, highlight script syntax and runtime errors (if any) and link errors to a line of code.

    Some time ago I started using wxPython GUI library and faced problems with running such scripts from within NppExec.

    If I run this (in NppExec prompt):

        python -t -B -u "$(FULL_CURRENT_PATH)"

    …then GUI part of wxPython is not shown. I guess the reason is that wxPython requires a "real" console buffer and NppExec doesn't provide that.

    If I just run script over NPP "Run" dialog (no NppExec) then GUI is shown but if there are errors there is no way to easily relate them to line of code in NPP.

    So I found this solution to work:

    1.When creating wxPython application in the script make sure it's STDOUT is **not** redirected:

        app = App(redirect=False)

    2.Run in NppExec:

        cmd /C python -t -B -u "$(FULL_CURRENT_PATH)"

    Voila! We have both wxPython GUI running and its STDOUT redirected to NppExec

     
  • DV

    DV - 2009-11-10

    Thank you for the information.

     
  • wonea

    wonea - 2010-01-29

    Marvellous, this helped me run my C# application, thanks a bunch!

     
  • Markus

    Markus - 2012-01-04

    Thanks a lot, cioma, this helped for my python problem (console input/output) , too.

     

Log in to post a comment.