-
Notifications
You must be signed in to change notification settings - Fork 0
/
testViewer.py
executable file
·56 lines (42 loc) · 1.35 KB
/
testViewer.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#! /usr/bin/python3
# application: RespView
# author: Krzysztof Czarnecki
# email: czarnecki.krzysiek@gmail.com
# brief: viewers for respiration signal
# opensource licence: LGPL-2.1
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import GObject
from gi.repository import Gtk
from respTools import drawPixBuf
from respViewer import RespViewer
from random import randint
class TestScreen(RespViewer):
title = "Test Viewer"
def __init__(self, width, height):
super(TestScreen, self).__init__(self.title, width, height)
self.img = Gtk.Image()
GObject.timeout_add(100, self.on_timeout)
ebox = Gtk.EventBox()
ebox.connect('button-press-event',
self.on_clicked_mouse)
self.fix.put(ebox, 0,0)
ebox.add(self.img)
self.show_all()
def refresh(self):
gen = range(3 * self.width * self.height)
data = [randint(0, 255) for index in gen]
pbuf = drawPixBuf(data, self.width, self.height)
self.img.set_from_pixbuf(pbuf)
while Gtk.events_pending():
Gtk.main_iteration()
def on_timeout(self, data=None):
self.refresh()
return True
try:
args = 400, 100
win = TestScreen(*args)
Gtk.main()
print("end..")
except KeyboardInterrupt:
print("break..")