V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
oldbird
V2EX  ›  Python

Python 脚本运行时如何弹出 yesno 对话框

  •  
  •   oldbird · 2021-02-27 15:59:34 +08:00 · 2212 次点击
    这是一个创建于 1125 天前的主题,其中的信息可能已经有所发展或是发生改变。

    tkinter.messagebox.askyesno 可以,但同时会弹出一个单独的窗体,如何只弹出 yesno 对话框?

    4 条回复    2021-02-28 08:24:22 +08:00
    ClericPy
        1
    ClericPy  
       2021-02-27 16:20:27 +08:00
    如果不介意第三方, 我之前用的 pymsgbox
    介意的话, 忘记了...
    delectate
        2
    delectate  
       2021-02-27 18:25:23 +08:00
    #import ctypes;

    #dll = ctypes.WinDLL('user32.dll');

    #dll.MessageBox();
    #need install pywin32
    import win32api, win32gui
    import win32con, winerror,win32event,pywintypes
    import sys, os,time
    win32api.MessageBox(0,'hello', 'messagebox',win32con.MB_OK)

    #import win32api,win32con
    usr_select = win32api.MessageBox(0, "这是一个测试消息", "消息框标题",win32con.MB_YESNO)
    if usr_select ==6:
    print("click yes")
    zictos
        3
    zictos  
       2021-02-27 20:10:06 +08:00
    import tkinter
    import tkinter.messagebox as messagebox

    root = tkinter.Tk()
    root.withdraw()
    print(messagebox.askokcancel("标题","内容"))
    oldbird
        4
    oldbird  
    OP
       2021-02-28 08:24:22 +08:00
    @zictos @ClericPy @delectate 谢谢各位。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2995 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 14:42 · PVG 22:42 · LAX 07:42 · JFK 10:42
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.