Skip to content

Instantly share code, notes, and snippets.

@wolfv
Created August 25, 2012 20:51
Show Gist options
  • Save wolfv/3470841 to your computer and use it in GitHub Desktop.
Save wolfv/3470841 to your computer and use it in GitHub Desktop.
Python GTK 3 Pattern Tiling
#!/usr/bin/env python
from gi.repository import Gtk, Gdk
import cairo
def draw_background( widget, context):
surface = cairo.ImageSurface.create_from_png('bg.png')
sp = cairo.SurfacePattern(surface)
sp.set_extend(cairo.EXTEND_REPEAT)
context.set_source(sp)
context.paint()
window = Gtk.Window()
window.set_title('Drawing Test')
window.set_size_request(640,480)
window.connect('destroy',Gtk.main_quit)
hbbox = Gtk.HButtonBox()
window.add(hbbox)
hbbox.connect('draw', draw_background)
button = Gtk.Button('Press Me!')
hbbox.pack_start(button, True, False, 10)
window.show_all()
Gtk.main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment