📜  Python EasyGUI – 是 否 框

📅  最后修改于: 2022-05-13 01:54:34.220000             🧑  作者: Mango

Python EasyGUI – 是 否 框

Yes No Box :用于在 EasyGUI 中显示一个窗口有两个选项 yes 或 no,它可以用于需要以 yes 或 no 的形式得到问题答案的地方,它显示两个选项 yes 或no 例如,当我们想询问用户天气他是否在 18 岁以上时,我们将使用 yes no 框,类似于继续取消框,下面是继续取消框的外观

例子 :
在此我们将创建一个是否框,当按下任何按钮时,它将在屏幕上显示特定消息,下面是实现

# importing easygui module
from easygui import *
  
# message / information to be displayed on the screen
message = "Are you a Geek ?"
  
# title of the window
title = "GfG - EasyGUI"
  
# creating a yes no box
output = ynbox(message, title)
  
  
# if user pressed yes
if output:
      
    # message / information to be displayed on the screen
    message = "Thats Great !!"
   
    # title of the window
    title = "GfG - EasyGUI"
   
    # creating a message box
    msg = msgbox(message, title)
  
# if user pressed No
else:
      
    # message / information to be displayed on the screen
    message = "You should become a Geek, go to GeeksforGeeks to become one"
   
    # title of the window
    title = "GfG - EasyGUI"
   
    # creating a message box
    msg = msgbox(message, title)
      
     

输出 :


另一个例子 :
在此我们将创建一个是否框并为是和否按钮设置特定选择,当按下任何按钮时,它将在屏幕上显示特定消息,以下是实现

# importing easygui module
from easygui import *
  
# message / information to be displayed on the screen
message = "Are you a Geek ?"
  
# title of the window
title = "GfG - EasyGUI"
  
# choices for yes and no button
choices = ["Agree", "Disagree"]
  
# creating a yes no box
output = ynbox(message, title, choices)
  
  
# if user pressed yes
if output:
      
    # message / information to be displayed on the screen
    message = "Thats Great !!"
   
    # title of the window
    title = "GfG - EasyGUI"
   
    # creating a message box
    msg = msgbox(message, title)
  
# if user pressed No
else:
      
    # message / information to be displayed on the screen
    message = "You should become a Geek, go to GeeksforGeeks to become one"
   
    # title of the window
    title = "GfG - EasyGUI"
   
    # creating a message box
    msg = msgbox(message, title)
      
     

输出 :