Based on the size of your grid (2x10) it looks like it is the cell renderer code that is causing problems for you.   My comments about poor performance of treeviews don't apply in your case, because your treeview is quite small compared with the ones I'm running into problems with.

You probably need to knock up a version of your code in C so that you can profile the gtkcellrenderer code and find out where the bottleneck is.

A couple of other things you could try.

  1. Use a dictionary instead of that long if/elif clause to convert letters to the colour strings (I suspect this won't help much, because I doubt if it is spending much time there).
  2. Have one column per character in your strings and use the trick explained in this PyGTK FAQ entry to set the background colours of each cell: http://www.async.com.br/faq/pygtk/index.py?req=show&file=faq13.031.htp  -- I'm not sure if this will help or not, but it is worth a try.   It will mean that the renderers are no longer dealing with the markup stuff, rather they will be getting a single colour from another column of your model.
  3. Find some other way of displaying your data.   One option is the solution to all problems, matplotlib:  http://matplotlib.sourceforge.net
I hope one of these works for you.

John

Frederico Arnoldi wrote:
  Hi John,

   Thanks for reply my question.

Some things you can do to improve performance:

   * set_fixed_height_mode
   * use fixed with columns in the view
   * use your own custom tree_model.

    I have already tried the first two methods, but didn't work. The third, I have been reading about how to create my own model, but I didn't try  it yet.

Finally, I'm not entirely sure whether your performance issues are a variation on what I am running into.  Can you post a simple code snippet?

        Here is a bit of the code:
       # Creating the Treeview #
    self.liststore = gtk.ListStore(str,str)

       #sequence treeview => _This is the slow Treeview_
       self._seqs_treeview.set_model(self.liststore)
    seqsselection = self._seqs_treeview.get_selection()
       seqsselection.set_mode(gtk.SELECTION_MULTIPLE)

    #spp treeview
       self._spp_treeview.set_model(self.liststore)

       #After opened the desired file and selected the desired rows to color, the color data is loaded into the Treeview#
    (model, paths) = sppselection.get_selected_rows()
    tmpliststore = {}
    names = []
    uncolored = {}
    for path in paths:
            kiter = model.get_iter(path)
        name = model.get_value(kiter,0)
           sequncolor = model.get_value(kiter,1)
        seq2 =[]
        names.append(name)
        for letter in sequncolor:#THIS STEP turn my treeview too slow
            if letter == "A" :
                   seq2.append('<span background="">A</span>')
               elif letter == "T":
                  seq2.append('<span background="">T</span>')
               elif letter == "C":
                  seq2.append('<span background="">C</span>')
            elif letter == "G":
                   seq2.append('<span background="">G</span>')
               elif letter == "R":
                   seq2.append('<span background="">R</span>')
               elif letter == "M":
                   seq2.append('<span background="">M</span>')
               elif letter == "S":
                   seq2.append('<span background="">S</span>')
               elif letter == "N":
                   seq2.append('<span background="">N</span>')
               elif letter == "D":
                   seq2.append('<span background="">D</span>')
               elif letter == "E":
                   seq2.append('<span background="">E</span>')
               elif letter == "K":
                   seq2.append('<span background="">K</span>')
               elif letter == "V":
                   seq2.append('<span background="">V</span>')
               elif letter == "I":
                   seq2.append('<span background="">I</span>')
               elif letter == "P":
                   seq2.append('<span background="">P</span>')
               elif letter == "L":
                   seq2.append('<span background="">L</span>')
               elif letter == "H":
                   seq2.append('<span background="">H</span>')
               elif letter == "Y":
                   seq2.append('<span background="">Y</span>')
               elif letter == "Q":
                   seq2.append('<span background="">Q</span>')
               elif letter == "F":
                   seq2.append('<span background="">F</span>')
               elif letter == "W":
                   seq2.append('<span background="">W</span>')
               else:
                   seq2.append('<span background="">%s</span>'%letter)

        joinseq=join(seq2)
           strseq=str(joinseq)
           colorseq = strseq.replace("> <","><")
           tmpliststore[name] = colorseq
         ....

         ....
    #appending the liststore
    for seqname in names:
           self.liststore.append([seqname,tmpliststore[seqname]])
       ...

       ...
       self.cellspp = gtk.CellRendererText()
       self.cellseqs = gtk.CellRendererText()
       ....

       ....
       #setting the cell attributes to the appropriate liststore column
       self.spp.set_attributes(self.cellspp, markup=0)
       self.seqs.set_attributes(self.cellseqs,markup=1)
    # end #

 How many rows can you put in your tables before the performance starts to fall off?
     Each row contain at least 500 letters, and about seven rows turn the Treeview slow, and more than 15 turns the Treeview too slow.
      I believe that the root of the problem is the great number of markups, because when I just open the file with only normal text, even 20 rows are not enough to turn the treeview slow. However, when I color the letters to turn the data analysis easier, the performance problem apear.

      Thanks again,
      Fred

Frederico Arnoldi wrote:

I have been working in a tool that display large sequences of data. Using
normal text it work's fine, but when I substitute the normal text by markup
text it get to slow. I have already tried set_fixed_height_mode, but didn't
work. Is it an algorithm  or a processor/RAM memory problem?
Is there another way to improve the treeview performance?

_________________________________________________________________
MSN Messenger: converse online com seus amigos .  http://messenger.msn.com.br

_______________________________________________
pygtk mailing list   [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to