Kavaeric Kavaeric - 9 months ago 55
CSS Question

PyGI: Styling Context Menu

I'm using PyGI to build a GUI for an app I've written in Python 3.4, and I'm using GTK+3's CSS implementation to style the interface.

In my .css file, I've specified that all text by default should be white:

* {
color: #fff;

as I'm mostly working against dark/black backgrounds.

The app I'm building has text boxes, however, and GTK automatically gives them context/right-click menus. Unfortunately the default white text styling I've applied also works on the menu, and so the user can't see anything.

If I try to override those settings with:

.menu {
color: #000;
background-color: #f3f3f3;

it just turns out like this. The text colour doesn't change, and it doesn't seem to respond to any
pseudo-classes either.

How can I style or customise the context menus of these text fields using GTK+3's implementation of CSS?

Answer Source

I styled the context menu to look the way I want with these lines in the CSS file:

.menu {
    border: 1px #444 solid;

    background: #0d0d0d;

    font: light 12px;
.menu .separator {
    color: rgba(68, 68, 68, 0.1);
.menuitem {
    padding: 8px 0px;
.menuitem:hover {
    background: rgba(255, 255, 255, .1);
.menuitem:insensitive .label {
    color: #555;

It now looks like this.