Skip to content

Instantly share code, notes, and snippets.

@vojtechtrefny
Created April 8, 2016 11:39
Show Gist options
  • Save vojtechtrefny/bea68aa567828bec5968c2e7738021c9 to your computer and use it in GitHub Desktop.
Save vojtechtrefny/bea68aa567828bec5968c2e7738021c9 to your computer and use it in GitHub Desktop.
import gi
gi.require_version('Gtk', '3.0')
gi.require_version('Gdk', '3.0')
from gi.repository import Gtk, Gdk
class MyButton(Gtk.RadioButton):
def __init__(self, *args):
self.set_css_name("mybutton")
Gtk.RadioButton.__init__(self, *args)
win = Gtk.Window()
win.connect("delete-event", Gtk.main_quit)
css_provider = Gtk.CssProvider()
css = b"""mybutton {
border: solid 6px red;
}
"""
css_provider.load_from_data(css)
screen = Gdk.Screen.get_default()
style_context = Gtk.StyleContext()
style_context.add_provider_for_screen(screen, css_provider, Gtk.STYLE_PROVIDER_PRIORITY_USER)
label = MyButton("Button 1")
win.add(label)
win.show_all()
Gtk.main()
@vojtechtrefny
Copy link
Author

Gtk.RadioButton and Gtk.ToggleButton

gtk-buttons-css

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment