473,320 Members | 1,988 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

MFC application and Python

Hi.

I'm working on a C++ Win32 MFC application and I want to move as much
code as possible to Python.

At first I wanted to use a Python GUI package and keep the critical
components (performance wise) in C++ extensions. The application must
have a native look so this leaves us with only two choices.

wxPython is way too bloated (9 MB on disk, 20MB! in memory for basic
stuff) and people say buggy. PythonWin is nice and small, but lacks
some features, like GDI support.

So this gave me the idea of doing it the other way around: having a
skeleton application which handles Win32 messages and the application
threads and this will call into Python for the logic, which will call
back into C++ for the critical operations and GUI updates.

Since I'm new to Python, can you see any problems with this approach?
Is there a better way to do it?

A specific question: is it ok if C++ calls into Python which calls
into C++ which calls again into Python and so on let's say 5 levels
deep as reaction to a Win32 message or a thread unblocking?

And another one: What are the ways to call into Python? I know of
PyRun_, PyObject_Call and boost::python::call.

Regards,
Adal Chiriliuc

Jul 18 '05 #1
3 2766
Adal Chiriliuc wrote:
I'm working on a C++ Win32 MFC application and I want to move as much
code as possible to Python.

At first I wanted to use a Python GUI package and keep the critical
components (performance wise) in C++ extensions. The application must
have a native look so this leaves us with only two choices.

wxPython is way too bloated (9 MB on disk, 20MB! in memory for basic
stuff) and people say buggy. PythonWin is nice and small, but lacks
some features, like GDI support.


If you're already coding in C++, and think wxPython is too bloated, and
you were prepared to use pythonwin (win32gui) if only it had more
features, then I'd say stick with C++, it's not much more difficult than
using win32gui and will allow you to make your application as fast and
lightweight as you like.
But if you seriously want to switch to Python, then I'd reconsider
wxpython. It is the best python GUI toolkit for your specific purposes
I think. It isn't buggy.
Jul 18 '05 #2
Adal Chiriliuc:
wxPython is way too bloated (9 MB on disk, 20MB! in memory for basic
stuff) and people say buggy. PythonWin is nice and small, but lacks
some features, like GDI support.
At least some of GDI is available. I wrote some of the printing code
inside PythonWin and there are calls like dc.GetTextMetrics, dc.SetMapMode,
and dc.TextOut.
So this gave me the idea of doing it the other way around: having a
skeleton application which handles Win32 messages and the application
threads and this will call into Python for the logic, which will call
back into C++ for the critical operations and GUI updates.


Venster and ctypes may be of interest. Venster doesn't appear very active
but was updated as recently as January.

Neil
Jul 18 '05 #3
Adal wrote:
I'm working on a C++ Win32 MFC application and I want to move as much
code as possible to Python.

At first I wanted to use a Python GUI package and keep the critical
components (performance wise) in C++ extensions. The application must
have a native look so this leaves us with only two choices.

wxPython is way too bloated (9 MB on disk, 20MB! in memory for basic
stuff) and people say buggy. PythonWin is nice and small, but lacks
some features, like GDI support.


You might consider using ctypes as it lets you call pretty much any Windows
API. If you are familiar with rather low-level Win32 GUI programming, Venster
(a pure Python package built on top of ctypes) provides a good head start - at
my company we've used it in several places and have found it to be a good
alternative when app size is an issue, or when we're not really interested in
anything but a Win32 deployment.

-Dave
Jul 18 '05 #4

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

Similar topics

4
by: indru | last post by:
Hi all, I am new to Python programming. I am from C,C++,Perl background. I am quite convinced by the possibilities python as a very high level language is offering. I am seriously thinking of...
8
by: Susanne | last post by:
Hello! In have embedded python into my MFC application. It works fine using the PyRun_SimpleString method, giving it a string with some simple commands. When i am using PyRun_SimpleFile...
1
by: Gernot Hillier | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi! I'm the developer of a Linux ISDN application which uses embedded Python for controlling the communication. It starts several threads (i.e....
10
by: John Underwood | last post by:
Can I use python23_d and python23 to develop an extension for a commercial application uses python22.dll? (Providing that I do not use any new features found only in 2.3.) I would bulld version...
2
by: Miki Tebeka | last post by:
Hello All, I have a funny problem: An embedded python application is working fine on a "clean" computer. When it runs on a computer with python installed (the very same computer used to...
14
by: Wolfgang Keller | last post by:
Hello, as a non-developer I am currently participating in an industrial "research" project to develop a so-called "web application". This application serves at the same time as middleware to...
1
by: Andrew McCall | last post by:
Hi Folks, I am building an application under multiple OS's, and I wanted to give my application For example, the test application I am working on is a calculator and I would like to have a...
4
by: MrBlueSky | last post by:
Hello! I've just finished working on my first Python app (a Tkinter-based program that displays the content of our application log files in graphical format). It was a great experience that's...
4
by: Julian | last post by:
Hi, first of all, I have to say I am new to Python. I have been working with a finite element analysis program written in c++. now, I am trying to 'rebuild' this code (possibly a full re-write)...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.