-
Notifications
You must be signed in to change notification settings - Fork 6
/
base.py
37 lines (26 loc) · 994 Bytes
/
base.py
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
#!/usr/bin/env python
# - coding: utf-8 -
# Copyright (C) 2018 Tom Striker <[email protected]>
"""Base template"""
from gi.repository import Gtk as gtk
from lib import graphics
class Scene(graphics.Scene):
def __init__(self):
graphics.Scene.__init__(self)
self.connect("on-enter-frame", self.on_enter_frame)
def on_enter_frame(self, scene, context):
# you could do all your drawing here, or you could add some sprites
g = graphics.Graphics(context)
# self.redraw() # this is how to get a constant redraw loop (say, for animation)
class BasicWindow:
def __init__(self):
window = gtk.Window()
window.set_default_size(600, 500)
window.connect("delete_event", lambda *args: gtk.main_quit())
window.add(Scene())
window.show_all()
if __name__ == '__main__':
window = BasicWindow()
import signal
signal.signal(signal.SIGINT, signal.SIG_DFL) # gtk3 screws up ctrl+c
gtk.main()