Re: [pygtk] Setting the Colors in a ZVTerm
Eric Gillespie wrote: This is the second time i've had to deal with this broken interface, this time broken in a different way. See http://www.daa.com.au/pipermail/pygtk/2000-October/000425.html for the first time. What i ended up doing to work around that bug was this: from gnome.zvt import * from gtk import * colors = [ (0, 0, 0), (43690, 0, 0), (0, 43690, 0), (43690, 21845, 0), (0, 0, 43690), (43690, 0, 43690), (0, 43690, 43690), (43690, 43690, 43690), (21845, 21845, 21845), (65535, 21845, 21845), (21845, 65535, 21845), (65535, 65535, 21845), (21845, 21845, 65535), (65535, 21845, 65535), (21845, 65535, 65535), (65535, 65535, 65535), (43690, 43690, 43690), (0, 0, 0) ] for i in range(len(colors)): colors[i] = (colors[i],) win = GtkWindow(WINDOW_DIALOG) term = ZvtTerm(80, 25) term.set_color_scheme(colors) term.show() win.add(term) win.show() mainloop() Ugly, but it worked. Now i'm having to do this again and i discover that the interface has changed yet again. Running that program merely gives me this error: Traceback (most recent call last): File fuck.py, line 29, in ? term.set_color_scheme(colors) File /usr/pkg/lib/python2.1/site-packages/gnome/zvt.py, line 66, in set_color_scheme _zvt.zvt_term_set_color_scheme(self._o, color_list) TypeError: list items must be like (int,int,int) Strangely, eliminating the for loop doesn't change the error message! I'm very confused. 1) How can i work around this? 2) Will this interface ever be repaired properly? Thanks in advance. There is a fix for this in CVS now (I checked it in a few days ago). The colour components are meant to be unsigned shorts, and I was using PyArg_ParseTuple's h format character to read the tuples. Unfortunately this is for reading signed shorts, so any number greater than 0x7fff (32767) would cause the above exception. Until the next release, you can work around the bug by subtracting 0x from the larger numbers (the negative ints will be treated as ints 0x7fff). James. -- Email: [EMAIL PROTECTED] WWW: http://www.daa.com.au/~james/ ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] Setting the Colors in a ZVTerm
Try the attached patch. You can also make workaround in python code like for i in range(len(colors)): colors[i] = (colors[i],) in your commented block. On Mon, Oct 23, 2000 at 12:29:11PM -0500, Eric Gillespie, Jr. wrote: I'm trying to set the colors of a ZVTerm to white on black. I copied the color codes from gnome-terminal.c, but i must be doing something wrong in passing them to set_color_scheme(). I've tried 2 different methods (one is commented out), and neither worked. What am i doing wrong? The colors list was generated by having Python print the red, green, and blue lists and then copying them into the file. I thought that the hex might be throwing it off somehow. Thanks in advance. from gnome.zvtimport * from gtk import * red = [0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x0] green = [0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x0] blue = [0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x0] colors = [ (0, 0, 0), (43690, 0, 0), (0, 43690, 0), (43690, 21845, 0), (0, 0, 43690), (43690, 0, 43690), (0, 43690, 43690), (43690, 43690, 43690), (21845, 21845, 21845), (65535, 21845, 21845), (21845, 65535, 21845), (65535, 65535, 21845), (21845, 21845, 65535), (65535, 21845, 65535), (21845, 65535, 65535), (65535, 65535, 65535), (43690, 43690, 43690), (0, 0, 0) ] #colors = [] #for i in range(len(red)): #colors.append((red[i], green[i], blue[i])) win = GtkWindow(WINDOW_DIALOG) term = ZvtTerm(80, 25) term.set_color_scheme(colors) term.show() win.add(term) win.show() mainloop() -- Eric Gillespie, Jr. * [EMAIL PROTECTED] Software Developer Progeny Linux Systems - http://progeny.com ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk --- gnome-python-1.0.53/pygnome/zvtmodule.c.origTue Oct 24 15:34:21 2000 +++ gnome-python-1.0.53/pygnome/zvtmodule.c Tue Oct 24 15:41:36 2000 @@ -54,7 +54,7 @@ } for (i = 0; i 18; i++) { item = PyList_GetItem(colours, i); -if (!PyArg_ParseTuple(PyList_GetItem(colours, i), "(hhh)", +if (!PyArg_ParseTuple(item, "hhh", red[i], grn[i], blu[i])) { PyErr_Clear(); PyErr_SetString(PyExc_TypeError,"list items must be like (int,int,int)");
[pygtk] Setting the Colors in a ZVTerm
I'm trying to set the colors of a ZVTerm to white on black. I copied the color codes from gnome-terminal.c, but i must be doing something wrong in passing them to set_color_scheme(). I've tried 2 different methods (one is commented out), and neither worked. What am i doing wrong? The colors list was generated by having Python print the red, green, and blue lists and then copying them into the file. I thought that the hex might be throwing it off somehow. Thanks in advance. from gnome.zvt import * from gtkimport * red = [0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x0] green = [0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x0] blue = [0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x0] colors = [ (0, 0, 0), (43690, 0, 0), (0, 43690, 0), (43690, 21845, 0), (0, 0, 43690), (43690, 0, 43690), (0, 43690, 43690), (43690, 43690, 43690), (21845, 21845, 21845), (65535, 21845, 21845), (21845, 65535, 21845), (65535, 65535, 21845), (21845, 21845, 65535), (65535, 21845, 65535), (21845, 65535, 65535), (65535, 65535, 65535), (43690, 43690, 43690), (0, 0, 0) ] #colors = [] #for i in range(len(red)): #colors.append((red[i], green[i], blue[i])) win = GtkWindow(WINDOW_DIALOG) term = ZvtTerm(80, 25) term.set_color_scheme(colors) term.show() win.add(term) win.show() mainloop() -- Eric Gillespie, Jr. * [EMAIL PROTECTED] Software Developer Progeny Linux Systems - http://progeny.com ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk