Re: Ruby GTK modify widget colors
Kouhei Sutou <[email protected]>
| Newsgroups | gmane.comp.lang.ruby.general |
|---|---|
| Message-ID | <[email protected]> |
Hi, In <[email protected]> "Ruby GTK modify widget colors" on Thu, 10 Jan 2019 23:38:55 +0100, ulli bei Unity <[email protected]> wrote: > I want to modify the widget colors in GTK3. I only found an example > with GTK2. > > With GTK3 it doesn't work. > > Has someone a solution? You can use CSS in GTK+ 3: require "gtk3" application = Gtk::Application.new application.signal_connect(:activate) do provider = Gtk::CssProvider.new provider.load(data: <<-CSS) button { background-image: none; background-color: yellow; } label { font-size: 28px; color: magenta; } button:hover { background-color: cyan; } button:hover label { color: blue; } button:active { background-color: green; } button:active label { color: white; } CSS Gtk::StyleContext.add_provider_for_screen(Gdk::Screen.default, provider, Gtk::StyleProvider::PRIORITY_APPLICATION) window = Gtk::ApplicationWindow.new(application) window.set_size_request(300, 200) button = Gtk::Button.new(label: "Button") button.set_size_request(100, -1) fixed = Gtk::Fixed.new fixed.put(button, 10, 10) window << fixed window.show_all end application.run Unsubscribe: <mailto:[email protected]?subject=unsubscribe> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>