| 1 |
import gi |
| 2 |
|
| 3 |
gi.require_version("Gtk", "4.0") |
| 4 |
from gi.repository import Gtk |
| 5 |
|
| 6 |
|
| 7 |
class NotebookWindow(Gtk.Window): |
| 8 |
def __init__(self, **kargs): |
| 9 |
super().__init__(**kargs, title="Simple Notebook Example") |
| 10 |
|
| 11 |
notebook = Gtk.Notebook() |
| 12 |
self.set_child(notebook) |
| 13 |
|
| 14 |
page1 = Gtk.Box() |
| 15 |
page1.append(Gtk.Label(label="Default Page!")) |
| 16 |
notebook.append_page(page1, Gtk.Label(label="Plain Title")) |
| 17 |
|
| 18 |
page2 = Gtk.Box() |
| 19 |
page2.append(Gtk.Label(label="A page with an image for a Title.")) |
| 20 |
notebook.append_page(page2, Gtk.Image(icon_name="help-about")) |
| 21 |
|
| 22 |
|
| 23 |
def on_activate(app): |
| 24 |
# Create window |
| 25 |
win = NotebookWindow(application=app) |
| 26 |
win.present() |
| 27 |
|
| 28 |
|
| 29 |
app = Gtk.Application(application_id="com.example.App") |
| 30 |
app.connect("activate", on_activate) |
| 31 |
|
| 32 |
app.run(None) |