Trouble with find/replace closing

Hey all,

I’m trying to work on a dialog for find and replace, but I’m having some trouble with it closing. When I close the find or replace dialog, and then try to open another one, I get an error from wx saying that I already have a dialog open and am not supposed to be able to open another one. I don’t actually have the find and replace functions down yet, but just a message saying what to do. Here’s my code:

···

#!/usr/bin/python

#FILE FOR TESTING OUT FIND/REPLACE

import wx
import os
import sys

ID_FIND = 301
ID_FIND_B1 = 302

ID_FIND_B2 = 303
ID_FIND_TX = 304
ID_REPLACE = 351
ID_RPLC_B1 = 352
ID_RPLC_B2 = 353
ID_TEXTBOX = 401

class MainWin(wx.Frame):
def init(self, parent, id, title):
wx.Frame._init
_(self, parent, id, title, size=(850, 450))
#Menubar
menubar = wx.MenuBar()
test = wx.Menu()
find = wx.MenuItem(test, ID_FIND, ‘Find’, ‘Find something.’)
test.AppendItem(find)
replace = wx.MenuItem(test, ID_REPLACE, ‘Replace’, ‘Replace something.’)
test.AppendItem(replace)
menubar.Append(test, ‘&Test’)
self.SetMenuBar(menubar)
self.sb = self.CreateStatusBar()
self.code = wx.TextCtrl(self, ID_TEXTBOX, size=(200, 130), style=wx.TE_MULTILINE)
self.code.SetFont(wx.Font
(11, wx.FONTFAMILY_MODERN, wx.NORMAL, wx.NORMAL))
self.Bind(wx.EVT_MENU, self.OnFind, id=ID_FIND)
self.Bind(wx.EVT_MENU, self.OnReplace, id=ID_REPLACE)
self.Bind(wx.EVT_FIND, self.DoFind)

    self.Bind(wx.EVT_FIND_NEXT, self.DoFind)
    self.Bind(wx.EVT_FIND_REPLACE, self.DoReplace)
    self.Bind(wx.EVT_FIND_REPLACE_ALL, self.DoReplaceAll)
    self.SetMinSize((300, 150))
    self.Centre()
    self.Show(True)
def OnFind(self, event):
    data = wx.FindReplaceData()
    dlg = wx.FindReplaceDialog(self, data, "Find")
    dlg.data = data
    dlg.Show

()
def DoFind(self, event):
findmsg = wx.MessageDialog(None, ‘Find event activated’, ‘Find’, wx.OK)
findmsg.ShowModal()
find_string = event.GetFindString()
find_flags = event.GetFlags()
#self.SetSelection(from, to)
def DoReplace(self, event):
findmsg = wx.MessageDialog(None, ‘Replace event activated’, ‘Replace’, wx.OK)
findmsg.ShowModal
()
def DoReplaceAll(self, event):
findmsg = wx.MessageDialog(None, ‘Replace all event activated’, ‘Replace all’, wx.OK)
findmsg.ShowModal()
def OnReplace(self, event):

    data = wx.FindReplaceData()
    dlg = wx.FindReplaceDialog(self, data, "Replace", wx.FR_REPLACEDIALOG)
    dlg.data = data
    dlg.Show()

class MyApp(wx.App):
def OnInit(self):

    MainWin(None, -1, 'Ephesus').Show()
    return True

app = MyApp()
app.MainLoop()

and yes, I know I shouldn’t use the MyApp thing, but for some reason when I try to use:

if name == “main”:

(i believe that’s what it is…), I get an error.

Thanks for any help.