#1
  1. Recovering Intellectual
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jun 2006
    Location
    Orange County, CA
    Posts
    1,306
    Rep Power
    785

    Wx.Python -- How do I focus a TextCtrl after a button event?


    I have an interface where the user enters text into a textbox, and then presses a button or hits enter to 'submit' the data. But the user will need to be able to begin typing again immediately after this. The way I have it written now, after the submit event, the textbox is no longer in focus and you must click on it to begin typing again. Ive looked through the wxPyDocs for a way to do this, but I havent seen any methods of TextCtrl that do this. Has anyone else had this issue? Any solutions?
  2. #2
  3. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2005
    Posts
    610
    Rep Power
    65
    If your wx.TextCtrl is called edit1, then something like self.edit1.SetFocus() should do.
    Real Programmers always confuse Christmas and Halloween because Oct31 == Dec25
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2004
    Location
    London, England
    Posts
    1,585
    Rep Power
    1373
    wxPython uses quite a deep inheritance heirarchy. To see everything that a control does you must remember to check the attributes on all the parent classes as well. In particular most of the visible objects derive from wxControl, which is derived from wxWindow. The wxWindow class has a huge number of methods, including setFocus.

    It is worth spending some time studying the top level classes since there is a lot of functionality shared by all the controls.

    Dave
  6. #4
  7. Recovering Intellectual
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jun 2006
    Location
    Orange County, CA
    Posts
    1,306
    Rep Power
    785
    thanks I will look into that. Im new to OOP so the habits havent been developed yet, ;0) I appreciate the help

IMN logo majestic logo threadwatch logo seochat tools logo