Peter Mueller wrote:
Hi,

I'm new in python and gtk/gnome. My first project is a simple cashbook
application. For this app it would be nice to have different colors for
rows in a clist (one white, one green, one white ...). There is a method
that requires a GdkColor type for setting the row color.
Unfortunately I did not find this type and there is also no example
using this type. Can anyone send me an example or tell me how to use the
GdkColor type in pygtk.

Thank you very much,
Peter

To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]

Hi

I attached a simple script and hope i coulded help you.

Bye
Dirk

-- 
The box said "Requires Win95, NT, or better," and so I installed Linux.



================================================
internet : http://www.desys.de
e-mail   : [EMAIL PROTECTED]
================================================
 
#!/usr/bin/env python
#-*-Python-*-
import gtk

color1 = "green"
color2 = "red"
color3 = "blue"

class Test(gtk.GtkWindow):
    def __init__(self):

        gtk.GtkWindow.__init__(self)
        self.set_usize(150, 100)
        self.connect_after("delete_event", gtk.mainquit)
        
        vbox = gtk.GtkVBox()
        vbox.show()
        self.add(vbox)

        self.clist = gtk.GtkCList(3)
        self.clist.column_titles_show(1)
        for index in xrange(0, 3):
            label = gtk.GtkLabel("label%d" % index)
            label.show()
            self.clist.set_column_widget(index, label)

        self.clist.show()
        vbox.pack_start(self.clist)

        button = gtk.GtkButton("Quit")
        button.connect("clicked", gtk.mainquit)
        button.show()
        vbox.pack_start(button, 0, 1, 0)

        # First: copy the clist-style
        self.style1 = self.clist.get_style().copy()
        self.style2 = self.clist.get_style().copy()
        self.style3 = self.clist.get_style().copy()
        self.style1.base[gtk.STATE_NORMAL] = self.get_colormap().alloc(color1)
        self.style2.base[gtk.STATE_NORMAL] = self.get_colormap().alloc(color2)
        self.style3.base[gtk.STATE_NORMAL] = self.get_colormap().alloc(color3)

        # Now fill the CList
        self._fill_clist()

    def _fill_clist(self):
        self.clist.clear()
        self.clist.freeze()
        
        for lines in xrange(0, 3):
            llist = []
            for columns in xrange(6, 9):
                llist.append("%d" % columns)
            self.clist.append(llist)

        # Now set the new style
        self.clist.set_row_style(0, self.style1)
        self.clist.set_row_style(1, self.style2)
        self.clist.set_row_style(2, self.style3)

        self.clist.thaw()


        
app = Test()
app.show()
gtk.mainloop()


Reply via email to