Python EasyGUI - 多选框
多选框:用于在EasyGUI中显示一个有多个选项的窗口,即项目,它可以用于需要在一组项目中选择多个项目,它由标题、要显示的消息、组项目和按钮,即“取消”、“全选”、“全部清除”、“确定”按钮来确认项目的选择。它类似于选择框,但与选择框不同的是,在多选框中,我们可以一次选择多个项目。下面是选择框的样子
In order to do this we will use multchoicebox method
Syntax : multchoicebox(message, title, choices)
Argument : It takes 3 arguments, first string i.e message/information to be displayed, second string i.e title of the window and third is list of strings i.e items
Return : It returns the list of display text of the selected items else None
例子 :
在此我们将创建一个包含多个项目的多选框,当任何项目被确认时,它将根据项目在屏幕上显示特定的消息,下面是实现
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)
输出 :