win32all-131 at python.org
mhammond at skippinet.com.au
Sat Apr 29 01:26:12 CEST 2000
"Matthias" <matthias_w at my-deja.com> wrote in message
news:8ecf70$766$1 at nnrp1.deja.com...
> Hy Mark :-)
> Are the sources anywhere ??
> (You told me to include the new startup-code in my project)
Only from CVS - available via the web at
David Ascher creates a nightly tarball:
> I have the following problems:
> (1) I want to use python-win for the interface in my programm, but it
> is most important to hide the interactive windows for most of the users
> (they should not know that they are powered by python), and
Ultimately you will end up with your own "intpyapp.py" (hopefully named
something else!) This gives you full control over the app - eg, do you
want an editor, interactive, debugger, etc.
> (2) I have a conflict with my main windows. In the InitInstance() from
> my application the pyglue-code creates a new window and now visualc
> does not know which of them is the main window. (e.g. I open
> splittst.py in my window, have to choose debug (go is disabled ??) from
> the python-window and the splitter - test window is a mdi-child in my
> own main window again (little confuseing, isn't it ;-) - the menus are
> quite the same, but in my window all python-related menus are diasbled)
You _definately_ need a new intpyapp.py - either drop the creation of the
main frame from your C++ code, or from the custom app.py
Here is some code taken from a real project that does the exact same
thing - the MFC app creates the frame, and Pythonwin attaches to it!
"The main startup code for my custom Pythonwin App."
debugging = win32ui.GetProfileVal("Whatever", "Debugging", 0)
# Keep this as short as possible, cos error output is only redirected to
# the interactive window if this runs OK.
# Keep as much logic in imported modules, as errors in these are much
# the messages go somewhere!
# Redirect to the debugging device!
print "Starting up:", sys.path
from pywin.framework import intpyapp, app
from pywin.mfc import afxres
f = win32ui.GetMainFrame()
# Probably dont want most of these if you are not exposing the
# interactive Window, or any Python IDE features.
self.ddeServer = None
# Create the taskbar icon if necessary.
# Attach to (NOT CREATE) the main frame.
# This code assumes the MFC app has ALREADY created the main frame
# so win32ui.GetMainFrame() will return this window. By passing this
window to the
# app.MainFrame() constructor, we attach to the existing window.
self.frame = app.MainFrame(win32ui.GetMainFrame())
# However, in this example, our main app does not create the status bar!
from editor import editor
# Allow HTML files to be edited by Pythonwin!
# ('something' is a module that exposes an MFC resource ID - there
# should be a string, icon, menu etc entries in the resources for this
self.AddDocTemplate( editor.EditorTemplate(something.IDR_HTML_FILE) )
# Create the interactive window if we want.
from pywin.framework import interact
# Load internal modules we need (if you want :-)
# Minimise the interactive window.
interactiveFrame = interact.edit.currentView.GetParentFrame()
if interactiveFrame != win32ui.GetMainFrame():
appobj = MyApp()
More information about the Python-list