プログラムの実行後に、ruby-gnome2のノートブックページの背景色を動的に変更できるようにしたいと思います。背景色を設定する方法は1つしか見つかりませんでした。
# Some page contents, for the sake of example
box1 = Gtk::HBox.new(false, 2)
box1.pack_start(Gtk::Label.new("Page 1"))
box2 = Gtk::HBox.new(false, 2)
box2.pack_start(Gtk::Label.new("Page 2"))
notebook = Gtk::Notebook.new # Create a notebook object
notebook.append_page(box1) # Create a page with box1 as contents
notebook.append_page(box2) # Create a page with box2 as contents
style = notebook.style # Copy the currently applied style
style.set_bg(Gtk::STATE_NORMAL, bg.red, bg.green, bg.blue) # Update the bg color
notebook.style = style # Set notebook's style to the updated object
Gtk.main
キックオフ前に適用された場合、これは問題ありません。ただし、ウィンドウがすでに起動した後は効果がありません。ノートブックオブジェクトとページコンテンツの両方の組み合わせを試しましたが、効果はありませんでしmodify_bg
た。modify_base
それほどハックではなく、メインループの実行後に適用できるノートブックページの色を設定する適切な方法はありますか?