Child frame will not show until a dialog is created

Recently I’ve moved a large app I’ve
been developing to wxPython 3.0.1.1 cocoa 3.0.1.1on OSX, and I’m left
with one pernicious problem: child frames I create will not
be visible. The only way I’ve found to make it appear is to create a
dialog, and when the dialog is created, both the dialog and the child
frame will appear. After a dialog has been closed, subsequent child
frames will appear instantly.

What makes this behavior so pernicious
is that it’s inconsistent. For example, I don’t usually see it on my
main development system (OSX 10.9.5), but if I bundle this with
py2app and run it on another test system (OSX 10.8.6) it happens most
of the time (although the py2app bundle still works fine on the
10.9.5 system, so it doesn’t seem to be related to py2app). I’ve
attached a small demo ffd03.py that demonstrates this problem with
the child frame on the 10.8.6 system. To test this click the “frame” button, and if the child frame does not appear, click the “dialog” button and see them both appear.

On the 10.9.5 system, I can get this
same behavior, where the child frame won’t initially show, if I
create a modal dialog in App.OnInit. And, surprisingly, running this
on the 10.8.6 system cures the problem there (though this opens a
whole new can of worms, and sometimes leads to the program hanging,
as in,
https://groups.google.com/forum/#!topic/wxpython-users/3z0pvPHAGt0 ).
I’ve attached this version as ffd04.py, so if ffd03.py doesn’t show
the problem on your system, maybe ffd04.py will.

In all of these, when the child frame
in not visible, I find that all calls to the child frame methods:
IsShown(), IsShownOnScreen(), IsMaximized(), and IsActive(), all give
the same values as for a frame that is actually visible.

So far I’ve tested this with the
2.9.5.0, 3.0.0.0, and 3.0.1.1 cocoa versions and I see this behavior
with all of them, but I don’t see it with 2.8.12.1 carbon. I haven’t
tried this yet in Windows, but because this seems to be produced at
the osx carbon/cocoa split, I’m guessing it an osx thing.

Any fixes, work-arounds, explanations,
suggestions, or ideas would be greatly appreciated.

Thanks,

Tom

ffd03.py (996 Bytes)

ffd04.py (1.32 KB)

While I do not have access to a device with OS-X I did review the code examples provided. I noticed a couple of things that I would personally change myself which may or may not be part of the issue.

First I would suggest changing the line: self.frame = MyChildFrame(self)

To something like: self._frame - MyChildFrame(self) or self.child_frame = MyChildFrame(self)

Or something similar to those examples. I suggest this primarily as a way to differentiate between your main frame and any child frames created by the function.

The next suggestion is to change where the .Show() is placed. When I tried calling self.Show() in my child frame subclass on an older version of Ubuntu I ran into some issues. I ended up placing the .Show() in the function creating the frame instance, for example (showing both suggestions):

def _MakeFrame(self, evt):

self.child_frame = MyChildFrame(self)

self.child_frame.Show()

Hope this helps.

···

On Wednesday, November 19, 2014 12:17:18 PM UTC-5, Tom wrote:

Recently I’ve moved a large app I’ve
been developing to wxPython 3.0.1.1 cocoa 3.0.1.1on OSX, and I’m left
with one pernicious problem: child frames I create will not
be visible. The only way I’ve found to make it appear is to create a
dialog, and when the dialog is created, both the dialog and the child
frame will appear. After a dialog has been closed, subsequent child
frames will appear instantly.

What makes this behavior so pernicious
is that it’s inconsistent. For example, I don’t usually see it on my
main development system (OSX 10.9.5), but if I bundle this with
py2app and run it on another test system (OSX 10.8.6) it happens most
of the time (although the py2app bundle still works fine on the
10.9.5 system, so it doesn’t seem to be related to py2app). I’ve
attached a small demo ffd03.py that demonstrates this problem with
the child frame on the 10.8.6 system. To test this click the “frame” button, and if the child frame does not appear, click the “dialog” button and see them both appear.

On the 10.9.5 system, I can get this
same behavior, where the child frame won’t initially show, if I
create a modal dialog in App.OnInit. And, surprisingly, running this
on the 10.8.6 system cures the problem there (though this opens a
whole new can of worms, and sometimes leads to the program hanging,
as in,
https://groups.google.com/forum/#!topic/wxpython-users/3z0pvPHAGt0 ).
I’ve attached this version as ffd04.py, so if ffd03.py doesn’t show
the problem on your system, maybe ffd04.py will.

In all of these, when the child frame
in not visible, I find that all calls to the child frame methods:
IsShown(), IsShownOnScreen(), IsMaximized(), and IsActive(), all give
the same values as for a frame that is actually visible.

So far I’ve tested this with the
2.9.5.0, 3.0.0.0, and 3.0.1.1 cocoa versions and I see this behavior
with all of them, but I don’t see it with 2.8.12.1 carbon. I haven’t
tried this yet in Windows, but because this seems to be produced at
the osx carbon/cocoa split, I’m guessing it an osx thing.

Any fixes, work-arounds, explanations,
suggestions, or ideas would be greatly appreciated.

Thanks,

Tom

Thanks for the input and ideas, Mike.

I did tried the changes that you suggest but unfortunately the problems are still there. I’ve attached the two modified versions.

ffd03_01.py (1.03 KB)

ffd04_01.py (1.41 KB)

···

On Thursday, November 20, 2014 1:36:09 PM UTC-5, Mike Stover wrote:

While I do not have access to a device with OS-X I did review the code examples provided. I noticed a couple of things that I would personally change myself which may or may not be part of the issue.

First I would suggest changing the line: self.frame = MyChildFrame(self)

To something like: self._frame - MyChildFrame(self) or self.child_frame = MyChildFrame(self)

Or something similar to those examples. I suggest this primarily as a way to differentiate between your main frame and any child frames created by the function.

The next suggestion is to change where the .Show() is placed. When I tried calling self.Show() in my child frame subclass on an older version of Ubuntu I ran into some issues. I ended up placing the .Show() in the function creating the frame instance, for example (showing both suggestions):

def _MakeFrame(self, evt):

self.child_frame = MyChildFrame(self)

self.child_frame.Show()

Hope this helps.

On Wednesday, November 19, 2014 12:17:18 PM UTC-5, Tom wrote:

Recently I’ve moved a large app I’ve
been developing to wxPython 3.0.1.1 cocoa 3.0.1.1on OSX, and I’m left
with one pernicious problem: child frames I create will not
be visible. The only way I’ve found to make it appear is to create a
dialog, and when the dialog is created, both the dialog and the child
frame will appear. After a dialog has been closed, subsequent child
frames will appear instantly.

What makes this behavior so pernicious
is that it’s inconsistent. For example, I don’t usually see it on my
main development system (OSX 10.9.5), but if I bundle this with
py2app and run it on another test system (OSX 10.8.6) it happens most
of the time (although the py2app bundle still works fine on the
10.9.5 system, so it doesn’t seem to be related to py2app). I’ve
attached a small demo ffd03.py that demonstrates this problem with
the child frame on the 10.8.6 system. To test this click the “frame” button, and if the child frame does not appear, click the “dialog” button and see them both appear.

On the 10.9.5 system, I can get this
same behavior, where the child frame won’t initially show, if I
create a modal dialog in App.OnInit. And, surprisingly, running this
on the 10.8.6 system cures the problem there (though this opens a
whole new can of worms, and sometimes leads to the program hanging,
as in,
https://groups.google.com/forum/#!topic/wxpython-users/3z0pvPHAGt0 ).
I’ve attached this version as ffd04.py, so if ffd03.py doesn’t show
the problem on your system, maybe ffd04.py will.

In all of these, when the child frame
in not visible, I find that all calls to the child frame methods:
IsShown(), IsShownOnScreen(), IsMaximized(), and IsActive(), all give
the same values as for a frame that is actually visible.

So far I’ve tested this with the
2.9.5.0, 3.0.0.0, and 3.0.1.1 cocoa versions and I see this behavior
with all of them, but I don’t see it with 2.8.12.1 carbon. I haven’t
tried this yet in Windows, but because this seems to be produced at
the osx carbon/cocoa split, I’m guessing it an osx thing.

Any fixes, work-arounds, explanations,
suggestions, or ideas would be greatly appreciated.

Thanks,

Tom

I’ll see about getting access to an OS-X device to test your code on. In the meantime I recommend using the event watcher from the Widget Inspection Tool and make sure the event for creating the frame isn’t getting swallowed up somewhere. Information on WIT is available Right Here, I have also attached a modified version of ffd03_01.py with WIT already imported and set to load on start.

ffd03_01_WIT.py (1.15 KB)

···

On Wednesday, November 19, 2014 12:17:18 PM UTC-5, Tom wrote:

Recently I’ve moved a large app I’ve
been developing to wxPython 3.0.1.1 cocoa 3.0.1.1on OSX, and I’m left
with one pernicious problem: child frames I create will not
be visible. The only way I’ve found to make it appear is to create a
dialog, and when the dialog is created, both the dialog and the child
frame will appear. After a dialog has been closed, subsequent child
frames will appear instantly.

What makes this behavior so pernicious
is that it’s inconsistent. For example, I don’t usually see it on my
main development system (OSX 10.9.5), but if I bundle this with
py2app and run it on another test system (OSX 10.8.6) it happens most
of the time (although the py2app bundle still works fine on the
10.9.5 system, so it doesn’t seem to be related to py2app). I’ve
attached a small demo ffd03.py that demonstrates this problem with
the child frame on the 10.8.6 system. To test this click the “frame” button, and if the child frame does not appear, click the “dialog” button and see them both appear.

On the 10.9.5 system, I can get this
same behavior, where the child frame won’t initially show, if I
create a modal dialog in App.OnInit. And, surprisingly, running this
on the 10.8.6 system cures the problem there (though this opens a
whole new can of worms, and sometimes leads to the program hanging,
as in,
https://groups.google.com/forum/#!topic/wxpython-users/3z0pvPHAGt0 ).
I’ve attached this version as ffd04.py, so if ffd03.py doesn’t show
the problem on your system, maybe ffd04.py will.

In all of these, when the child frame
in not visible, I find that all calls to the child frame methods:
IsShown(), IsShownOnScreen(), IsMaximized(), and IsActive(), all give
the same values as for a frame that is actually visible.

So far I’ve tested this with the
2.9.5.0, 3.0.0.0, and 3.0.1.1 cocoa versions and I see this behavior
with all of them, but I don’t see it with 2.8.12.1 carbon. I haven’t
tried this yet in Windows, but because this seems to be produced at
the osx carbon/cocoa split, I’m guessing it an osx thing.

Any fixes, work-arounds, explanations,
suggestions, or ideas would be greatly appreciated.

Thanks,

Tom

I forgot to mention that I had made a few other tweaks other than the Widget Inspection Tool. I also changed a few lines to use super. Such as:

super(MyFrame, self).init(parent, size=(200, 200), *args, **kw)

and

super(MyChildFrame, self).init(parent, *args, **kw)

Again, these are personal preferences and can easily be updated for Python 3.

-MikeS

···

On Wednesday, November 19, 2014 12:17:18 PM UTC-5, Tom wrote:

Recently I’ve moved a large app I’ve
been developing to wxPython 3.0.1.1 cocoa 3.0.1.1on OSX, and I’m left
with one pernicious problem: child frames I create will not
be visible. The only way I’ve found to make it appear is to create a
dialog, and when the dialog is created, both the dialog and the child
frame will appear. After a dialog has been closed, subsequent child
frames will appear instantly.

What makes this behavior so pernicious
is that it’s inconsistent. For example, I don’t usually see it on my
main development system (OSX 10.9.5), but if I bundle this with
py2app and run it on another test system (OSX 10.8.6) it happens most
of the time (although the py2app bundle still works fine on the
10.9.5 system, so it doesn’t seem to be related to py2app). I’ve
attached a small demo ffd03.py that demonstrates this problem with
the child frame on the 10.8.6 system. To test this click the “frame” button, and if the child frame does not appear, click the “dialog” button and see them both appear.

On the 10.9.5 system, I can get this
same behavior, where the child frame won’t initially show, if I
create a modal dialog in App.OnInit. And, surprisingly, running this
on the 10.8.6 system cures the problem there (though this opens a
whole new can of worms, and sometimes leads to the program hanging,
as in,
https://groups.google.com/forum/#!topic/wxpython-users/3z0pvPHAGt0 ).
I’ve attached this version as ffd04.py, so if ffd03.py doesn’t show
the problem on your system, maybe ffd04.py will.

In all of these, when the child frame
in not visible, I find that all calls to the child frame methods:
IsShown(), IsShownOnScreen(), IsMaximized(), and IsActive(), all give
the same values as for a frame that is actually visible.

So far I’ve tested this with the
2.9.5.0, 3.0.0.0, and 3.0.1.1 cocoa versions and I see this behavior
with all of them, but I don’t see it with 2.8.12.1 carbon. I haven’t
tried this yet in Windows, but because this seems to be produced at
the osx carbon/cocoa split, I’m guessing it an osx thing.

Any fixes, work-arounds, explanations,
suggestions, or ideas would be greatly appreciated.

Thanks,

Tom