Widgets are not showing in child window

Hi,

When I click on a menu item (‘translation’), the class ‘PanelTwo’ does not display the widgets that I have provided. When I test “PanelTwo” as a independent class, it displays. Any pointers to fix the bug is highly appreciated.

Please find the script attached.

Thanks,
Babylakshmi

menu_event.py (3.1 KB)

When I click on a menu item (‘translation’), the class ‘PanelTwo’ does not display the widgets that I have provided. When I test “PanelTwo” as a independent class, it displays. Any pointers to fix the bug is highly appreciated.

Hi. The problem is here:

    wx.Panel.__init__(self, parent=parent)
    panel = wx.Panel(self)

The first line is the panel. The second line creates a second panel, thus the confusion. You should replace all instances of “panel” with “self”, which refers to the instance of the panel class you’ve made.

To see this work quickly, change that second line to:

 panel = self

But for clarity, you should just go and make the 12 or so changes and keep the name as self.

You have one other problem: you are working with a bare frame. You shouldn’t do that. You should create a frame with a panel on it as the background, and then add things to that panel. Because of the way you are doing it, the interior panel doesn’t get a Layout() until you manually resize the frame (try it). I don’t know a good way to do that programmatically other than this hack, which would be called in nucTranslation:

    self.SetSize(wx.Size(self.GetSizeTuple()[0]+1, self.GetSizeTuple()[1]))

But don’t do that–just create a background panel and work on that.

Che

self.SendSizeEvent()

···

On 8/20/12 8:26 AM, C M wrote:

Because of the way you
are doing it, the interior panel doesn't get a Layout() until you
manually resize the frame (try it). I don't know a good way to do that
programmatically other than this hack, which would be called in
nucTranslation:

         self.SetSize(wx.Size(self.GetSizeTuple()[0]+1,
self.GetSizeTuple()[1]))

--
Robin Dunn
Software Craftsman

Dear Che,

Thank you very much. It worked. I will create a panel in the initial frame itself.

Thanks again,
Babylakshmi

···

On Mon, Aug 20, 2012 at 8:56 PM, C M cmpython@gmail.com wrote:

When I click on a menu item (‘translation’), the class ‘PanelTwo’ does not display the widgets that I have provided. When I test “PanelTwo” as a independent class, it displays. Any pointers to fix the bug is highly appreciated.

Hi. The problem is here:

    wx.Panel.__init__(self, parent=parent)
    panel = wx.Panel(self)

The first line is the panel. The second line creates a second panel, thus the confusion. You should replace all instances of “panel” with “self”, which refers to the instance of the panel class you’ve made.

To see this work quickly, change that second line to:

 panel = self

But for clarity, you should just go and make the 12 or so changes and keep the name as self.

You have one other problem: you are working with a bare frame. You shouldn’t do that. You should create a frame with a panel on it as the background, and then add things to that panel. Because of the way you are doing it, the interior panel doesn’t get a Layout() until you manually resize the frame (try it). I don’t know a good way to do that programmatically other than this hack, which would be called in nucTranslation:

    self.SetSize(wx.Size(self.GetSizeTuple()[0]+1, self.GetSizeTuple()[1]))

But don’t do that–just create a background panel and work on that.

Che

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en