我目前有一个PyQt5应用程序,它非常简单(只有一个按钮)。我希望它具有活力,所以我将ObjC活力代码移植到了Python中。我的振动代码如下:
frame = NSMakeRect(0, 0, * self.get_screen_size()) # get_screen_size returns the resolution of the monitor
view = objc.objc_object(c_void_p=self.winId().__int__()) # returns NSView of current window
visualEffectView = NSVisualEffectView.new()
visualEffectView.setAutoresizingMask_(NSViewWidthSizable|NSViewHeightSizable) # equivalent to: visualEffectView.autoresizingMask = NSViewW...
visualEffectView.setFrame_(frame)
visualEffectView.setState_(NSVisualEffectStateActive)
visualEffectView.setMaterial_(NSVisualEffectMaterialDark)
visualEffectView.setBlendingMode_(NSVisualEffectBlendingModeBehindWindow)
window = view.window()
window.contentView().addSubview_positioned_relativeTo_(visualEffectView, NSWindowBelow, None)
# equal to: [window.contentView addSubview:visualEffectView positioned:NSWindowBelow relativeTo:nul]
window.setTitlebarAppearsTransparent_(True)
window.setStyleMask_(window.styleMask() | NSFullSizeContentViewWindowMask) # so the title bar is also vibrant
self.repaint()
我所要做的就是绘制一个按钮:btn = QPushButton("test", self)
self
是一个继承自QMainWindow
的类,其他一切都应该是相当不重要的。
注释掉window.contentView().addSubview...
行的行为(无活力)
没有注释掉的行为(带着活力)
谢谢!
https://stackoverflow.com/questions/51452668
复制相似问题