What's wrong with this code in Boa: [def OnMenuHelpAboutMenu(self, event) works fine if I use it to open file etc.., but won't work for Dialog2] Thanks!

#Boa:Frame:Frame2
import wx
#import Dialog2
def create(parent):
    return Frame2(parent)
.
class Frame2(wx.Frame):
.
    def OnMenuHelpAboutMenu(self, event):
        # if hasattr(sys, 'debugger_control'):     
        # sys.debugger_control.set_traceable() 
        dlg = Dialog2.Dialog2(self)
        try:
            dlg.ShowModal()
        finally:
            dlg.Destroy()  #  event.Skip()

Which calls Dialog2.py

#Boa:Dialog:Dialog2

import wx

def create(parent):
    return Dialog2(parent)

[wxID_DIALOG2, wxID_DIALOG2BUTTON1, wxID_DIALOG2STATICBITMAP1, 
 wxID_DIALOG2STATICTEXT1, wxID_DIALOG2STATICTEXT2, 
] = [wx.NewId() for _init_ctrls in range(5)]

class Dialog2(wx.Dialog):
    def _init_ctrls(self, prnt):
        # generated method, don't edit
        wx.Dialog.__init__(self, id=wxID_Dialog2, name='', parent=prnt,
              pos=wx.Point(604, 204), size=wx.Size(400, 398),
              style=wx.DEFAULT_DIALOG_STYLE, title='About NoteBook')
        self.SetClientSize(wx.Size(392, 364))

        self.staticText1 = wx.StaticText(id=wxID_DIALOG2STATICTEXT1,
              label='NoteBook - Simple Text Editor', name='staticText1',
              parent=self, pos=wx.Point(80, 0), size=wx.Size(251, 23),
              style=wx.ALIGN_CENTRE)
        self.staticText1.SetFont(wx.Font(14, wx.SWISS, wx.NORMAL, wx.NORMAL,
              False, 'Tahoma'))

        self.staticText2 = wx.StaticText(id=wxID_DIALOG2STATICTEXT2,
              label='This is my first Boa Contstructor application',
              name='staticText2', parent=self, pos=wx.Point(40, 56),
              size=wx.Size(309, 19), style=0)
        self.staticText2.SetBackgroundColour(wx.Colour(255, 0, 0))
        self.staticText2.SetFont(wx.Font(12, wx.SWISS, wx.NORMAL, wx.NORMAL,
              False, 'Tahoma'))

        self.staticBitmap1 = wx.StaticBitmap(bitmap=wx.Bitmap(u'C:/Program Files/Python26/Boa Constructor/Practice/Boa.jpg',
              wx.BITMAP_TYPE_JPEG), id=wxID_DIALOG2STATICBITMAP1,
              name='staticBitmap1', parent=self, pos=wx.Point(80, 112),
              size=wx.Size(236, 157), style=0)

        self.button1 = wx.Button(id=wxID_DIALOG2BUTTON1, label='Close',
              name='button1', parent=self, pos=wx.Point(168, 312),
              size=wx.Size(75, 23), style=0)
        self.button1.Bind(wx.EVT_BUTTON, self.OnButton1Button,
              id=wxID_DIALOG2BUTTON1)

    def __init__(self, parent):
        self._init_ctrls(parent)

    def OnButton1Button(self, event):
        self.Close()  # event.Skip()

It helps when you tell us what "doesn't work". Do you get an error, does your computer light on fire, what?

Okay, I used the BOA constructor IDE to create two files. One file Frame1.py contains the meat:

#Boa:Frame:Frame1
# saved as Frame1.py

import wx
# user added
# Dialog1.py was separately created with New
import Dialog1

def create(parent):
    return Frame1(parent)

[wxID_FRAME1, wxID_FRAME1BUTTON1, wxID_FRAME1PANEL1, 
] = [wx.NewId() for _init_ctrls in range(3)]

class Frame1(wx.Frame):
    def _init_ctrls(self, prnt):
        # generated method, don't edit
        wx.Frame.__init__(self, id=wxID_FRAME1, name='', parent=prnt,
              pos=wx.Point(331, 157), size=wx.Size(400, 489),
              style=wx.DEFAULT_FRAME_STYLE, title='Frame1')
        self.SetClientSize(wx.Size(392, 455))

        self.panel1 = wx.Panel(id=wxID_FRAME1PANEL1, name='panel1', parent=self,
              pos=wx.Point(56, 72), size=wx.Size(200, 100),
              style=wx.TAB_TRAVERSAL)

        self.button1 = wx.Button(id=wxID_FRAME1BUTTON1, label='button1',
              name='button1', parent=self.panel1, pos=wx.Point(56, 32),
              size=wx.Size(75, 23), style=0)
        self.button1.Bind(wx.EVT_BUTTON, self.OnButton1Button,
              id=wxID_FRAME1BUTTON1)

    def __init__(self, parent):
        self._init_ctrls(parent)

    def OnButton1Button(self, event):
        # user added
        dlg = Dialog1.Dialog1(self)
        dlg.ShowModal()
        dlg.Destroy()
        
        event.Skip()


# added this via Edit/Add module runner
# much easier to test things this way
if __name__ == '__main__':
    app = wx.PySimpleApp()
    frame = create(None)
    frame.Show()

    app.MainLoop()

Then I created a separate file called Dialog1.py that I can import into the Frame.py:

#Boa:Dialog:Dialog1
# saved as Dialog1.py

import wx

def create(parent):
    return Dialog1(parent)

[wxID_DIALOG1] = [wx.NewId() for _init_ctrls in range(1)]

class Dialog1(wx.Dialog):
    def _init_ctrls(self, prnt):
        # generated method, don't edit
        wx.Dialog.__init__(self, id=wxID_DIALOG1, name='', parent=prnt,
              pos=wx.Point(339, 154), size=wx.Size(400, 489),
              style=wx.DEFAULT_DIALOG_STYLE, title='Dialog1')
        self.SetClientSize(wx.Size(392, 455))
        self.SetBackgroundColour(wx.Colour(255, 255, 0))

    def __init__(self, parent):
        self._init_ctrls(parent)

The whole thing works just fine. When in doubt, do some simple stuff to test things out.

This question has already been answered. Start a new discussion instead.