Skip to content

Add basic support for widget templates

Nikita Churaev requested to merge lamefun/pygobject:widget-templates into master

Really feels like a very basic missing feature, especially given that all the pieces are already in place. This class is the simplest one I came up with so far, and works very well for me.

Issues: #52 (closed) and #179 (closed)

from gi.templates import Template, Child

@Template.from_file('window.ui')
class Window(Gtk.Window):
    __gtype_name__ = 'MyWindow'

    label = Child()

    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.init_template()

    def button_clicked(self, button):
        self.label.set_text('Thanks!')
Edited by Nikita Churaev

Merge request reports