I am trying to build a GUI in wxPython. I have two TextCtrls. Let's say they are first_index_input
and last_index_input
, and they control model.f_i
and model.l_i
, respectively. There's a condition: For proper model execution, model.f_i must be <= model.l_i. Therefore the content of first_index_input
should be <= last_index_input
.
So what I want to do is fix it so that: 1) if the user enters a value into first_index_input
that is greater than the value in last_index_input
(established in a prior use case or something) then last_index_input
and model.l_i
will both be set equal to the new first_index_input
. 2) If the user enters a last_index_input
that is less than first_index_input
, then last_index_input
will be corrected again and set equal to first_index_input
.
So what's so hard about that? It's a question of what event to key off of. Let's say that first_index_input
has content "145" and I (correctly) want to give last_index_input
an input of 10324. If this widget keys off of a wx.EVT_TEXT event, then it won't wait for me to type in "10324". As soon as it sees the "1" (i.e. first digit) it freaks out and says, "NO! That's less than first_index_input
" and "corrects" my typing. On the other hand, I can get rid of this by keying off of a wx.EVT_TEXT_ENTER command, and everything works fine as long as I remember to hit return after entering my value and I never remember to hit return so I am sure my users won't either.
Is there another way to do this? Some other event that is available, perhaps? Thanks.