当我通过pysdl2玩sdl2时,我注意到了一个奇怪的副作用:一旦sdl脚本运行不相关的窗口,这些窗口通常在移动时变成半透明的,现在却保持不透明。在
I wouldn't mind all that much if it weren't for the nagging feeling that this indicates that I'm doing something fundamentally wrong.
有谁能告诉我这里到底发生了什么?
这是我的剧本:
import sdl2
import sdl2.ext as se
import time
def main():
k = 2
event_buffer = (k * sdl2.SDL_Event)()
se.init()
window = se.Window("what the ?", size=(400, 300))
window.show()
while True:
window.refresh()
time.sleep(0.01)
sdl2.SDL_PumpEvents()
sdl2.SDL_PeepEvents(event_buffer, k, sdl2.SDL_GETEVENT,
sdl2.SDL_FIRSTEVENT, sdl2.SDL_LASTEVENT)
for event in event_buffer:
if not event.type:
continue
elif event.type == sdl2.SDL_QUIT:
se.quit()
break
else:
pass
event.type = 0
else:
continue
break
if __name__ == '__main__':
main()
下面是前屏和后屏:
未运行sdl脚本的myKDE 5.45.0
桌面的系统设置窗口,显示相关设置桌面Effects>Translucency
。请注意窗口是如何半透明的,因为我在拍照时拖动它。在
相同,但运行sdl脚本。请注意,尽管我用力拖动窗口,但它始终保持不透明。在
我也可以用Unity在我的Ubuntu桌面上复制这个,所以这绝对不是你的KDE桌面的问题。我认为这是pysdl2中的一个bug,在得到修复之前,这个解决方案应该是一个临时的解决方案,但同时,您可以将它添加到while循环中:
此问题已在此处报告:https://github.com/marcusva/py-sdl2/issues/139
相关问题 更多 >
编程相关推荐