Dynamically add panels to wx.Dialog

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Dynamically add panels to wx.Dialog

daniel d
Hello, 

My program frame contains panels which I would like to either copy or move into a wx.Dialog. When I try to do this, the panel does not get placed inside the wx.Dialog window. 

In my example app I click "Add Panel" 3 times and it looks like this

<a imageanchor="1" href="about:invalid#zClosurez" style="margin-left: 1em; margin-right: 1em;">three_panels_in_program_frame.png

When I click "Open Dialog", it is supposed to create a new dialog and put TEST PANEL 0 in the dialog. Instead, TEST PANEL 0 appears to be placed inside the program frame. 

<a imageanchor="1" href="about:invalid#zClosurez" style="margin-left: 1em; margin-right: 1em;">panel_not_in_dialog.png


How can I get TEST PANEL 0 inside the dialog window? I have attached all the code in dialog_test.zip. 


My main module code is below. See zip file for GUI setup. 


import wx
import gui

class ProgramFrame(gui.MainFrame):
def __init__(self,parent):
gui.MainFrame.__init__(self,parent)
self.num_main_panels = 0
self.panels = []

def OnButtonClick_addPanel( self, event ):
panel = gui.TestPanel(self)
panel.m_staticText_idx.SetLabelText(str(self.num_main_panels))
self.num_main_panels = self.num_main_panels +1
sizer = self.m_main_panel.GetSizer()
sizer.Add(panel, 1, wx.EXPAND|wx.ALL|wx.ALIGN_CENTER_HORIZONTAL, 5 )
self.panels.append(panel)
panel.Show()
# sizer.Layout()
self.Fit()
self.Layout()
event.Skip()

def OnButtonClick_openDialog( self, event ):
dlg = gui.TestDialog(self)
sizer = dlg.GetSizer()
sizer.Add(self.panels[0], 1, wx.EXPAND|wx.ALL|wx.ALIGN_CENTER_HORIZONTAL, 5 )
dlg.Fit()
dlg.Layout()
dlg.Show()
event.Skip()

# -----------------------------------------------------------------------------
if __name__ == '__main__':

# create app
app = wx.App(False)
# create frame
frame = ProgramFrame(None)
# show the frame
frame.Show(True)
app.MainLoop()





--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

dialog_test.zip (43K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

AW: [GREY] [wxPython-users] Dynamically add panels to wx.Dialog

Thomas

Von: [hidden email] [mailto:[hidden email]] Im Auftrag von daniel d
Gesendet: Donnerstag, 30. August 2018 00:14
An: wxPython-users <[hidden email]>
Betreff: [GREY] [wxPython-users] Dynamically add panels to wx.Dialog

 

Hello, 

 

My program frame contains panels which I would like to either copy or move into a wx.Dialog. When I try to do this, the panel does not get placed inside the wx.Dialog window. 

 

In my example app I click "Add Panel" 3 times and it looks like this

<a href="about:invalid#zClosurez">three_panels_in_program_frame.png

When I click "Open Dialog", it is supposed to create a new dialog and put TEST PANEL 0 in the dialog. Instead, TEST PANEL 0 appears to be placed inside the program frame. 

<a href="about:invalid#zClosurez">panel_not_in_dialog.png

 

How can I get TEST PANEL 0 inside the dialog window? I have attached all the code in dialog_test.zip. 

 

My main module code is below. See zip file for GUI setup. 

 

import wx
import gui

class ProgramFrame(gui.MainFrame):
   
def __init__(self,parent):
        gui.MainFrame.
__init__(self,parent)
       
self.num_main_panels = 0
       
self.panels = []
   
    
def OnButtonClick_addPanel( self, event ):
        panel = gui.TestPanel(
self)
        panel.m_staticText_idx.SetLabelText(
str(self.num_main_panels))
       
self.num_main_panels = self.num_main_panels +1
       
sizer = self.m_main_panel.GetSizer()
        sizer.Add(panel,
1, wx.EXPAND|wx.ALL|wx.ALIGN_CENTER_HORIZONTAL, 5 )
       
self.panels.append(panel)
        panel.Show()
       
# sizer.Layout()
       
self.Fit()
       
self.Layout()
        event.Skip()
       
    
def OnButtonClick_openDialog( self, event ):
        dlg = gui.TestDialog(
self)
        sizer = dlg.GetSizer()
        sizer.Add(
self.panels[0], 1, wx.EXPAND|wx.ALL|wx.ALIGN_CENTER_HORIZONTAL, 5 )
        dlg.Fit()
        dlg.Layout()
        dlg.Show()
        event.Skip()

# -----------------------------------------------------------------------------
if __name__ == '__main__':

   
# create app
   
app = wx.App(False)
   
# create frame
   
frame = ProgramFrame(None)
   
# show the frame
   
frame.Show(True)
    app.MainLoop()

 

 

 

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.