473,594 Members | 2,833 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

Jul 25 '06 #1
7 2309
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

Jul 25 '06 #2

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

Jul 25 '06 #3
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
Jul 25 '06 #4
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.
Jul 25 '06 #5
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


Jul 25 '06 #6
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
Jul 25 '06 #7
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


Jul 25 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1677
by: Tinmean K.H.Liu | last post by:
Hi! I install wxPython under WinXP when I want to use some simple sample, there is an error message: File "C:\Python22\Lib\site-packages\Pythonwin\pywin\framework\scriptutils.py",line 301, in RunScript exec codeObject in __main__.__dict__ File "C:\Documents and Settings\Tinmean\temp_desktop\python_0921\wx1.py", line 3, in ? from frame import Frame ImportError: No module named frame
5
3510
by: Max Powers | last post by:
I've spent an interesting day searching the web for help with calling OCaml functions from a python program and have come to the newsgroup for some advice (unfortunately I'm learning both languages at the same time, so maybe I've missed something obvious!) The situation is this; I've got a large legacy program that is written in ocaml, within which there's a parser. I'd like to be able to call that parser from my python program (actually...
0
1575
by: The Jetman | last post by:
I'm trying to port PyWin into a limited version of Windows XP, called BartPE. Essentially, it's a matter of taking the installed elements of most WinApps (ie. registry settings and files) and insert them into the framework defined by BartPE's author. I "think" I've got it going, except for a single PyWin error: 'No module named pywin.framework.startup.' That is, when I launch PyWin, I get an error dialog w/ this message. I suspect it...
2
3174
by: dr_tyson | last post by:
I am trying to embed images into a wxPython app (created using Boa Constructor), but have not been able to do so. I know how to embed plots, but images seem to be a problem. I've tried using code analogous to the example given at the Matplotlib website to no avail. If anybody has been successful at this could you please post some sample code? That would be greatly appreciated. Thanks! Randy
6
1832
by: Charles Krug | last post by:
Here's the deal: I've a dead-simple command-line program I'm using to test things that I can't (for various reasons) test in the IDE. Here's a do-nothing subset that shows the idea: # insanely simply command interpreter import Commands import sys
2
3797
by: Janto Dreijer | last post by:
I'm writing a Linux filemanager using wxPython. I'd like to embed a bash console inside it. I have found the Logilab pyqonsole (http://www.logilab.org/projects/pyqonsole), but it uses PyQT. Does anyone know how to do this from wx? Is it possible to embed a PyQT widget inside wxPython? Thanks! Janto
1
1745
by: Mr. Roboto | last post by:
I need PyWin under the covers, that is, to install it as part of an application, but in such a way that it isn't visible to users. I'm concerned about a so-called "power-user", seeing the Python directory and/or the corresponding entry in the 'Add/Remove Programs' list, breaking my app by uninstalling what he/she thinks is removing an 'unnecessary program.' Unfortunately, I don't see any installer scripts, like for Inno Setup or NSIS...
3
3829
by: gopython | last post by:
Hi all, Python:2.5 OS: Windows XP I have posted couple questions regarding the wxPython. Since I am still a newbie to Python, wxPython makes more sense to me than pyWin for gui programming. But recently my friend ask me for help on pywin32 gui programming. There is one thing that throw us off (Note. Both of us don't have any mfc background). When the "DoModal" is called, the gui will stay in loop. It is different when the "CreateWindow"...
0
3391
by: Soren | last post by:
Hi, I've been trying to embed matplotlib in wxpython. I want to be able to put a figure (axes) in a wx.Panel and place it somewhere in my GUI. The GUI should have other panels with buttons etc. that can control the output on the figure. I've been looking at the examples from the matplotlib website, but can't seem to get it to work.. Does anyone here have experience in embedding matplotlib in wxpython?
0
7936
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
7874
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8241
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
7997
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8227
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5402
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3893
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2383
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1203
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.