wx.RichTextCtrl Question

Hi All,

I am using the RichTextCtrl to view a text file and i have two questions:

  1. How do i add the “find” dialog which will scroll to the correct place

  2. i am using a list ctrl which is a brief copy of the full text ctrl. i want to be able to select a line in the list ctrl and set the focus of the richtextctrl to the selected line, for example:

the list has only the lines start with [xxx] from the full text file:

[100] blahblah

[101] klhgvdsfjhv

.

.

.

[550] sdkjhgf

.

.

.

.

[1500]

and the full text file which is displayed in the richtextctrl:

[100] blahblah

text text text text text

text text text text

text text text text

[101] klhgvdsfjhv

text text text text text

text text text text

text text text text

.

.

.

[550] sdkjhgf

text text text text text

text text text text

text text text text

.

.

[1500]

now, when i hit the list line [550] i want to scroll down in the richtextctrl to the same line.

Thanks in advance,

Roy.

···

Explore the seven wonders of the world Learn more!

Hi All,

I am using the RichTextCtrl to view a text file and i have two questions:

1. How do i add the "find" dialog which will scroll to the correct place

AFAIK, there is no "built in" way to do this; you have to write it yourself.
See the FindReplaceDialog in the demo and read the overview; You could then
use some text searching methods to search the RichTextCtrl's text.

2. i am using a list ctrl which is a brief copy of the full text ctrl. i
want to be able to select a line in the list ctrl and set the focus of the
richtextctrl to the selected line, for example:

I also think there is no built-in way to do this. See the RTC's methods and
search for "find" and there may be a way to do it with that.

···

On Tue, Jun 24, 2008 at 2:02 AM, ROY ZINN <royzinn@hotmail.com> wrote:

C M wrote:

···

On Tue, Jun 24, 2008 at 2:02 AM, ROY ZINN <royzinn@hotmail.com> wrote:

Hi All,

I am using the RichTextCtrl to view a text file and i have two questions:

1. How do i add the "find" dialog which will scroll to the correct place

AFAIK, there is no "built in" way to do this; you have to write it yourself.
See the FindReplaceDialog in the demo and read the overview; You could then
use some text searching methods to search the RichTextCtrl's text.

2. i am using a list ctrl which is a brief copy of the full text ctrl. i
want to be able to select a line in the list ctrl and set the focus of the
richtextctrl to the selected line, for example:

I also think there is no built-in way to do this. See the RTC's methods and
search for "find" and there may be a way to do it with that.

If you keep track of or can find the position where the lines are, then you can use SetInsertionPoint to put the caret there, and use ShowPostition to make sure it is visible, etc.

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

Hi Robin,

I do know the line in the original file to go to.

I tried most of the combination (SetInsertionPoint and ShowPostition ) but nothing worked fine except ScrollLines, but i still have problem with that. if i push the scroller down arrow, it scrolls onle 1/3 line and not full line.

I also tried MoveDown, which puts the cursor in the right place, but the window did not scroll to this place, only if i scrolled manually, i saw that the cursor is in the correct position.

The ShowPosition did nothing (I’m not sure, but i think ShowPosition does not scroll down to the exact line…)

This is part of the code i’m using:

def UpdateFullLogView(self, idx):
    global gOrigFullLogLink
   
    origLineidx = gOrigFullLogLink[idx]
    self.FullLog.rtc.Freeze()

self.FullLog.rtc.SetScrollPos(wx.VERTICAL, origLineidx*3)

    self.FullLog.rtc.ScrollLines(origLineidx*3)

self.FullLog.rtc.SetInsertionPoint(origLineidx)

self.FullLog.rtc.MoveDown(origLineidx)

···

self.FullLog.rtc.ShowPosition(origLineidx)

print “position:”, self.FullLog.rtc.GetPosition()

    self.FullLog.rtc.Thaw()

Any Suggestions?

Thanks,

Roy.


Date: Tue, 24 Jun 2008 22:28:56 -0700
From: robin@alldunn.com
To: wxpython-users@lists.wxwidgets.org
Subject: Re: [wxpython-users] wx.RichTextCtrl Question

C M wrote:

On Tue, Jun 24, 2008 at 2:02 AM, ROY ZINN royzinn@hotmail.com wrote:

Hi All,

I am using the RichTextCtrl to view a text file and i have two questions:

  1. How do i add the “find” dialog which will scroll to the correct place

AFAIK, there is no “built in” way to do this; you have to write it yourself.
See the FindReplaceDialog in the demo and read the overview; You could then
use some text searching methods to search the RichTextCtrl’s text.

  1. i am using a list ctrl which is a brief copy of the full text ctrl. i
    want to be able to select a line in the list ctrl and
    set the focus of the
    richtextctrl to the selected line, for example:

I also think there is no built-in way to do this. See the RTC’s methods and
search for “find” and there may be a way to do it with that.

If you keep track of or can find the position where the lines are, then
you can use SetInsertionPoint to put the caret there, and use
ShowPostition to make sure it is visible, etc.


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


wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users


Explore the seven wonders of the world Learn more!

ROY ZINN wrote:

Hi Robin,
I do know the line in the original file to go to.
I tried most of the combination (SetInsertionPoint and ShowPostition ) but nothing worked fine except ScrollLines, but i still have problem with that. if i push the scroller down arrow, it scrolls onle 1/3 line and not full line.

SetInsertioPoint and ShowPosition deal with the character position within the text, not the line number. And a "line" in the context of ScrollLines is not a line of text but the number of pixels specified for the scroll rate.

···

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

Thanks,

I tried to set the scroll rate (using SetScrollRate, ScrollWindow method?) but the application collapsed, what is the right way to do that?

Thanks,

Roy.

···

Date: Wed, 25 Jun 2008 23:14:34 -0700
From: robin@alldunn.com
To: wxpython-users@lists.wxwidgets.org
Subject: Re: [wxpython-users] wx.RichTextCtrl Question

ROY ZINN wrote:

Hi Robin,

I do know the line in the original file to go to.
I tried most of the combination (SetInsertionPoint and ShowPostition )
but nothing worked fine except ScrollLines, but i still have problem
with that. if i push the scroller down arrow, it scrolls onle 1/3 line
and not full line.

SetInsertioPoint and ShowPosition deal with the character position
within the text, not the line number. And a “line” in the context of
ScrollLines is not a line of text but the number of pixels specified for
the scroll rate.


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


wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users


Connect to the next generation of MSN Messenger Get it now!

ROY ZINN wrote:

Thanks,
I tried to set the scroll rate (using SetScrollRate, ScrollWindow method?) but the application collapsed, what is the right way to do that?

The problem is in wxPython, there is a mismatch between what it thinks is the inheritance hierarchy and what it really is in C++. Not sure how that slipped through... I'll get a fix out asap.

···

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