Lets say that I would never have a multi-line text item in my tree.
Would I just call self.tree.GetEditControl().SetStyle() to remove the
scrollbars?
-Kyle Rickey
···
-----Original Message-----
From: Andrea Gavana [mailto:andrea.gavana@gmail.com]
Sent: Thursday, December 13, 2007 2:17 PM
To: wxPython-users@lists.wxwidgets.org
Subject: Re: [wxPython-users] CustomTreeControl cancel label edit
Hi Kyle,
On Dec 13, 2007 9:07 PM, Rickey, Kyle W wrote:
That did the trick, I was still using 2.8.4.0. IsEditCancelled works
as
expected now. Now another question, does the edit control from
self.tree.GetEditControl() now have the wx.TE_MULTILINE style? I see
what looks to be like a small scrollbar when I edit labels in the
demo.
Is there any way to disable that?
Uhm, the problem is that CustomTreeCtrl supports multiline items, so
if you edit one multiline item the associated text control should have
the wx.TE_MULTILINE style keyword. If it doesn't, all the multiline
item texts will display with the "\n" in the text control, which is
not that nice... I don't really know if there is a compromised
solution, other than setting this style only when the item has more
than one line. But then, if it has only one line, it will be
impossible to type a newline character in a text control without the
wx.TE_MULTILINE control.
Does anyone have some suggestion on how to best implement this?
---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org
Lets say that I would never have a multi-line text item in my tree.
Would I just call self.tree.GetEditControl().SetStyle() to remove the
scrollbars?
I don't know if all the platforms support the style changing after the
wx.TextCtrl widget has been created. I don't even know if Windows
does. If some (or one) of the platforms do not support it, the only
alternative I see is to revert back the changes I made for the latest
release and add some kind of style/method to enable/disable multiline
item texts.
Lets say that I would never have a multi-line text item in my tree.
Would I just call self.tree.GetEditControl().SetStyle() to remove the
scrollbars?
I don't know if all the platforms support the style changing after the
wx.TextCtrl widget has been created. I don't even know if Windows
does. If some (or one) of the platforms do not support it, the only
alternative I see is to revert back the changes I made for the latest
release and add some kind of style/method to enable/disable multiline
item texts.
Any other suggestion?
I wonder if wx.lib.expando would be a good fit for this problem?
···
On Dec 13, 2007 9:27 PM, Rickey, Kyle W wrote:
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!
2) Catching the wx.EVT_KEY_DOWN event and see if the Ctrl+Enter
sequence was enter, adding a "\n" to its text. Otherwise, Skip() the
event;
Did this work? I seem to remember fixing a bug a few years ago that was preventing Ctrl-Enter from being caught in a key down event, so hopefully that bug hasn't crept back in...
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!
2) Catching the wx.EVT_KEY_DOWN event and see if the Ctrl+Enter
sequence was enter, adding a "\n" to its text. Otherwise, Skip() the
event;
Did this work? I seem to remember fixing a bug a few years ago that was
preventing Ctrl-Enter from being caught in a key down event, so
hopefully that bug hasn't crept back in...
Sorry for the late reply. I have tried to implement the OnKeyDown
method as follows:
def OnKeyDown(self, event):
"""Handles the wx.EVT_KEY_DOWN event for TreeTextCtrl."""
if keycode == wx.WXK_RETURN and controlDown:
self.SetValue(self.GetValue() + "\n")
else:
event.Skip()
Unfortunately, it still doesn't catch the Ctrl+Enter event... the
focus is switched from the text control to the next widget in the tab
hierarchy. Am I missing something? Or did I implement it in a wrong
way? This is on Windows XP, Python 2.5, wxPython 2.8.7.1.
Sorry, I now see that the code I was trying to get removed way back when is still there, so I guess I was misremembering. As it is now a Ctrl-Enter will be consumed by the win32 IsDialogMessage API, which will use it for navigation.
···
On Dec 15, 2007 6:03 AM, Robin Dunn wrote:
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!
Andrea Gavana wrote:
> Hi Robin,
>
>> Andrea Gavana wrote:
>>
>>> 2) Catching the wx.EVT_KEY_DOWN event and see if the Ctrl+Enter
>>> sequence was enter, adding a "\n" to its text. Otherwise, Skip() the
>>> event;
>> Did this work? I seem to remember fixing a bug a few years ago that was
>> preventing Ctrl-Enter from being caught in a key down event, so
>> hopefully that bug hasn't crept back in...
>
> Sorry for the late reply. I have tried to implement the OnKeyDown
> method as follows:
>
> def OnKeyDown(self, event):
> """Handles the wx.EVT_KEY_DOWN event for TreeTextCtrl."""
>
> keycode = event.GetKeyCode()
> controlDown = event.CmdDown()
> print controlDown, keycode
>
> if keycode == wx.WXK_RETURN and controlDown:
> self.SetValue(self.GetValue() + "\n")
> else:
> event.Skip()
>
> Unfortunately, it still doesn't catch the Ctrl+Enter event... the
> focus is switched from the text control to the next widget in the tab
> hierarchy. Am I missing something? Or did I implement it in a wrong
> way? This is on Windows XP, Python 2.5, wxPython 2.8.7.1.
Sorry, I now see that the code I was trying to get removed way back when
is still there, so I guess I was misremembering. As it is now a
Ctrl-Enter will be consumed by the win32 IsDialogMessage API, which will
use it for navigation.
Ok, will it be acceptable to use the Shift+Enter combination to add a
newline character? At the moment is the only thing I am able to make
work. Otherwise, I am open to all suggestions on how to best implement
this.
Ok, will it be acceptable to use the Shift+Enter combination to add a
newline character? At the moment is the only thing I am able to make
work. Otherwise, I am open to all suggestions on how to best implement
this.
If that's all that can work then that's all that can work. You may want to leave the code for Ctrl-Enter there in case wxMSW ever changes, or for the other platforms.
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!