mailr10887 - /branches/bieri_gui/gui_bieri/controller.py


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by michael . bieri on February 24, 2010 - 05:00:
Author: michaelbieri
Date: Wed Feb 24 05:00:23 2010
New Revision: 10887

URL: http://svn.gna.org/viewcvs/relax?rev=10887&view=rev
Log:
The number of maximum lines in the relaxGUI log window is limited to 1000
lines.

relaxGUI calculation crashed during local tm calculation due to too many
lines in the relaxGUI log window. Therefore, the maximum amout of numbers is
limited to 1000 as discussed with Edward d'Auvergne
(https://gna.org/bugs/?15173).

A new function to limit maximum lines in relaxGUI log windows was introduced
into controller.py.

Modified:
    branches/bieri_gui/gui_bieri/controller.py

Modified: branches/bieri_gui/gui_bieri/controller.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/bieri_gui/gui_bieri/controller.py?rev=10887&r1=10886&r2=10887&view=diff
==============================================================================
--- branches/bieri_gui/gui_bieri/controller.py (original)
+++ branches/bieri_gui/gui_bieri/controller.py Wed Feb 24 05:00:23 2010
@@ -26,6 +26,7 @@
 
 # Python module imports.
 from os import sep
+from string import split, replace
 import sys
 import time
 import thread
@@ -185,10 +186,37 @@
         self.out=aWxTextCtrl
 
 
+    def limit_entries(self):
+        """ Function to overcome feedback problem of wx.CallAfter() 
command"""
+
+        # Maximum allowed number of lines in log window.
+        max_entries = 1000
+        new_entries = ''
+
+        # read number of lines in log window.
+        total_entries = self.out.log_panel.GetNumberOfLines()
+
+        # Shift entries backwards if maximum of line exeeded.
+        if total_entries > max_entries:
+            # Convert entries to list
+            list_of_entries = split(self.out.log_panel.GetValue(), '\n')
+
+            for i in range(1, max_entries + 1):
+                new_entries = new_entries + (list_of_entries[i]) + '\n'
+
+            # Reset log window entries
+            #new_entries = str(list_of_entries)
+            self.out.log_panel.SetValue(new_entries)
+
+
     def write(self,string):
         global progress
 
-        wx.CallAfter(self.out.log_panel.WriteText, string)
+        # Limit panle entries to max_entries Lines.
+        wx.CallAfter(self.limit_entries)
+
+        # Add new output.
+        wx.CallAfter(self.out.log_panel.AppendText, string)
         time.sleep(0.001)  # allow relaxGUI log panel to get refreshed
 
         # split print out into list




Related Messages


Powered by MHonArc, Updated Wed Feb 24 05:20:06 2010