python的图形用户界面
msgbox的使用
magbox()函数显示一个消息和提供一个ok的按钮 示例1:
import easygui as AX
AX.msgbox("嗨,欢迎进入\n第一个\n界面小游戏","zhaojie")
ccbox的使用
ccbox() 函数提供一个选择:C[o]ntinue 或C[a]ncel (对应的按下键盘‘o’或键盘‘a’代替鼠标操作,[]括起来的字母就是对应的按键,当然continue和cancel也可以根据自己的需求设计)
示例2:
import easygui as AX
import sys
msg = "请问,你是大帅哥吗"
title = "魔镜"
choices = ('是([y])','不是([n])')
AX.ccbox(msg ,title,choices)
buttonbox的使用
buttonbox()函数的用法:
buttonbox(msg = '',title = '',choices = ('button[1]','butthon[2]','button[3]'),image=None,default_choice=None,cancel_choice=None,callback=None,run=True)
示例3:
import easygui as AX
import sys
msg = '我是大帅哥吗?'
title = '魔镜'
choices = ('贼帅([1])','很帅([2])','最帅([3])')
AX.buttonbox(msg,title,choices)
AX.buttonbox(msg = '我是大帅哥吗?',title = '魔镜',choices = ('贼帅([1])','很帅([2])','最帅([3])'),image=None,default_choice=None,cancel_choice=None,callback=None,run=True)
buttonbox添加图片
在buttonbox里面显示图片: 大家注意到在上面buttonbox函数里面image = None,因此只需要将None改为对应的图片就行了
import easygui as AX
import sys
msg = '我是大帅哥吗?'
title = '魔镜'
choices = ('贼帅([1])','很帅([2])','最帅([3])')
image = 'OIP-C.jpg'
AX.buttonbox(msg,title,choices,image)
AX.buttonbox(msg = '我是大帅哥吗?',title = '魔镜',choices = ('贼帅([1])','很帅([2])','最帅([3])'),image='OIP-C.jpg',default_choice=None,cancel_choice=None,callback=None,run=True)
choicebox的使用
choicebox 的使用:
choicebox(msg='',title='',choices=[],preselect=0,callback=None,run=True)
choicebox()函数提供一个可供选择的列表,
import easygui as AX
import sys
AX.choicebox(msg='谁是大帅哥?',title='摸着自己的良心说',choices=["孙行者","者行孙","行者孙"],preselect=0,callback=None,run=True)
multchoicebox的使用
multchoicebox的用法: 与choicebox的用法一样,支持多项选择
import easygui as AX
import sys
AX.multchoicebox(msg='谁是大帅哥?',title='摸着自己的良心说',choices=["孙行者","者行孙","行者孙"],preselect=0,callback=None,run=True)
|