私はを編集しています。Ubuntu 14 GTK version 3.10.8で作業しています。私は今Ubuntu 16にアップグレードしたくない......。それでもカラーのみを変更するにはGtkNotebook
、私はCSSとGtkNoteBookと理解の疑問を持っている
私のテスト
それは
GtkNotebook tab:nth-child(3) {} or
GtkNotebook tab:nth-child(4){} or
GtkNotebook tab:nth-child(5) etc …..
のように、一つだけのタブのタブの色を変更することは可能です
私はそれが大丈夫かどうかを確認しました
/* */
/* 2N + 1 OK OK / /最後のOK */
/*奇数OK */
/*でもOK */
/* 1 OK */
/* 3N + 4非OK */
/* 2非OK */
/* 1非OK */
/* 1非OK */
#!/usr/bin/python
# -*- coding: ISO-8859-1 -*-
# notebook_20.py
from gi.repository import Gtk, Gdk
def _destroy_cb(widget, data=None):
Gtk.main_quit()
window = Gtk.Window()
window.connect("destroy", _destroy_cb)
screen = Gdk.Screen.get_default()
css_provider = Gtk.CssProvider()
css = """
/* Theme any label within a notebook */
GtkNotebook tab GtkLabel {background-color: green;color: cyan;}
GtkNotebook > GtkLabel {background-color: pink;color: cyan;}
GtkNotebook { /*------ OR use " GtkNotebook#notebook OR GtkNotebook.mynotebook */
-GtkWidget-focus-line-width: 0; /* Remove focus line (dotted line) around text on all tabs */
-GtkNotebook-tab-overlap: 0;
padding: 10px 20px 10px 20px;
border-radius: 15px;
border-width: 4px;
}
GtkLabel.first_label { /* another way to select tab label */
color: green; /* overides last font color selection */
font: Serif italic 10; /* overides last font & font size selection */
}
/* first ok */
/* last ok */
/* odd ok */
/* even ok */
/* 1 ok */
/* 2n+1 ok */
/* 3n+4 non ok */
/* 2 non ok */
/* one non ok */
/* one non ok */
GtkNotebook tab:nth-child(3n+4) { /* modification 1er onglet tab "FirstTab */
background-color: pink; /* tab background color */
color: green; /* tab font color */
font: Sans 12; /* tab font & font size */
}
"""
css_provider.load_from_data(css)
context = Gtk.StyleContext()
context.add_provider_for_screen(screen, css_provider,
Gtk.STYLE_PROVIDER_PRIORITY_USER)
box = Gtk.VBox()
window.add(box)
notebook = Gtk.Notebook()
box.pack_start(notebook, False, False, 0)
for i in range(10):
bufferf = "Prepend Frame %d" % (i+1)
bufferl = "Page %d" % (i+1)
frame = Gtk.Frame()
frame.set_border_width(10)
frame.set_size_request(100, 75)
label = Gtk.Label(bufferf)
frame.add(label)
label.show()
label2 = Gtk.Label(bufferl)
notebook.append_page(frame, label2)
frame.show()
window.show_all()
Gtk.main()
あなたは私が perhap私はありがとうgtkのバージョン(今私はバージョン3.10.8を持っている) を変更する必要があります助けてもらえ事前
あなたのテストであなたは正常に色やタブを変更したと言っていますか? – haxxxton