File: Tutorial_08_gtk_ventana_boton.py

package info (click to toggle)
sugar-pippy-activity 75-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 1,660 kB
  • sloc: python: 5,786; makefile: 16; sh: 6
file content (28 lines) | stat: -rw-r--r-- 622 bytes parent folder | download | duplicates (2)
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
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk

class PyApp(Gtk.Window):
    def __init__(self):
        super(PyApp, self).__init__()

        self.set_title("Boton")
        self.set_position(Gtk.WindowPosition.CENTER_ALWAYS)
        self.set_size_request(250, 200)

        def button_cb(widget):
            print('click')

        button = Gtk.Button(label="Boton")
        fixed = Gtk.Fixed()
        fixed.put(button, 20, 30)
        button.connect('clicked', button_cb)

        self.connect("destroy", Gtk.main_quit)

        self.add(fixed)
        self.show_all()


PyApp()
Gtk.main()