module Gtk::WidgetTemplate
Overview
Module used to implement widgets using XML templates.
The example below creates a window with the widgets defined by the XML file widget_template.ui
@[Gtk::UiTemplate(file: "#{__DIR__}/widget_template.ui")]
class ExampleAppWindow < Gtk::ApplicationWindow
include Gtk::WidgetTemplate
end
app = Gtk::Application.new("hello.example.com", Gio::ApplicationFlags::None)
app.activate_signal.connect do
window = ExampleAppWindow.new
window.application = app
window.present
end
exit(app.run)
You can also load the UI file from a resource by using resource
instead of file
on Gtk::UiTemplate
parameter.