简体   繁体   中英

How to keep an Ursina window always on top?

I am using the Python Ursina game engine to make a 3D character. I want to keep the window always on top, like a picture-in-picture video. How would I do this, currently my code is as follows...

from ursina import *

app = Ursina()

cube = Entity(model='cube')

def update():
    cube.rotation_y += 1

app.run()

The code runs fine, but it is always behind the other windows I open. Any advice or solutions out there?

You can use win32 gui

import win32gui
def windowEnumerationHandler(hwnd, top_windows):
    top_windows.append((hwnd, win32gui.GetWindowText(hwnd)))
if __name__ == "__main__":
    results = []
    top_windows = []
    win32gui.EnumWindows(windowEnumerationHandler, top_windows)
    for i in top_windows:
        if "window name" in i[1].lower():
            print i
            win32gui.ShowWindow(i[0],5)
            win32gui.SetForegroundWindow(i[0])
            break

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM