Commit 5c5cced5 authored by Wouter Wijsman's avatar Wouter Wijsman

Implemented Gtk template into the python example

parent efae58e0
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="HelloWindow" parent="GtkWindow">
<property name="default_width">600</property>
<property name="default_height">300</property>
<child type="titlebar">
<object class="GtkHeaderBar" id="headerbar">
<property name="visible">true</property>
<property name="show-close-button">true</property>
<property name="title">Hello, World!</property>
</object>
</child>
<child>
<object class="GtkLabel" id="label">
<property name="label">Hello, World!</property>
<property name="visible">true</property>
<attributes>
<attribute name="weight" value="bold"/>
<attribute name="scale" value="2"/>
</attributes>
</object>
</child>
</template>
</interface>
......@@ -8,13 +8,15 @@ gi.require_version('Gtk', '3.0')
from gi.repository import Gio
from gi.repository import Gtk
@Gtk.Template.from_file("hello-window.ui")
class Window(Gtk.Window):
__gtype_name__ = "HelloWindow"
headerbar = Gtk.Template.Child()
label = Gtk.Template.Child()
def create_window(app):
# TODO: Once PyGObject supports Gtk templates, use that
win = Gtk.Window(application=app, default_width=600, default_height=300)
headerbar = Gtk.HeaderBar(visible=True, show_close_button=True, title='Hello, World!')
win.set_titlebar(headerbar)
label = Gtk.Label(visible=True, label='Hello, World!')
win.add(label)
win = Window(application=app, default_width=600, default_height=300)
return win
def on_activate(app):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment