summaryrefslogtreecommitdiffstats
path: root/tests/manual/xembed-widgets/gtk-embedder.py
blob: b3b7b8c433d3d65a6490d6bc2620c48422eed11b (plain)
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
#!/usr/bin/python
# Copyright (C) 2013 Canonical Ltd.
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

from gi.repository import Gtk
from subprocess import Popen

window = Gtk.Window()

box = Gtk.VBox(False, 0)
window.add(box)

child = None
def on_button_clicked(button, socket):
    global child
    child = Popen(['./lineedits', str(socket.get_id())])

button = Gtk.Button("Press me to embed a Qt client")
box.pack_start(button, False, False, 0)

entry = Gtk.Entry()
box.pack_start(entry, False, False, 0)

socket = Gtk.Socket()
socket.set_size_request(200, 200)
box.add(socket)

button.connect("clicked", on_button_clicked, socket)
window.connect("destroy", Gtk.main_quit)

def plugged_event(widget):
    print("A window was embedded!")

socket.connect("plug-added", plugged_event)

window.show_all()
Gtk.main()
if child:
    child.terminate()