[Tutor] Visual Basic AND Python, is there a way to...

Jeff Shannon jeff@ccvcorp.com
Mon, 22 Apr 2002 10:16:59 -0700


> "Robert Garber" <garber@centralcatholic.org> wrote:
>
> OK hear goes an off the wall question. I started with python and loved it...came very easy to me. I moved on to visual basic. I like the way you can set up the GUI first and the methods used in doing so...seems very intuitive. i like the dea of writing code for each part of the form and object in it...is there a way to use VB6.0 and ptyhon together... set up the GUi and use python to write the code for each event in the app?or is there an IDE out ther that wroks like VB 6.0 for setting up and writting GUI apps? I have to admit I never messed with tkinter, but i know it sets up the GUI with code instead  the 'drag and drop' methods in VB6.0...i like writting code with python..it is the first language i have learned and would like to find a way to use both together if possible.\

Yes, you can use them together, though it's not quite as trivial as you might be thinking.  The best way would probably be to use Python to create COM objects which expose methods that do whatever event processing you want, and use VB to create the GUI.  You'll need to have stub event handlers in VB, whose purpose is to call the Python COM methods and then display the results in whatever way is appropriate.  The Python COM framework is part of Mark Hammond's Win32 extensions, available as a win32all package from www.python.org, or bundled with ActiveState's ActivePython distribution.  If you want to go this route, I strongly recommend picking up the book "Python Programming on Win32", by Mark Hammond and Andy Robinson.  It includes a lengthy example of doing exactly what you're
asking about.

Another option is to check out Boa Constructor (http://boa-constructor.sourceforge.net), which is a GUI builder for Python and the wxPython GUI framework.  I haven't tried it myself, but I gather that the intent, at least, is similar to VB's IDE.

Jeff Shannon
Technician/Programmer
Credit International