How to specify what actually happens when Yes/No is clicked with ctypes MessageBoxW?

前端 未结 4 1461
灰色年华
灰色年华 2020-12-18 12:22
def addnewunit(title, text, style):
    ctypes.windll.user32.MessageBoxW(0, text, title, style)

Ive seen a lot of people show this code, however no

4条回答
  •  佛祖请我去吃肉
    2020-12-18 12:52

    You set the answer as equal to the command, like so:

    import ctypes
    answer = ctypes.windll.user32.MessageBoxW(0, "Message", "Title", 4) 
    

    Then you can just use

    print(answer)

    to see what number is the outcome of the user's choice.

    Then use an "If" statement based on what the answer number is to make it do what you want.

提交回复
热议问题