I have minimal code in python kivy + pywin32. I use the CreateRoundRectRgn function to create a region with rounded corners, and then assign this region to my window via SetWindowRgn. How to remove artifacts on corners?
import os
import win32con
import win32gui
import win32api
os.environ['PYTHONFAULTHANDLER'] = '1'
from additive import createDirs, writer
createDirs(["config",], True)
writer(0, 1)
from kivy.app import App
from kivy.core.window import Window
from kivy.uix.screenmanager import ScreenManager, FadeTransition
from kivy.lang.builder import Builder
from kivy.uix.floatlayout import FloatLayout
def resource_path(relative_path):
try:
base_path = sys._MEIPASS
except Exception:
base_path = os.path.abspath(".")
return os.path.join(base_path, relative_path)
TemplateDir = resource_path('styles/')
for file in os.listdir(TemplateDir):
Builder.load_file(TemplateDir+file)
from LocalScreen import LocalScreen as LS
from userWidgets import TB
class FastMessageApp(App):
def __init__(self, **kwargs):
super(FastMessageApp, self).__init__(**kwargs)
Window.clearcolor = (0.1, 0.1, 0.1, 1)
Window.size = (500, 400)
Window.set_title("FastMessage")
self.HWND = win32gui.FindWindow(None, "FastMessage")
self.RoundedRegion = win32gui.CreateRoundRectRgn(0, 0, 500, 400, 50, 50)
win32gui.SetWindowRgn(self.HWND, self.RoundedRegion, True)
win32gui.SetWindowLong(self.HWND, win32con.GWL_EXSTYLE, win32gui.GetWindowLong(self.HWND, win32con.GWL_EXSTYLE) | win32con.WS_EX_LAYERED)
win32gui.SetLayeredWindowAttributes(self.HWND, win32api.RGB(0,0,0), 255, win32con.LWA_ALPHA)
self.__Manager = ScreenManager(transition = FadeTransition(duration=0.1), size_hint = (1,0.95), pos_hint = {'bottom': 1})
def build(self):
self.__Window = FloatLayout()
self.__Window.add_widget(TB())
self.__Window.add_widget(self.__Manager)
return self.__Window
if __name__ == "__main__":
app = FastMessageApp()
app.run()
I tried to reduce the radius of the rounding, but the size of the artifacts remained the same, although there were fewer of them.
I also tried to call the ExtSelectClipRgn function from GDI via ctypes, but none of the flags helped me.