About Embedding PyWin or wxPython

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mr. Roboto

    #1

    About Embedding PyWin or wxPython


    Folks: I want to embark on a project to add Python (actually, wxPython
    or PythonWin) to a new Windows app I want to start writing soon.
    Essentially, I want to take VB6 (or pos Delphi) and construct the app
    framework/core functionality using one of those languages, then extend
    the app w/ Python, the same way one can extend the MS Office apps
    using VBA. The core Python docs provide the fundamental info one
    needs to get started. But, I've been looking for some pointers to
    articles/web pages that will bootstrap the effort, so I won't have to
    completely reinvent the wheel. So far, the c.l.p ngroup traffic (and
    the web in general) that speaks to this subject is apparently pretty
    sparse. Since I'm a one-man show, it would be helpful if anyone could
    offer pointers to sites/pages/books that address some of these issues:

    1) To COM or not ? From an implementation standpoint, it seems
    worthwhile to build the host app as a series of COM objects, which
    could then be ref'd/manipulated via external Python code. Not sure if
    this makes sense from a performance-perspective, but I doubt the apps
    I'm thinking about (mostly desk accessory utils kinda, sorta) are
    going to be compute-intensive at all.

    2) SWIG or not ? Have never used it, but know that SWIG has been
    ref'd many times in the ngroup as an tool for facilitating the use of
    Python as an embedded language. Is SWIG worth the effort for a
    relatively small (<10 KLOC) app ?

    3) Handling exceptions. I want to start from Day One with a sensible
    approach to debugging and testing both host objects and external
    scripts.

    4) Deployment. Size (30 - 50MB for wxPython or PyWin alone) and a
    silent install of either pkg prior to installing the host app.

    Regardless of the conversation in this group, I plan to get started in
    the next few days. This is how I'm currently looking at the above
    issues:

    1) COM: Yes, since COM seems like an easy fit w/o writing lotsa
    glue code because of built-in support via PyWin

    2) SWIG: Not for a 1st cut, at least not to get one's feet wet, so
    to speak

    3) Exceptions: No clue. Need to closely read Extending/Embedding
    Python for more guidance

    4) Deployment: Bite the disk space bullet and use PyWin or wxPython as
    is

    Anyway, that's the beginning of the conversation. If you have any
    observations or suggestions, please feel free. Later...MR

  • Steve Holden

    #2
    Re: About Embedding PyWin or wxPython

    Mr. Roboto wrote:
    Folks: I want to embark on a project to add Python (actually, wxPython
    or PythonWin) to a new Windows app I want to start writing soon.
    Essentially, I want to take VB6 (or pos Delphi) and construct the app
    framework/core functionality using one of those languages, then extend
    the app w/ Python, the same way one can extend the MS Office apps
    using VBA. The core Python docs provide the fundamental info one
    needs to get started. But, I've been looking for some pointers to
    articles/web pages that will bootstrap the effort, so I won't have to
    completely reinvent the wheel. So far, the c.l.p ngroup traffic (and
    the web in general) that speaks to this subject is apparently pretty
    sparse. Since I'm a one-man show, it would be helpful if anyone could
    offer pointers to sites/pages/books that address some of these issues:
    >
    You almost certainly would regard a copy of Hammind and Robinson's
    "Python Programming on Win32" as remarkable value for money. It's an
    axcellent book, and even has examples fo how you can make a VBA
    application scriptable in Python.

    If you are more interested in developing functionality that
    experimenting, buying that book would save to a huge amount of time.

    regards
    Steve
    --
    Steve Holden +44 150 684 7255 +1 800 494 3119
    Holden Web LLC/Ltd http://www.holdenweb.com
    Skype: holdenweb http://holdenweb.blogspot.com
    Recent Ramblings http://del.icio.us/steve.holden

    Comment

    • Simon Hibbs

      #3
      Re: About Embedding PyWin or wxPython


      Have you considered IronPython?

      This is of course only an option if you're prepared to code in VB.NET
      or C# instead of VB6 or Delphi, but it would provide seamless
      integratioon between your Python code and the rest of your app and
      would not require an external graphics library - although you would
      need to distribute the .NET and IronPython runtimes.

      Multiple-language and library integration is after all what .NET is all
      about.


      Simon Hibbs

      Comment

      • Mr. Roboto

        #4
        Re: About Embedding PyWin or wxPython

        Steve: Thanx for reminding me. I have that book around here
        *someplace*. Never finished it, but will dig it out pronto. As you
        so aptly point out, I want to develop more than experiment and who
        better to learn from than the author of PyWin itself....

        Steve Holden wrote:
        You almost certainly would regard a copy of Hammind and Robinson's
        "Python Programming on Win32" as remarkable value for money. It's an
        axcellent book, and even has examples fo how you can make a VBA
        application scriptable in Python.
        >
        If you are more interested in developing functionality that
        experimenting, buying that book would save to a huge amount of time.
        >
        regards
        Steve

        Comment

        • Mr. Roboto

          #5
          Re: About Embedding PyWin or wxPython

          Simon: Good idea, but I'm not yet .NET-compatible and can't handle
          that learning curve in addition to everything else. IronPython is an
          option I hadn't considered, but yours is a good idea for the next
          project....

          Simon Hibbs wrote:
          Have you considered IronPython?
          >
          This is of course only an option if you're prepared to code in VB.NET
          or C# instead of VB6 or Delphi, but it would provide seamless
          integratioon between your Python code and the rest of your app and
          would not require an external graphics library - although you would
          need to distribute the .NET and IronPython runtimes.

          Comment

          • Philippe Martin

            #6
            Re: About Embedding PyWin or wxPython

            Mr. Roboto wrote:
            >
            Folks: I want to embark on a project to add Python (actually, wxPython
            or PythonWin) to a new Windows app I want to start writing soon.
            Essentially, I want to take VB6 (or pos Delphi) and construct the app
            framework/core functionality using one of those languages, then extend
            the app w/ Python, the same way one can extend the MS Office apps
            using VBA. The core Python docs provide the fundamental info one
            needs to get started. But, I've been looking for some pointers to
            articles/web pages that will bootstrap the effort, so I won't have to
            completely reinvent the wheel. So far, the c.l.p ngroup traffic (and
            the web in general) that speaks to this subject is apparently pretty
            sparse. Since I'm a one-man show, it would be helpful if anyone could
            offer pointers to sites/pages/books that address some of these issues:
            >
            1) To COM or not ? From an implementation standpoint, it seems
            worthwhile to build the host app as a series of COM objects, which
            could then be ref'd/manipulated via external Python code. Not sure if
            this makes sense from a performance-perspective, but I doubt the apps
            I'm thinking about (mostly desk accessory utils kinda, sorta) are
            going to be compute-intensive at all.
            >
            2) SWIG or not ? Have never used it, but know that SWIG has been
            ref'd many times in the ngroup as an tool for facilitating the use of
            Python as an embedded language. Is SWIG worth the effort for a
            relatively small (<10 KLOC) app ?
            >
            3) Handling exceptions. I want to start from Day One with a sensible
            approach to debugging and testing both host objects and external
            scripts.
            >
            4) Deployment. Size (30 - 50MB for wxPython or PyWin alone) and a
            silent install of either pkg prior to installing the host app.
            >
            Regardless of the conversation in this group, I plan to get started in
            the next few days. This is how I'm currently looking at the above
            issues:
            >
            1) COM: Yes, since COM seems like an easy fit w/o writing lotsa
            glue code because of built-in support via PyWin
            >
            2) SWIG: Not for a 1st cut, at least not to get one's feet wet, so
            to speak
            >
            3) Exceptions: No clue. Need to closely read Extending/Embedding
            Python for more guidance
            >
            4) Deployment: Bite the disk space bullet and use PyWin or wxPython as
            is
            >
            Anyway, that's the beginning of the conversation. If you have any
            observations or suggestions, please feel free. Later...MR

            Do you have major performances issues ? why not write everything in
            Python/WxPython ?


            I used to write my applications in VB6 with python com objects ... and
            decided there was no gain there.

            Regards,

            Philippe




            Comment

            • Mr. Roboto

              #7
              Re: About Embedding PyWin or wxPython

              Phillipe: Actually, it's not performance of the core app that concerns
              me. I'm thinking more about UI/form *design* productivity. I've done
              a lot of Access work over the years and while the stand-alone VB form
              designer isn't quite as thorough, it's still one of the slickest out
              there. Unfortunately, there's no designer for PyWin and wxPython's
              XRC is nice but not in the same league as what can be done w/ Delphi
              or VB. Yes, I'm aware that wxWidgets has a real form designer, but
              that's yet another story, for another day.

              Making XRC into a more fully-featured tool (more on par w/ the
              aforementioned) is a way nice project unto itself, but not right now.
              However, the desk accessory I've mentioned is an excellent 1st step
              towards *possibly* doing something much bigger....

              Philippe Martin wrote:
              Do you have major performances issues ? why not write everything in
              Python/WxPython ?
              >
              >
              I used to write my applications in VB6 with python com objects ... and
              decided there was no gain there.
              >
              Regards,
              >
              Philippe

              Comment

              • Philippe Martin

                #8
                Re: About Embedding PyWin or wxPython

                Mr. Roboto wrote:
                Phillipe: Actually, it's not performance of the core app that concerns
                me. I'm thinking more about UI/form *design* productivity. I've done
                a lot of Access work over the years and while the stand-alone VB form
                designer isn't quite as thorough, it's still one of the slickest out
                there. Unfortunately, there's no designer for PyWin and wxPython's
                XRC is nice but not in the same league as what can be done w/ Delphi
                or VB. Yes, I'm aware that wxWidgets has a real form designer, but
                that's yet another story, for another day.
                >
                Making XRC into a more fully-featured tool (more on par w/ the
                aforementioned) is a way nice project unto itself, but not right now.
                However, the desk accessory I've mentioned is an excellent 1st step
                towards *possibly* doing something much bigger....
                >
                Philippe Martin wrote:
                >Do you have major performances issues ? why not write everything in
                >Python/WxPython ?
                >>
                >>
                >I used to write my applications in VB6 with python com objects ... and
                >decided there was no gain there.
                >>
                >Regards,
                >>
                >Philippe
                I personally _really_ like wxDesigner (http://www.roebling.de/) and as
                under VB6, I always avoided having the tables filled for me (bound forms if
                I recall) I have not found my productivity go down ... but then again, I
                never was a VB expert.

                1)
                As others have said, it is very easy to make a Python com object (thank you
                Mark!) - and as long as Windows keeps supporting COM ....

                2)
                I chose the COM option

                3)
                If your script does not handle exceptions, you'll have a fairly cryptic VB
                dialog box telling you about your python com object unhapiness - I find it
                more easy to handle the expections in the script

                4)
                Yes it takes space - I have an application that uses Python, wxPython,
                Gadfly, pyserial, HTMLGen ..... and the whole thing takes 120M

                I used visual studio to buld a single install for everything- works well.


                The one open issue I have about wxPython in a com object is how the main
                event loop (in your core application) will react if a com object with GUI
                pops-up ... never tried it.

                Regards,

                Philippe






                Comment

                Working...