public
Last active

Python GTK 3 Pattern Tiling

  • Download Gist
bgimage-python-gtk3.py
Python
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
#!/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()

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.