2
我希望能夠在程序運行後動態更改ruby-gnome2中筆記本頁面的背景顏色。我只發現設置背景顏色的一種方式:Ruby-Gnome2筆記本顏色
# 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
的組合,不起作用。
是否有正確的方法來設置筆記本頁面的顏色,這是不是很蹩腳,可以在主循環運行後應用?