add xml section

This commit is contained in:
Taiko2k
2023-05-17 22:27:27 +12:00
parent 0b68f0e3b4
commit 2dd2eb5977
4 changed files with 150 additions and 2 deletions

30
part3.py Normal file
View File

@@ -0,0 +1,30 @@
import sys
import gi
gi.require_version('Gtk', '4.0')
gi.require_version('Adw', '1')
from gi.repository import Gtk, Adw
class MyApp(Adw.Application):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.connect('activate', self.on_activate)
def on_activate(self, app):
# Create a Builder
builder = Gtk.Builder()
builder.add_from_file("test.ui")
# Obtain the button widget and connect it to a function
button = builder.get_object("button1")
button.connect("clicked", self.hello)
# Obtain and show the main window
self.win = builder.get_object("main_window")
self.win.set_application(self) # Application will close once it no longer has active windows attached to it
self.win.present()
def hello(self, button):
print("Hello")
app = MyApp(application_id="com.example.GtkApplication")
app.run(sys.argv)