problem with textctrl

Hi All,

In my application i am using a textctrl that displays certain messages along with the time…

In the demo of wxpython also there is a textctrl that scrolls down according to the new messages…

In the same way my text ctrl also scrolls down when new messages are appended to it.

In my app i am using the AppendText() for showing the messages…

I need to know what will happen to all the previous messages…

Will it get automatically deleted or do we need to delete it after a ceratin number of lines…My application need to run for several hours and hence the messages that appear each and every second will be very lengthy.All
these messages are appended to the previous text. i doubt what will happen if so many mesages get appended to the text ctrl.

Can anyone help me?

This is my first application in wxPython and i congragulate Robin for his wonderful creation…

and i also thank all the members of the list for helping me. This mailing list helped a lot…

Regards,

Shine Anne

Nothing will happen to them. The messages will always be available. If
you are using Windows (or you plan for the application to be run on
Windows), you should pass the wx.TE_RICH2 style to the text control.
This is because the default text control on Windows is limited to 64k of
text, and if your logs get *really* long, 64k may not be enough.

- Josiah

···

"Shine Anne" <m2ids2005@gmail.com> wrote:

In my app i am using the AppendText() for showing the messages..
I need to know what will happen to all the previous messages..

well if the text messages are going to be there…then it is a problem. since my app will run for a very long time and since i am appending the newly got messages all will get accumulated and it consumes a lot of memory. then i need to delete the previously shown messages…does any one know how to remove the previous messages when a particular length is reached…hope iam able to convey my point

···

On 4/19/06, Josiah Carlson jcarlson@uci.edu wrote:

“Shine Anne” m2ids2005@gmail.com wrote:

In my app i am using the AppendText() for showing the messages…
I need to know what will happen to all the previous messages…

Nothing will happen to them. The messages will always be available. If

you are using Windows (or you plan for the application to be run on
Windows), you should pass the wx.TE_RICH2 style to the text control.
This is because the default text control on Windows is limited to 64k of
text, and if your logs get really long, 64k may not be enough.

  • Josiah


Regards,

Shine Anne

Shine Anne wrote:

well if the text messages are going to be there..then it is a problem. since my app will run for a very long time and since i am appending the newly got messages all will get accumulated and it consumes a lot of memory. then i need to delete the previously shown messages..does any one know how to remove the previous messages when a particular length is reached...hope iam able to convey my point

Assuming you keep track of the number of lines as you append them (linecount), then you could do :

if linecount > maxLines:
    myText.Remove( 0, myText.XYToPosition(0,removeLines))
    linecount = linecount - removeLines

where maxLines is the max number you want to allow
          removeLines is how many you then want to remove.

If you don't keep track of the number of lines, then you can do

linecount = len(myText.GetValue().splitlines())
if linecount > maxLines:
    myText.Remove( 0, myText.XYToPosition(0,removeLines))
    linecount = linecount - removeLines

but that will be less efficient than just keeping track as you append them.

.

···

--
Alex Tweedly http://www.tweedly.net

--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.385 / Virus Database: 268.4.4/318 - Release Date: 18/04/2006

Shine Anne escribió:

well if the text messages are going to be there..then it is a problem. since my app will run for a very long time and since i am appending the newly got messages all will get accumulated and it consumes a lot of memory. then i need to delete the previously shown messages..does any one know how to remove the previous messages when a particular length is reached...hope iam able to convey my point

In an old project made with VB I used a simple ListBox instead of a TextCtrl to show realtime log messages.

Append the new log lines to the list. When the count lines reach some limit, then on each append, also remove the first line.

  if lc.GetCount() > LimitLines:
    lc.Remove(0) # remove the first line
  lc.AppendAndEnsureVisible(logline) # add the new line

You must test the optimal value for limit lines, if you use a big number the push/pop operation may be slow.

···

--
*****************************************
Oswaldo Hernández
oswaldo@soft-com.es
*****************************************

Oswaldo Hernández wrote:

Shine Anne escribió:

well if the text messages are going to be there..then it is a problem. since my app will run for a very long time and since i am appending the newly got messages all will get accumulated and it consumes a lot of memory. then i need to delete the previously shown messages..does any one know how to remove the previous messages when a particular length is reached...hope iam able to convey my point

In an old project made with VB I used a simple ListBox instead of a TextCtrl to show realtime log messages.

Append the new log lines to the list. When the count lines reach some limit, then on each append, also remove the first line.

    if lc.GetCount() > LimitLines:
        lc.Remove(0) # remove the first line
    lc.AppendAndEnsureVisible(logline) # add the new line

You must test the optimal value for limit lines, if you use a big number the push/pop operation may be slow.

If you use a virtual listctrl then you can just keep your log lines in a Python list and then adding/removing lines is only a matter appending or deleting items from the list, and adjusting the count in the listctrl.

···

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