M
Miki Tebeka
Hello All,
I have a frame that contains a panel and several buttons.
I'd like to make one of the button the default button but
self.SetDefaultItem(btn) or btn.SetFocus() don't work. The item in
focus is a text control inside the panel.
Any Ideas? (see short example below)
Thanks.
Miki
--- btn.py ---
import wx
class P(wx.Panel):
def __init__(self, parent, id=-1):
wx.Panel.__init__(self, parent, id)
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(wx.TextCtrl(self, -1, size=(250, -1), value="XXX"))
self.SetAutoLayout(True)
self.SetSizer(sizer)
sizer.Fit(self)
class F(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, -1, "Test Frame")
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(P(self), 0, wx.EXPAND)
b = wx.Button(self, wx.NewId(), "Quit")
wx.EVT_BUTTON(self, b.GetId(), self.on_quit)
sizer.Add(b, 0, wx.EXPAND)
self.SetDefaultItem(b)
b.SetFocus()
self.SetAutoLayout(True)
self.SetSizer(sizer)
sizer.Fit(self)
def on_quit(self, e):
self.Close(True)
def main():
app = wx.PySimpleApp()
f = F()
f.Show(True)
app.MainLoop()
if __name__ == "__main__":
main()
--- btn.py ---
I have a frame that contains a panel and several buttons.
I'd like to make one of the button the default button but
self.SetDefaultItem(btn) or btn.SetFocus() don't work. The item in
focus is a text control inside the panel.
Any Ideas? (see short example below)
Thanks.
Miki
--- btn.py ---
import wx
class P(wx.Panel):
def __init__(self, parent, id=-1):
wx.Panel.__init__(self, parent, id)
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(wx.TextCtrl(self, -1, size=(250, -1), value="XXX"))
self.SetAutoLayout(True)
self.SetSizer(sizer)
sizer.Fit(self)
class F(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, -1, "Test Frame")
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(P(self), 0, wx.EXPAND)
b = wx.Button(self, wx.NewId(), "Quit")
wx.EVT_BUTTON(self, b.GetId(), self.on_quit)
sizer.Add(b, 0, wx.EXPAND)
self.SetDefaultItem(b)
b.SetFocus()
self.SetAutoLayout(True)
self.SetSizer(sizer)
sizer.Fit(self)
def on_quit(self, e):
self.Close(True)
def main():
app = wx.PySimpleApp()
f = F()
f.Show(True)
app.MainLoop()
if __name__ == "__main__":
main()
--- btn.py ---