Created
April 27, 2020 03:29
-
-
Save LiraNuna/5fd22c218af27ffac4ead0b94c8610d1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import cairo | |
import gi | |
gi.require_version('Gtk', '3.0') | |
from gi.repository import Gtk, Gdk | |
class AppWindow(Gtk.ApplicationWindow): | |
def __init__(self, *args, **kwargs): | |
super().__init__(*args, **kwargs) | |
self.set_size_request(500, 500) | |
label = Gtk.Label(label="指针穿透窗体") | |
self.add(label) | |
self.set_keep_above(True) | |
self.set_app_paintable(True) | |
# self.set_decorated(False) | |
screen: Gdk.Screen = self.get_screen() | |
visual = screen.get_rgba_visual() | |
self.set_visual(visual) | |
def do_map_event(self, *args): | |
orig_x = self.get_allocated_width() | |
orig_y = self.get_allocated_height() | |
rect = cairo.RectangleInt(x=orig_x, y=orig_y, width=self.get_allocated_width(), | |
height=self.get_allocated_height()) | |
region = cairo.Region(rect) | |
self.input_shape_combine_region(region) | |
# self.shape_combine_region(region) | |
class Application(Gtk.Application): | |
def __init__(self, *args, **kwargs): | |
super().__init__(*args, application_id="org.example.myapp", | |
**kwargs) | |
self.window = None | |
def do_activate(self): | |
if not self.window: | |
self.window = AppWindow(application=self, | |
title="指针穿透窗体", type=Gtk.WindowType.TOPLEVEL) | |
self.window.show_all() | |
self.window.present() | |
if __name__ == "__main__": | |
app = Application() | |
app.run(sys.argv) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
sudo apt-get update sudo apt-get install python3-venv python3-dev build-essential libcairo2-dev libgirepository1.0-dev python3.6 -m venv venv source venv/bin/activate pip install -U wheel pip pip install PyGObject wget https://gist.githubusercontent.com/LiraNuna/5fd22c218af27ffac4ead0b94c8610d1/raw/eb6e5e2bf1a3ad99679a0bd77573fd6b631015ff/script.py python script.py