2024-09-29 23:33:24 发布
网友
调用SetWindowCompositionAttribute确实可以将Win10的丙烯效果添加到窗口中,但我仍然无法解决一个问题,那就是如何在添加丙烯效果的同时实现圆形窗口。如下图所示,即使我在pyqt中使用win32guiSetWindowRgn(int(self.winId()),win32gui.CreateRoundRectRgn(0, 0, 500, 500, 500, 500), True),也无法裁剪丙烯酸面板。请问你有什么好主意吗
SetWindowCompositionAttribute
win32guiSetWindowRgn(int(self.winId()),win32gui.CreateRoundRectRgn(0, 0, 500, 500, 500, 500), True)
可以使用“边界半径”创建变通方法 (UpdateLayeredWindow相当于WA_半透明背景,SetWindowRgn对SetWindowCompositionAttribute模糊没有影响)
完整代码:
Stylesheet = """ #Custom_Widget { border-radius: 20px; opacity: 100; border: 8px solid #cdced4; } #closeButton { min-width: 36px; min-height: 36px; border-radius: 10px; } #closeButton:hover { color: #FFFFFF; background: red; } """ import sys from PySide2.QtWidgets import * from PySide2.QtCore import * from BlurWindow.blurWindow import GlobalBlur class MainWindow(QMainWindow): def __init__(self): super(MainWindow, self).__init__() self.setStyleSheet(Stylesheet) self.setWindowFlag(Qt.FramelessWindowHint) self.setAttribute(Qt.WA_TranslucentBackground, True) self.resize(488, 388) GlobalBlur(self.winId(),Acrylic=True,hexColor='#FFFFFF20') self.Borders() #the real MainWindow def Borders(self): window = QMainWindow(self) window.setAttribute(Qt.WA_TranslucentBackground) window.setWindowFlag(Qt.FramelessWindowHint) window.resize(500, 400) self.widget = QWidget(window) window.setCentralWidget(self.widget) self.widget.setObjectName('Custom_Widget') self.layout = QHBoxLayout(self.widget) self.layout.addWidget(QPushButton( 'X', self,clicked=exit, objectName='closeButton')) self.layout.addWidget(QLabel("<h2 style='color:blue;'>Blurry</h2>")) window.show() if __name__ == '__main__': app = QApplication(sys.argv) mw = MainWindow() mw.show() sys.exit(app.exec_())
UpdateLayeredWindow alpha示例:https://github.com/wxWidgets/Phoenix/issues/1544
SetWindowCompositionAttributeAPI不是公共的。要将一个或多个高质量效果应用于图像或一组图像,可以使用Direct2D
以下是一些有助于您入门的链接:
How to load an image into Direct2D effects using the FilePicker
Directional blur effect
Custom effects
如果您仍然想使用SetWindowCompositionAttributeAPI,我建议您在Feedback Hub上提高声音
可以使用“边界半径”创建变通方法 (UpdateLayeredWindow相当于WA_半透明背景,SetWindowRgn对SetWindowCompositionAttribute模糊没有影响)
完整代码:
UpdateLayeredWindow alpha示例:https://github.com/wxWidgets/Phoenix/issues/1544
SetWindowCompositionAttribute
API不是公共的。要将一个或多个高质量效果应用于图像或一组图像,可以使用Direct2D以下是一些有助于您入门的链接:
How to load an image into Direct2D effects using the FilePicker
Directional blur effect
Custom effects
如果您仍然想使用
SetWindowCompositionAttribute
API,我建议您在Feedback Hub上提高声音相关问题 更多 >
编程相关推荐