| 1 |
import gi |
| 2 |
|
| 3 |
gi.require_version("Gtk", "4.0") |
| 4 |
from gi.repository import Gtk |
| 5 |
|
| 6 |
|
| 7 |
class PictureWindow(Gtk.ApplicationWindow): |
| 8 |
def __init__(self, **kargs): |
| 9 |
super().__init__(**kargs, title="Picture Demo") |
| 10 |
|
| 11 |
# Let's set a windows size so pictures don't start at their default size |
| 12 |
self.set_default_size(500, 400) |
| 13 |
|
| 14 |
box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=6) |
| 15 |
self.set_child(box) |
| 16 |
|
| 17 |
label = Gtk.Label(label="Here we can see some nice pictures:") |
| 18 |
box.append(label) |
| 19 |
|
| 20 |
picture = Gtk.Picture.new_for_filename("../images/spinner_ext.png") |
| 21 |
box.append(picture) |
| 22 |
|
| 23 |
cover_picture = Gtk.Picture.new_for_filename("../images/spinner_ext.png") |
| 24 |
cover_picture.props.content_fit = Gtk.ContentFit.COVER |
| 25 |
box.append(cover_picture) |
| 26 |
|
| 27 |
|
| 28 |
def on_activate(app): |
| 29 |
win = PictureWindow(application=app) |
| 30 |
win.present() |
| 31 |
|
| 32 |
|
| 33 |
app = Gtk.Application(application_id="com.example.App") |
| 34 |
app.connect("activate", on_activate) |
| 35 |
|
| 36 |
app.run(None) |