Init
This commit is contained in:
commit
ddb1e7b804
|
@ -0,0 +1,72 @@
|
|||
import math
|
||||
import sys
|
||||
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk # noqa
|
||||
import cairo # noqa
|
||||
|
||||
|
||||
class TestWin(Gtk.Window):
|
||||
WINDOW_POPUP = 1
|
||||
|
||||
def __init__(self):
|
||||
Gtk.Window.__init__(self, type=self.WINDOW_POPUP)
|
||||
|
||||
self._default_monitor = 0
|
||||
self.make_fullscreen()
|
||||
self.label = Gtk.Label(label="Hallo! :)")
|
||||
self.label.show()
|
||||
self.add(self.label)
|
||||
|
||||
self.make_rgba()
|
||||
self.set_app_paintable(True)
|
||||
self.connect("draw", self.on_draw)
|
||||
|
||||
self.show()
|
||||
self.make_untouchable()
|
||||
|
||||
def make_rgba(self):
|
||||
self.screen = self.get_screen()
|
||||
self.visual = self.screen.get_rgba_visual()
|
||||
if self.visual is None or not self.screen.is_composited():
|
||||
print("ERROR: You do not appear to be running a composite manager")
|
||||
sys.exit(1)
|
||||
else:
|
||||
self.set_visual(self.visual)
|
||||
|
||||
def make_fullscreen(self):
|
||||
geo = self.get_screen_size(self._default_monitor)
|
||||
self.move(geo.x, geo.y)
|
||||
self.resize(geo.width, geo.height)
|
||||
|
||||
def get_screen_size(self, monitor):
|
||||
return self.get_screen().get_monitor_geometry(monitor)
|
||||
|
||||
def on_draw(self, widget, cr):
|
||||
# make everything transparent
|
||||
cr.set_source_rgba(1.0, 1.0, 1.0, 0.1)
|
||||
cr.set_operator(cairo.OPERATOR_SOURCE)
|
||||
cr.paint()
|
||||
cr.set_operator(cairo.OPERATOR_OVER)
|
||||
|
||||
# draw the circle
|
||||
w, h = self.get_size()
|
||||
cr.translate(w / 2, h / 2)
|
||||
cr.set_source_rgba(0.7, 0.3, 0.0, 0.6)
|
||||
cr.arc(0, 0, 10, 0, 2 * math.pi)
|
||||
cr.stroke_preserve()
|
||||
cr.fill()
|
||||
|
||||
def make_untouchable(self):
|
||||
self.input_shape_combine_region(cairo.Region(cairo.RectangleInt(0, 0, 0, 0)))
|
||||
|
||||
def run(self):
|
||||
Gtk.main()
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app = TestWin()
|
||||
sys.exit(app.run())
|
Loading…
Reference in New Issue