File: paned.py

package info (click to toggle)
gnome-devel-docs 40.3-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 79,188 kB
  • sloc: javascript: 2,514; xml: 2,407; ansic: 2,229; python: 1,854; makefile: 805; sh: 499; cpp: 131
file content (44 lines) | stat: -rw-r--r-- 1,093 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
from gi.repository import Gtk
import sys


class MyWindow(Gtk.ApplicationWindow):

    def __init__(self, app):
        Gtk.Window.__init__(self, title="Paned Example", application=app)
        self.set_default_size(450, 350)

        # a new widget with two adjustable panes,
        # one on the left and one on the right
        paned = Gtk.Paned.new(Gtk.Orientation.HORIZONTAL)

        # two images
        image1 = Gtk.Image()
        image1.set_from_file("gnome-image.png")
        image2 = Gtk.Image()
        image2.set_from_file("tux.png")

        # add the first image to the left pane
        paned.add1(image1)
        # add the second image to the right pane
        paned.add2(image2)

        # add the panes to the window
        self.add(paned)


class MyApplication(Gtk.Application):

    def __init__(self):
        Gtk.Application.__init__(self)

    def do_activate(self):
        win = MyWindow(self)
        win.show_all()

    def do_startup(self):
        Gtk.Application.do_startup(self)

app = MyApplication()
exit_status = app.run(sys.argv)
sys.exit(exit_status)