# Following NOTE 1 & 2 makes it work.
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, GObject
testlabel = """
True
"""
@Gtk.Template(string=testlabel)
class TestLabel(Gtk.Label):
__gtype_name__ = 'TestLabel'
neem = GObject.Property(type=bool, default=False)
def __init__(self):
super().__init__()
self.props.label = 'TestLabel'
testbox = """
True
"""
@Gtk.Template(string=testbox)
class TestBox(Gtk.Box):
__gtype_name__ = 'TestBox'
# NOTE1: Disable this for it to work
_testlabel = Gtk.Template.Child()
noom = GObject.Property(type=bool, default=False)
def __init__(self):
super().__init__()
# NOTE2: Enable this for it to work
# self._testlabel = TestLabel()
self._testlabel.props.neem = True
print(self._testlabel.props.neem)
window = """
"Hellow World"
True
"""
@Gtk.Template(string=window)
class MyWindow(Gtk.Window):
__gtype_name__ = 'MyWindow'
_testbox = Gtk.Template.Child()
_testlabel = Gtk.Template.Child()
def __init__(self):
super().__init__()
self._testbox.props.noom = True
self._testlabel.props.neem = True
print("noom", self._testbox.props.noom)
print("neem", self._testlabel.props.neem)
win = MyWindow()
win.connect("destroy", Gtk.main_quit)
win.show_all()
Gtk.main()