[Sugar-devel] Background Screen Color for SoaS Activity
Art Hunkins
abhunkin at uncg.edu
Mon Jul 13 22:21:38 EDT 2009
Gary -
Thanks so much for these helpful suggestions.
With them I've been able to change the color of the basic Sugar display, and
to create boxes of differing colors.
Several major issues remain (which may not be surmountable?):
1) when text displayed on the basic screen (in no box) - that area reverts
to gray;
2) importantly, nothing else displays in my colored boxes; this includes
frames, other boxes, text and buttons.
Can you guide me toward solutions here?
I'm basically modifying Lazzarini's csndsugui.py. Here is the revised box
code:
def box(self, vert=True, colour=(0xFFFF, 0xFFFF, 0xFFFF), parent=None,
padding=5):
"""creates a box
vert: True, creates a vertical box; horiz.
otherwise
parent: parent box, None if this is a toplevel box
padding: box padding
returns the widget instance"""
if vert:
box = gtk.VBox()
else:
box = gtk.HBox()
self.event_box = gtk.EventBox()
self.event_box.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(colour[0],
colour[1], colour[2], 0))
if parent:
parent.pack_start(self.event_box)
else:
self.outbox.pack_start(self.event_box)
self.window.set_canvas(self.outbox)
self.boxes.append(box)
self.event_box.show()
box.show()
return box
I suspect that chaages in the last few lines are required (especially in the
"boxes" line and probably the packing).
And here is the current "text" code. I rather imagine if this could be
gotten to display in a box with the box retaining its color, I might be on
the way to success (but this may be the hard part; can other things be
displayed "over" an event_box?). This code is straight from Lazzarini:
def text(self, name, box=None,colour=(0,0,0)):
"""Creates a static text label
name: text label
box: parent box, None if text is to be placed toplevel
colour: RGB values in a tuple (R,G,B)
returns the widget instance"""
label = gtk.Label(name)
label.modify_fg(gtk.STATE_NORMAL,
gtk.gdk.Color(colour[0],colour[1],colour[2], 0))
if box:
box.pack_start(label, False, False, 5)
else:
self.outbox.pack_start(label, False, False, 5)
label.show()
return label
I very much appreciate your help. I, too, wonder if all this hassling over
color is worth it. If only there were some simple way to make the overall
display white instead of gray! I'm wanting the color change strictly for
readability; I need more color contrast to read the text (which is
unfortunately profuse in my project).
Art Hunkins
----- Original Message -----
From: "Gary C Martin" <gary at garycmartin.com>
To: "Art Hunkins" <abhunkin at uncg.edu>
Cc: "Tomeu Vizoso" <tomeu at sugarlabs.org>; <sugar-devel at lists.sugarlabs.org>
Sent: Tuesday, July 07, 2009 10:07 AM
Subject: Re: [Sugar-devel] Background Screen Color for SoaS Activity
> Hi Art,
>
> On 7 Jul 2009, at 03:46, Art Hunkins wrote:
>
>> Tomeu,
>>
>> I've had no luck modifying background color for anything except buttons.
>>
>> No boxes, even when the box is completely empty.
>>
>> Does anyone know how to change the color of the entire screen, or of a
>> box?
>
> I can remember hitting my head on this when first playing with gtk. I
> wanted a black area to place a moon image in. The trick seems to be using
> a gtk.EventBox(). Have a look in moon.py at about line #114:
>
> http://git.sugarlabs.org/projects/moon/repos/mainline/trees/master
>
> Just quickly scraped out the lines I think might be interesting, does
> seem quite a bit for just a black screen :-)
>
> # Create the main activity container
> self.main_view = gtk.HBox()
>
> # Blackness
> self.event_box = gtk.EventBox()
> colormap = gtk.gdk.colormap_get_system()
> self.black_alloc_color = colormap.alloc_color('black')
> self.event_box.modify_bg(gtk.STATE_NORMAL, self.black_alloc_color)
> self.main_view.pack_end(self.event_box)
>
> # Display everything
> self.event_box.show()
> self.main_view.show()
> self.set_canvas(self.main_view)
> self.show_all()
>
> Regards,
> --Gary
More information about the Sugar-devel
mailing list