📜  Python EasyGUI - 多选框

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

Python EasyGUI - 多选框

选框:用于在EasyGUI中显示一个有多个选项的窗口,即项目,它可以用于需要在一组项目中选择多个项目,它由标题、要显示的消息、组项目和按钮,即“取消”、“全选”、“全部清除”、“确定”按钮来确认项目的选择。它类似于选择框,但与选择框不同的是,在多选框中,我们可以一次选择多个项目。下面是选择框的样子

例子 :
在此我们将创建一个包含多个项目的多选框,当任何项目被确认时,它将根据项目在屏幕上显示特定的消息,下面是实现

Python3
# importing easygui module
from easygui import *
 
# message to be displayed
text = "Selected any item from the list given below"
 
# window title
title = "Window Title GfG"
 
# item choices
choices = ["Geek", "Super Geeek", "Super Geek 2", "Super Geek God"]
 
# creating a multi choice box
output = multchoicebox(text, title, choices)
 
# title for the message box
title = "Message Box"
 
# message
message = "Selected items : " + str(output)
 
# creating a message box
msg = msgbox(message, title)


Python3
# importing easygui module
from easygui import *
 
# message to be displayed
text = "Selected any item from the list given below"
 
# window title
title = "Window Title GfG"
 
 
# creating a multi choice box
output = multchoicebox(text, title)
 
# title for the message box
title = "Message Box"
 
# message
message = "Selected items : " + str(output)
 
# creating a message box
msg = msgbox(message, title)


输出 :

另一个例子 :
在此我们将创建一个不添加任何项目的多选框,当任何项目被确认时,它将根据项目在屏幕上显示特定的消息,下面是实现

Python3

# importing easygui module
from easygui import *
 
# message to be displayed
text = "Selected any item from the list given below"
 
# window title
title = "Window Title GfG"
 
 
# creating a multi choice box
output = multchoicebox(text, title)
 
# title for the message box
title = "Message Box"
 
# message
message = "Selected items : " + str(output)
 
# creating a message box
msg = msgbox(message, title)

输出 :