SetFocus diffs between 2.4 and 2.5

Hi All!

The following snippet works for a 2.5.2.7 version (compiled and installed manually) but not for a 2.4.2.4 (gentoo ebuild); that is, in the latter case the TextCtrl does not get the focus when the app starts. Is it a 2.4 bug, a problem of my local installation of the 2.5 or is there some difference in the behaviour?

[code]
import wx

class MyApp(wx.App):

     def __init__(self):
         wx.App.__init__(self)

     def OnInit(self):
         parent = wx.MDIParentFrame(None, -1, 'test')
         child = wx.MDIChildFrame(parent, -1, 'child')
         text = wx.TextCtrl(child, -1, style=wx.TE_MULTILINE)
         child.Show(True)
         parent.Show(True)
         text.SetFocus()
         return True

app = MyApp()
app.MainLoop()
[/code]

thanks, qrz

Curzio Basso wrote:

Hi All!

The following snippet works for a 2.5.2.7 version (compiled and installed manually) but not for a 2.4.2.4 (gentoo ebuild); that is, in the latter case the TextCtrl does not get the focus when the app starts. Is it a 2.4 bug, a problem of my local installation of the 2.5 or is there some difference in the behaviour?

Probably differences in behaviour. Try using "wx.CallAfter(text.SetFocus)" I would expect that to work in both versions.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Robin Dunn wrote:

Probably differences in behaviour. Try using "wx.CallAfter(text.SetFocus)" I would expect that to work in both versions.

Tried this, and does not work. Well, in fact I just wanted to be sure that it should work also with 2.4, it's probably a problem of installation. Thanks for the help anyway.