When I enter text into my TextCtrl, every time a key is struck the entire text is selected briefly and then unselected. This causes a flashing that is stressful to my eyes. I presume that something in my EVT_TEXT-bound method causes this, but I am not sure what it is.
Here is my EVT_TEXT-bound method:
def OnText(self, e):
# Circumvent the initial EVT_TEXT
if self.firstOnText:
self.firstOnText = False
return
# If there is no text in the TextCtrl
if not self.control.GetValue():
return
selected = self.tree.GetSelection()
# Take the data from the TextCtrl, and add it to the item in the TreeCtrl
if selected:
# We don't want to write 'None' literally
if unicode(self.tree.GetPyData(selected)) == 'None':
self.control.SetValue("")
self.tree.SetPyData(selected, self.control.GetValue())
# Make sure that just one character changed
if len(self.control.GetValue()) - len(self.oldtext) in [-1, 1]:
self.SetModified(True)
self.control.SetAllDefaultStyle()
self.oldtext = self.control.GetValue()
The only thing I can think of is that self.control.GetValue() highlights all of the text in order to get the text value.
On Mon, 21 Aug 2006 08:27:36 -0400, "Saketh Bhamidipati" <saketh.bhamidipati@gmail.com> wrote:
When I enter text into my TextCtrl, every time a key is struck the entire
text is selected briefly and then unselected. This causes a flashing that is
stressful to my eyes. I presume that something in my EVT_TEXT-bound method
causes this, but I am not sure what it is.
Here is my EVT_TEXT-bound method:
def OnText(self, e):
# Circumvent the initial EVT_TEXT
if self.firstOnText:
self.firstOnText = False
return
# If there is no text in the TextCtrl
if not self.control.GetValue():
return
selected = self.tree.GetSelection()
# Take the data from the TextCtrl, and add it to the item in the
TreeCtrl
if selected:
# We don't want to write 'None' literally
if unicode(self.tree.GetPyData(selected)) == 'None':
self.control.SetValue("")
When I enter text into my TextCtrl, every time a key is struck the entire
text is selected briefly and then unselected. This causes a flashing that is
stressful to my eyes. I presume that something in my EVT_TEXT-bound method
causes this, but I am not sure what it is.
Here is my EVT_TEXT-bound method:
def OnText(self, e):
# Circumvent the initial EVT_TEXT
if self.firstOnText:
self.firstOnText = False
return
# If there is no text in the TextCtrl
if not self.control.GetValue():
return
selected = self.tree.GetSelection()
# Take the data from the TextCtrl, and add it to the item in the
TreeCtrl
if selected:
# We don't want to write 'None' literally
if unicode(self.tree.GetPyData(selected)) == 'None':
self.control.SetValue("")
self.tree.SetPyData(selected, self.control.GetValue())
# Make sure that just one character changed
if len(self.control.GetValue()) - len(self.oldtext) in [-1, 1]:
self.SetModified(True)
self.control.SetAllDefaultStyle
()
self.oldtext = self.control.GetValue()
The only thing I can think of is that self.control.GetValue() highlights all
of the text in order to get the text value.
Actually, I see nothing in this particular function that would make
the control flash. However, I am wondering if there's something in
the self.control.SetAllDefaultStyle() function that is doing it.
On Mon, 21 Aug 2006 10:30:14 -0400, "Saketh Bhamidipati" <saketh.bhamidipati@gmail.com> wrote:
>Here is my EVT_TEXT-bound method:
> def OnText(self, e):
> # Circumvent the initial EVT_TEXT
> if self.firstOnText:
> self.firstOnText = False
> return
>
> # If there is no text in the TextCtrl
> if not self.control.GetValue():
> return
>
> selected = self.tree.GetSelection()
>
> # Take the data from the TextCtrl, and add it to the item in the
>TreeCtrl
>
> if selected:
> # We don't want to write 'None' literally
> if unicode(self.tree.GetPyData(selected)) == 'None':
> self.control.SetValue("")
>
> self.tree.SetPyData(selected, self.control.GetValue())
>
> # Make sure that just one character changed
> if len(self.control.GetValue()) - len(self.oldtext) in [-1, 1]:
> self.SetModified(True)
>
> self.control.SetAllDefaultStyle()
> self.oldtext = self.control.GetValue()
>
Just a thought, but should self.SetModified(True) be self.control.SetModified(True) ?
Tim
Saketh Bhamidipati wrote:
···
When I enter text into my TextCtrl, every time a key is struck the entire text is selected briefly and then unselected. This causes a flashing that is stressful to my eyes. I presume that something in my EVT_TEXT-bound method causes this, but I am not sure what it is.
Here is my EVT_TEXT-bound method:
def OnText(self, e):
....
# Make sure that just one character changed
if len(self.control.GetValue()) - len(self.oldtext) in [-1, 1]:
self.SetModified(True)
Actually, what he's doing there is letting the "window" containing the
control know that the data has been modified. This would be used to
warn the user that there's been changes made to the document if the
user exits without saving...
On Mon, 21 Aug 2006 11:08:29 -0400, "Timothy J. Tucker" <tim@timtucker.com> wrote:
Just a thought, but should self.SetModified(True) be
self.control.SetModified(True) ?
Tim
Saketh Bhamidipati wrote:
When I enter text into my TextCtrl, every time a key is struck the
entire text is selected briefly and then unselected. This causes a
flashing that is stressful to my eyes. I presume that something in my
EVT_TEXT-bound method causes this, but I am not sure what it is.
Here is my EVT_TEXT-bound method:
def OnText(self, e):
....
# Make sure that just one character changed
if len(self.control.GetValue()) - len(self.oldtext) in [-1, 1]:
self.SetModified(True)
---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org
Actually, what he’s doing there is letting the “window” containing the
control know that the data has been modified. This would be used to
warn the user that there’s been changes made to the document if the
Well, this explains it. The first two parameters to the SetStyle
method describe a "range" of characters to change to a certain style,
so characters from 0...N will be "selected", thereby flashing the
control.
I'm trying to divine why you need to call this function at all.
Basically, if I'm reading this right, every time a user hits a key,
the "self.style" variable is applied to the whole text field. I'm
trying to figure out why this would be necessary.
When I enter text into my TextCtrl, every time a key is struck the entire text is selected briefly and then unselected. This causes a flashing that is stressful to my eyes. I presume that something in my EVT_TEXT-bound method causes this, but I am not sure what it is.
Here is my EVT_TEXT-bound method:
def OnText(self, e):
# Circumvent the initial EVT_TEXT
if self.firstOnText:
self.firstOnText = False
return
# If there is no text in the TextCtrl
if not self.control.GetValue():
return
selected = self.tree.GetSelection()
# Take the data from the TextCtrl, and add it to the item in the TreeCtrl
if selected:
# We don't want to write 'None' literally
if unicode(self.tree.GetPyData(selected)) == 'None':
self.control.SetValue("")
The only thing I can think of is that self.control.GetValue() highlights all of the text in order to get the text value.
The first thing to do is to find out exactly what is causing the selection flash. To do that go through some iterations where you comment out parts of the function until you are able to narrow it down to the actual cause. Once you know that then you will be able to decide if it is something that you need to keep or to find some workaround.
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!
Sometimes the style in my TextCtrl changes to some default style (it appears to be wx.DECORATIVE, size 9.5-ish) without warning. Even though I SetDefaultStyle() on initializing the frame, the style changes sometimes.
I’ll try to figure out why it’s changing the style randomly. Thanks for helping me!
When I enter text into my TextCtrl, every time a key is struck the
entire text is selected briefly and then unselected. This causes a
flashing that is stressful to my eyes. I presume that something in my
EVT_TEXT-bound method causes this, but I am not sure what it is.
Here is my EVT_TEXT-bound method:
def OnText(self, e):
# Circumvent the initial EVT_TEXT
if self.firstOnText:
self.firstOnText = False
return
# If there is no text in the TextCtrl
if not self.control.GetValue():
return
selected = self.tree.GetSelection()
# Take the data from the TextCtrl, and add it to the item in the
TreeCtrl
if selected:
# We don't want to write 'None' literally
if unicode(self.tree.GetPyData(selected)) == 'None':
self.control.SetValue("")
self.tree.SetPyData(selected, self.control.GetValue())
# Make sure that just one character changed
if len(self.control.GetValue()) - len(self.oldtext) in [-1, 1]:
self.SetModified(True)
self.control.SetAllDefaultStyle
()
self.oldtext = self.control.GetValue()
The only thing I can think of is that self.control.GetValue() highlights
all of the text in order to get the text value.
The first thing to do is to find out exactly what is causing the
selection flash. To do that go through some iterations where you
comment out parts of the function until you are able to narrow it down
to the actual cause. Once you know that then you will be able to decide
if it is something that you need to keep or to find some workaround.
–
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!