File: window.py

package info (click to toggle)
bzr-gtk 0.103.0+bzr792-3
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 1,524 kB
  • sloc: python: 9,616; makefile: 16; sh: 10
file content (23 lines) | stat: -rw-r--r-- 645 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

from gi.repository import Gdk
from gi.repository import Gtk


class Window(Gtk.Window):

    def __init__(self, parent=None):
        super(Window, self).__init__(type=Gtk.WindowType.TOPLEVEL)
        self._parent = parent

        self.connect('key-press-event', self._on_key_press)

    def _on_key_press(self, widget, event):
        keyname = Gdk.keyval_name(event.keyval)
        if event.get_state() & Gdk.ModifierType.CONTROL_MASK:
            if keyname is "w":
                self.destroy()
                if self._parent is None:
                    Gtk.main_quit()
            elif keyname is "q":
                Gtk.main_quit()