When I click on a line in a textctrl,
I want retrieve the information on that line (contains linenr and search results),
is that possible.
I tried GetPosition, GetInsertionPoint, LastPosition but they don't give the desired result.
thanks,
Stef Mientki
| See the example in the attached file. The panel needs to be put in a wx.Window or one of its subclasses like a wx.Frame. You also need to put some line items in the wx.TextCtrl, too, but that's easy. Raoul ------------------------------------------------------------------------------------------------------------------- Sponsored links: Rock Hard Erections. All New Formula Attacks the Root. Fast. www.capitolbird.org/pharma.html |
col, ln = my_TextCtrl.PositionToXY(my_TextCtrl.GetInsertionPoint()) #
zero-based indices
If line-wrapping is active, this returns the currently visible columns
and lines, regardless of the physical newlines in the text.
The search results must probably be handled with specific code; I
guess TextCtrl doesn't have a search capability (unlike e.g. stc).
hth,
vbr
cheers,
Stef
See the example in the attached file. The panel needs to be put in a wx.Window or one of its subclasses like a wx.Frame.
You also need to put some line items in the wx.TextCtrl, too, but that's easy.
Raoul
thanks again,
Stef
Ok, I'm glad, the solution was found :-)
I also experienced some surprises with handling text in this widget,
but these were of another art; mainly differences in indexing and
handling surrogate pairs depending on the TE_RICH... flags (GetString
and GetRange functions), or the potential speed problems of the
richtext variants, but this seems to be OS issue.
Regards,
vbr
On Mon, Jul 26, 2010 at 6:17 PM, Raoul <raoul...@yahoo.com> wrote:
> Yup, you're right. You can only retrieve a cursor coordinate from a
> TextCtrl. (Why would anyone want to do that ?! ) I am guessing that
> you want to retrieve the actual text from a list item and its position
> in the list. To do this requires a wx.ListBox which is far more
> flexible. A TextCtrl is just for display purposes and is not meant to
> be user-interactive.
>
What?!?!
A TextCtrl is quite possible the most common and widely used user
interactive control in all applications ever made (or at least a very
close second behind a Button). Sorry but saying it is not meant to be
user interactive is simply false.
Cody
The reason I used a TextCtrl is exactly the reason Cody mentioned: KISS
And Kiss in more than 1 way:
- keep it simple for the programmer (not to learn difficult objects like a listctrl)
- keep it simple for the user, in having just a few widgets he can learn in a short time
To keep it even more simple (= all my programs will have an identical look and feel and even more
important: identical behavior,
and I've to rememember just a small subset of the overwhelming wxPython methods ),
therefor I wrap wxPython components almost always in "My_Own_Class"
cheers,
Stef