Show(True) on different platforms

Below is a slightly simplified extract from the VPython library that creates a window into which a 3D OpenGL canvas can be inserted, along with widgets such as buttons and sliders (_plat is “Windows” or “Macintosh” or “Unix”). The attributes self.panel and self.menubar are referenced by the user’s program to set up widgets. I find experimentally that on Linux “self.win.Show(True)” must precede the panel and menubar setups, whereas on a Mac “self.win.Show(True)” must follow the panel and menubar setups, and on Windows it can either precede or follow. I don’t have a mental model of how these things work together. Can someone comment on these platform differences? Are these differences likely to be the same with future changes in wxPython? Thanks.

self.win = _wx.Frame(None, -1, title, pos=(x, y),

size=(width, height), style=_wx.DEFAULT_FRAME_STYLE)

self.win.Bind(_wx.EVT_CLOSE, self._OnExitApp)

self.win.Bind(_wx.EVT_MOVE, self._OnMove)

self.win.Bind(_wx.EVT_SIZE, self._OnSize)

if _plat != ‘Macintosh’: self.win.Show(True)

self.panel = _wx.Panel(self.win)

self.menubar = _wx.MenuBar()

menu = _wx.Menu()

item = menu.Append(_wx.ID_EXIT, “E&xit\tCtrl-Q”, “Exit demo”)

self.win.Bind(_wx.EVT_MENU, self._OnExitApp, item)

self.menubar.Append(menu, “&File”)

self.win.SetMenuBar(self.menubar)

if _plat == ‘Macintosh’: self.win.Show(True)

return

Bruce Sherwood wrote:

Below is a slightly simplified extract from the VPython library that
creates a window into which a 3D OpenGL canvas can be inserted, along
with widgets such as buttons and sliders (_plat is "Windows" or
"Macintosh" or "Unix"). The attributes self.panel and self.menubar are
referenced by the user's program to set up widgets. I find
experimentally that on Linux "self.win.Show(True)" must precede the
panel and menubar setups, whereas on a Mac "self.win.Show(True)" must
follow the panel and menubar setups, and on Windows it can either
precede or follow.

And what happens if you do it in the other order? The only thing I can think of that might make a difference there is when the first size event is delivered, perhaps causing the initial layout to not happen automatically. If that's the case then you can probably work around that by calling SendSizeEvent when you are done setting up everything.

In general you should not need to call Show at any different time on different platforms, but when the frame is created with it's initial size like you've done then you may need to help the layout happen after the contents of the frame have also been created.

···

--
Robin Dunn
Software Craftsman

What happens if I do things in the other order is that the window simply hangs, with nothing displayed in the window.

Thanks for the tips.

···

On Fri, Mar 1, 2013 at 11:25 PM, Robin Dunn robin@alldunn.com wrote:

Bruce Sherwood wrote:

Below is a slightly simplified extract from the VPython library that

creates a window into which a 3D OpenGL canvas can be inserted, along

with widgets such as buttons and sliders (_plat is “Windows” or

“Macintosh” or “Unix”). The attributes self.panel and self.menubar are

referenced by the user’s program to set up widgets. I find

experimentally that on Linux “self.win.Show(True)” must precede the

panel and menubar setups, whereas on a Mac “self.win.Show(True)” must

follow the panel and menubar setups, and on Windows it can either

precede or follow.

And what happens if you do it in the other order? The only thing I can think of that might make a difference there is when the first size event is delivered, perhaps causing the initial layout to not happen automatically. If that’s the case then you can probably work around that by calling SendSizeEvent when you are done setting up everything.

In general you should not need to call Show at any different time on different platforms, but when the frame is created with it’s initial size like you’ve done then you may need to help the layout happen after the contents of the frame have also been created.

Robin Dunn

Software Craftsman

http://wxPython.org

You received this message because you are subscribed to a topic in the Google Groups “wxPython-users” group.

To unsubscribe from this topic, visit https://groups.google.com/d/topic/wxpython-users/wlYpsVJKTYU/unsubscribe?hl=en-US.

To unsubscribe from this group and all its topics, send an email to wxpython-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.

Clarification: What happens with the “wrong” order is that Show(True) doesn’t return.

···

On Sat, Mar 2, 2013 at 9:10 PM, Bruce Sherwood bruce.sherwood@gmail.com wrote:

What happens if I do things in the other order is that the window simply hangs, with nothing displayed in the window.

Thanks for the tips.

On Fri, Mar 1, 2013 at 11:25 PM, Robin Dunn robin@alldunn.com wrote:

Bruce Sherwood wrote:

Below is a slightly simplified extract from the VPython library that

creates a window into which a 3D OpenGL canvas can be inserted, along

with widgets such as buttons and sliders (_plat is “Windows” or

“Macintosh” or “Unix”). The attributes self.panel and self.menubar are

referenced by the user’s program to set up widgets. I find

experimentally that on Linux “self.win.Show(True)” must precede the

panel and menubar setups, whereas on a Mac “self.win.Show(True)” must

follow the panel and menubar setups, and on Windows it can either

precede or follow.

And what happens if you do it in the other order? The only thing I can think of that might make a difference there is when the first size event is delivered, perhaps causing the initial layout to not happen automatically. If that’s the case then you can probably work around that by calling SendSizeEvent when you are done setting up everything.

In general you should not need to call Show at any different time on different platforms, but when the frame is created with it’s initial size like you’ve done then you may need to help the layout happen after the contents of the frame have also been created.

Robin Dunn

Software Craftsman

http://wxPython.org

You received this message because you are subscribed to a topic in the Google Groups “wxPython-users” group.

To unsubscribe from this topic, visit https://groups.google.com/d/topic/wxpython-users/wlYpsVJKTYU/unsubscribe?hl=en-US.

To unsubscribe from this group and all its topics, send an email to wxpython-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.