Question concerning cross platform usage differences

-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. :wink:

Joe

Joseph D. Poirier
DSP Software
IMN, Nokia Inc.
6000 Connection Drive
Irving, TX 75039

972-894-5320

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 was a little unclear on my point. What I meant was that one way top
address cross-platfrom differences is to put in a:

if Platfrom == X:
  do this
elif Plafrom == Y:
  do this other thing
etc.

type contruct. I have never had to do this, and instead have found a way
that the exact same code works on all platforms (that I've tested
anyway). And the result is ussually better than if I'd just used the
above construct.

> 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:

Well, I thought it was a simple and straight forward approach, especially after
comparing this implementation to some others. :wink:

It is simple and straightforward, but not so flexible. In general,
mixing multiple concepts as one attribute feels like a bad idea to me:
i.e. the frame's name and the name of the file being edited. Those are
two different things, even if they happen to be the same in the current
impimentation. You've also kind of mixed GUI and non-GUI concepts, which
might bite you later. Here are some issues I see right away:

- What if you want to have multiple frames all providing a view of the
same file?

- What if the full path to the file is very long...and wouldn't fit in
the frame title?

Just my $.02

-Chris

···

joseph.poirier@nokia.com wrote:

--
Christopher Barker, Ph.D.
Oceanographer
                                        
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov