forked from akkana/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtransimageviewer.py
executable file
·46 lines (36 loc) · 1.38 KB
/
transimageviewer.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
#!/usr/bin/env python
# A translucent window that passes events through.
# To see this under openbox, run xcompmgr -c -t-6 -l-6 -o.2 &
# or whatever compositor you prefer.
# Copyright 2017 by Akkana Peck, share and enjoy under the GPLv2 or later.
import cairo
import gtk
from imageviewer import ImageViewerWindow
import sys
import os
import math
class TransImageViewerWindow(ImageViewerWindow):
def __init__(self, file_list=None, width=1024, height=768):
super(TransImageViewerWindow, self).__init__(file_list, width, height)
self.connect("configure-event", self.expose)
self.connect("key-press-event", self.key_press_event)
self.set_opacity(.5)
def expose(self, widget, event):
# Set our shape mask, so mouse events pass through
# to the window underneath.
if self.is_composited():
region = gtk.gdk.region_rectangle(gtk.gdk.Rectangle(0, 0, 1, 1))
self.window.input_shape_combine_region(region, 0, 0)
else:
print "Not composited"
def key_press_event(self, widget, event):
'''Handle a key press event anywhere in the window'''
if event.string == " ":
imagewin.next_image()
return
if event.string == "q":
gtk.main_quit()
return
if __name__ == '__main__':
win = TransImageViewerWindow(sys.argv[1:])
win.run()