<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.1 -->
>
>
>
import gi
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk
def btn1_callback(inst):
print("hello")
builder = Gtk.Builder()
builder.add_from_file('hello.glade')
window = builder.get_object('window1')
button1 = builder.get_object('button1')
window.show()
window.connect("destroy",Gtk.main_quit)
button1.connect("pressed",btn1_callback)
Gtk.main()
运行图
参考链接:
https://pygobject.readthedocs.io/en/latest/guide/api/signals.html
https://developer.gnome.org/platform-overview/unstable/tour-summary.html.zh_CN
https://blog.csdn.net/a87b01c14/article/details/52085512