I’m having trouble understanding the relationship between a child and parent window. I’m just trying to create a dialog box that is spawned from a “main” frame that has to be dismissed before the user can access the “main” frame again. Using the Dialog_Modal style (in wxGlade) doesn’t seem to do it…
I thought the code below would create a parent and a child relationship, but I’m obviously wrong. What am I missing??
Thanks everyone,
Adrian
import wx
class MyMainFrame(wx.Frame):
def init(self, *args, **kwds):
# begin wxGlade: MyMainFrame.__init__
kwds["style"] = wx.DEFAULT_FRAME_STYLE
wx.Frame.__init__(self, *args, **kwds)
self.btnShowDialog = wx.Button(self, -1, "Show Dialog Box")
self.__set_properties()
self.__do_layout()
self.Bind(wx.EVT_BUTTON, self.showDialog, self.btnShowDialog)
# end wxGlade
def __set_properties(self):
# begin wxGlade: MyMainFrame.__set_properties
self.SetTitle("frame_1")
# end wxGlade
def __do_layout(self):
# begin wxGlade: MyMainFrame.__do_layout
sizer_1 = wx.BoxSizer(wx.VERTICAL)
sizer_2 = wx.BoxSizer(wx.VERTICAL)
sizer_2.Add(self.btnShowDialog, 0, wx.ALL, 3)
sizer_1.Add(sizer_2, 1, wx.EXPAND, 0)
self.SetSizer(sizer_1)
sizer_1.Fit(self)
self.Layout()
# end wxGlade
def showDialog(self, event): # wxGlade: MyMainFrame.<event_handler>
MySecondaryDialog(self).Show()
end of class MyMainFrame
class MySecondaryDialog(wx.Dialog):
def init(self, *args, **kwds):
# begin wxGlade: MySecondaryDialog.__init__
kwds["style"] = wx.DEFAULT_DIALOG_STYLE
wx.Dialog.__init__(self, *args, **kwds)
self.__set_properties()
self.__do_layout()
# end wxGlade
def __set_properties(self):
# begin wxGlade: MySecondaryDialog.__set_properties
self.SetTitle("dialog_1")
# end wxGlade
def __do_layout(self):
# begin wxGlade: MySecondaryDialog.__do_layout
self.Layout()
# end wxGlade
end of class MySecondaryDialog
if name == “main”:
app = wx.PySimpleApp(0)
wx.InitAllImageHandlers()
frame_1 = MyMainFrame(None, -1, "")
app.SetTopWindow(frame_1)
frame_1.Show()
app.MainLoop()