wxTextEntry question

Hi there.
I am a newbie to wx and so far I just love it.
The thing though, is that I am having trouble understanding the composition of certain widgets. I've tried the documentation but couldn't find it.

Here it is. I have a wxTextEntryDialog. So far so good. i would like to set a wxTextValidator to the text input inside the wxTextEntryDialog (I am assuming it is an instance of wxTextCtrl - Is my assumption right?)
Suppose I have the following code:

nameDialog = wx.TextEntryDialog(self.master, "attribute's name:", 'new attribute')
         if nameDialog.ShowModal() == wx.ID_OK:

I know how to get the text value for the dialog, but how do I access the TextControl that sends me the GetValue() string?

thanks
Arthur

Arthur Debert wrote:

Hi there.
I am a newbie to wx and so far I just love it.
The thing though, is that I am having trouble understanding the composition of certain widgets. I've tried the documentation but couldn't find it.

Here it is. I have a wxTextEntryDialog. So far so good. i would like to set a wxTextValidator to the text input inside the wxTextEntryDialog (I am assuming it is an instance of wxTextCtrl - Is my assumption right?)
Suppose I have the following code:

nameDialog = wx.TextEntryDialog(self.master, "attribute's name:", 'new attribute')
        if nameDialog.ShowModal() == wx.ID_OK:

I know how to get the text value for the dialog, but how do I access the TextControl that sends me the GetValue() string?

There are a couple ways to do it, and a bit of exploration in PyShell can help figure it out:

  >>> import wx
  >>> dlg = wx.TextEntryDialog(None, "Hello")
  >>> dlg.GetChildren()
  [<wx._controls.StaticText; proxy of C++ wxStaticText instance at _98f5ab00_p_wxStaticText>, <wx._controls.TextCtrl; proxy of C++ wxTextCtrl instance at _28a5f201_p_wxTextCtrl>, <wx._controls.StaticLine; proxy of C++ wxStaticLine instance at _78b13901_p_wxStaticLine>, <wx._controls.Button; proxy of C++ wxButton instance at _60abf201_p_wxButton>, <wx._controls.Button; proxy of C++ wxButton instance at _a0adf201_p_wxButton>]
  >>> txt = dlg.GetChildren()[1]

  >>> txt.GetId()
  3000
  >>> dlg.FindWindowById(3000)
  <wx._controls.TextCtrl; proxy of C++ wxTextCtrl instance at _28a5f201_p_wxTextCtrl>

···

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

Hi Robin, thanks for your answer, that was really helpful, it seems I've got some playing wih GetChildren() to do.

I am trying to put the validator on the textctrl I've got, but strangely enough there is no wx.TextValidator object.

I've checked and double checked. I've also printed a wx.__dict__.keys() array and it's not there.
I've noticed too that wx.GenericValidator doesn't show up neither. wx.Validator is there.

I am running python 2.4.1 (macPython) and wx 2.6.0 on mac os x tiger.
Is this some bug, or I am missing something here?

thanks a lot,
arthur

···

On May 31, 2005, at 18:30, Robin Dunn wrote:

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

I am trying to put the validator on the textctrl I've got, but strangely enough there is no wx.TextValidator object.

Never mind, I just checked the changelog and it's not implemented yet.

cheers
Arthur

Arthur Debert wrote:

I am trying to put the validator on the textctrl I've got, but strangely enough there is no wx.TextValidator object.

I've checked and double checked. I've also printed a wx.__dict__.keys () array and it's not there.
I've noticed too that wx.GenericValidator doesn't show up neither. wx.Validator is there.

If I remember correctly there were some changes that needed to be made to how wxPython uses the validators in order to allow them to be derived from in Python. These made it difficult to allow the standard validators to be used as well, so I never wrapped them. Since it is so easy to duplicate the things that validators do by deriving from wx.PyValidator I didn't think it would be much of a loss.

···

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