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

前端 未结 4 1467
灰色年华
灰色年华 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:45

    Other answers show that the return value indicates what button is pressed, but if you don't want to look up all the constant values use pywin32, which has already wrapped much of the Windows API for you (Demo in Chinese to show it is calling Unicode API):

    #coding:utf8
    import win32api
    import win32con
    result = win32api.MessageBox(None,'你是美国人吗?','问题',win32con.MB_YESNO)
    if result == win32con.IDYES:
        print('是')
    else:
        print('不是')
    

提交回复
热议问题