file names as command line argument

Developers
Steffen
2006-12-25
2013-04-26
  • Steffen
    Steffen
    2006-12-25

    The following small changes to drpython.py(w) provide the ability to give the names of files to edit as command line arguments.
    Among other benefits, this allows a smooth integration into Windows.
    I hope, they'll make it into the official sources.

    Steffen

    --- P:\Programme\drpython\drpython.py    Mon Dec 25 22:07:17 2006
    +++ drpython.py    Mon Dec 25 22:29:53 2006
    @@ -3969,6 +3969,22 @@
             event.Skip()

    -if __name__ == '__main__':
    +def main():
         app = DrApp(0)
    +    # load files from command line parameters
    +    if len(sys.argv) > 1:
    +       app.frame.OpenFile(sys.argv[1], False)
    +       if len(sys.argv) > 2:
    +             for f in sys.argv[2:]:
    +                 try:
    +                        print "loading file %r" % f
    +                  app.frame.OpenFile(f, True)
    +              except:
    +                  print "Error opening file %r" % f
    +    #
         app.MainLoop()
    +
    +
    +if __name__ == '__main__':
    +    main()
    +   

    --- P:\Programme\drpython\drpython.pyw    Mon Dec 25 22:07:17 2006
    +++ drpython.pyw    Mon Dec 25 22:29:25 2006
    @@ -33,5 +33,4 @@

    if __name__ == '__main__':
         import drpython
    -    app = drpython.DrApp(0)
    -    app.MainLoop()
    +    drpython.main()

     
    • Hello Steffen, thank you for your patch.
      This is very useful and I will integrate it into the next version.