-Chris wrote
wxPython is very good at cross platform code, but there still are
differences, of course. I have always found that there is a cross
platform way to everything I try, but the first thing that works on one
platform is not always it. However the cross platform way is usually
better in other respects as well.
One of the main requirements is that the app be cross platform, therefore,
I'll change anything that's not. I'll be more careful from this point
on concerning these types of issues.
Perhaps you could add this to this Wiki Page (which you should read
anyway):
Thanks for the link, I'll definitely check it out.
Because it's more powerful and flexible that way..All of a Frame's
children are not neccessarily the same type or have the same function.
When you add a second type,. you'll be glad you've kept track of them
yourself.
Actually, it was quite easy to keep track of the (dynamic) children
(aka opened files) in this case. E.g., on Windows, 'any' children within
the parent are appended to a single list of children.
I would set an opened document's frame names equal to the document's
path + filename (e.g., "c:\temp\source.py").
So processing a child, whether by reference or name, was quite easy:
For an active frame
···
-------------------
- The frame with focus was the active child, so GetActiveChild() gave me
the pointer. GetActiveChild().GetName() gave me the name (obviously)
but it also gave me the path and filename of the document; because
the frame's name was set to the path and file name when the document
was opened.
For a non active frame
----------------------
- If the user selected say, a file from the favorites menu or from the
project tree, I'd check whether or not the file was currently open
first. And because I saved the favorites and project items as path +
filename, all that needed to be done was to iterate through the
child list (created using GetChildren()) and look for a frame name
hit:
(simple scenario)
user_selected_item = "c:\temp\source.py"
for child in self.GetChildren():
if child.GetName() == user_selected_item
"then the file is already open"
# so activate the child to set focus
else:
#
f.open(user_selected_item, rb)
...etc....etc.....
Of course there are several other ways to use this idiom.
The only difference on Linux was that the GetClientWindow() had to be used,
rather than GetChildren(). But it did have the benefit of only returning a list of
(dynamic) children, i.e., a list that didn't include any other types of children.
Whereas on Windows, all the children, regardless of type, were returned in
one conglomerated list.
Well, I thought it was a simple and straight forward approach, especially after
comparing this implementation to some others.
Joe
Joseph D. Poirier
DSP Software
IMN, Nokia Inc.
6000 Connection Drive
Irving, TX 75039
972-894-5320