0

If I add multiple trait controls to an existent wx gui and I run the program I click on one text edit and start typing but then my key inputs are somehow "captured" by that text edit. Even if I click elsewhere, e.g. on the other text edit, my key input is only received from the text edit I clicked first.

Does someone understand what is going wrong there and how I can avoid that behavior?

Here is my code:

class Config(HasTraits):

    value = Float(0.0)


class Gui(object):

    def __init__(self, title):
        app = wx.App()

        window = wx.Frame(None, wx.ID_ANY, title)

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(Config().edit_traits(parent=window, kind='subpanel').control)
        sizer.Add(Config().edit_traits(parent=window, kind='subpanel').control)
        window.SetSizer(sizer)

        window.Fit()
        window.Show()

        app.MainLoop()


if __name__ == "__main__":
    Gui()
morph
  • 305
  • 2
  • 12
  • What does captures the focus for ever mean? What would you like to see/happen? What is the one you edit first? How do you edit the one? What do you want to achieve? Consider to edit your question instead of answering in a comment. – User May 21 '15 at 20:29
  • I thought one might understand by running the code, but I try to adapt the question – morph May 22 '15 at 10:39
  • What on earth are you trying to do here? Calling `edit_traits` inside wx specific code? You should have a very good reason to be using traitsui windows as controls inside a wx app and you certainly don't have any reason to in this example. As for your direct question I ran your code exactly as in this example and can't detect any problem. Apart from lacking a title in the initializer which I supplied, it worked exactly as written; I can edit the value in either textbox. – aestrivex May 28 '15 at 22:58

0 Answers0