简体   繁体   中英

Is there a way to make the message box show up in front of a PyGame Window?

For school, we have to code this dumb zombies game but whatever, onto the question.

I'm using the module 'ctypes' to get a message box in python but whenever we use it, the message box is showing up below the PyGame Window, which is really annoying, because we have to click on the tab at the bottom and it's just a glorified pain. Here's the code:

answer = ctypes.windll.user32.MessageBoxW(0, "Save survivor using ammo?", "Oh no, a zombie is approaching!", 4)
if answer == 6:
    survivor()
    ammo -= 1

It's a prompt that asks to save the survivor or abandon them, but the message box keeps showing up at the bottom. Is there some kind of parameter that I can apply that puts it in front of the pygame window?

MessageBox supports the uType flag MB_TOPMOST ( 0x00040000 ):

MB_YESNO = 4
MB_TOPMOST = 0x40000
uType = MB_YESNO | MB_TOPMOST
answer = ctypes.windll.user32.MessageBoxW(
    0, "Save survivor using ammo?", "Oh no, a zombie is approaching!", uType)

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