Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/test_menu_item.py
blob: 6011cb8ddd233739984f51e066849c0f57d25199 (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

from gi.repository import Gtk

class MenuTest(Gtk.Window):

    def __init__(self):
        super(MenuTest, self).__init__()

        self.set_title("Click the menu to update the counter!")

        mb = Gtk.MenuBar()
        menu_item = Gtk.MenuItem("Add 1")
        menu_item.connect("activate", self.on_menu_item_activate)
        mb.append(menu_item)

        vbox = Gtk.VBox()
        vbox.pack_start(mb, False, False, 0)
        self.add(vbox)
        self.label = Gtk.Label('Test!')
        vbox.pack_start(self.label, False, False, 0)

        self.connect("destroy", Gtk.main_quit)
        self.show_all()
        self._counter = 0

    def on_menu_item_activate(self, widget):
        self._counter += 1
        self.label.set_text(str(self._counter))


MenuTest()
Gtk.main()