Hey all,
I’m using a gridbagsizer for a wx.Dialog, and i’m having some trouble.
When I try to initiate the dialog, my program just freezes up and does nothing, not even sending an error back to the error log.
Here’s the code for my dialog-
···
import wx
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
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](http://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.SetMinSize((300, 150))
self.Centre()
self.Show(True)
def OnFind(self, event):
class FindDialog(wx.Dialog):
def __init__(self, parent):
wx.Dialog.__init__(self, parent, title=("Find"))
sizer = wx.GridBagSizer(hgap=5, vgap=5)
#
stat_text = wx.StaticText(self, 5000, "Enter text to find:")
find_text = wx.TextCtrl(self)
ok_find = wx.Button(self, ID_FIND_B1, 'Find')
cancel_find = wx.Button
(self, ID_FIND_B2, ‘Cancel’)
#
self.Bind(wx.EVT_BUTTON, self.OnFind_F, id=ID_FIND_B1)
self.Bind(wx.EVT_BUTTON, self.OnCancel_F, id=ID_FIND_B2)
#
sizer.Add(stat_text, (0,0), (0,2), wx.EXPAND)
sizer.Add(find_text, (0,3), (0,4), wx.EXPAND)
sizer.Add(ok_find, (0,8), (0,2), wx.EXPAND)
sizer.Add
(cancel_find, (1,8), (1,2), wx.EXPAND)
#
sizer.AddGrowableCol(10)
sizer.AddGrowableRow(2)
#
self.SetSizerAndFit(sizer)
def OnFind_F(self, event):
pass
def OnCancel_F(self, event):
dlg.Destroy()
dlg = FindDialog(None)
dlg.ShowModal()
dlg.Destroy()
def OnReplace(self, event):
class ReplaceDialog(wx.Dialog):
def __init__(self, parent):
wx.Dialog.__init__(self, parent, title=("Replace"))
sizer = wx.BoxSizer(wx.HORIZONTAL)
self.SetSizer(sizer)
dlg = ReplaceDialog(None)
dlg.ShowModal()
dlg.Destroy()
class MyApp(wx.App):
def OnInit(self):
MainWin(None, -1, ‘Ephesus’).Show()
return True
app = MyApp(redirect = True, filename = “error.log”)
app.MainLoop()
Does anybody know why my program is doing this?
Thanks,
Trey