python的图形用户界面介绍

2022-07-18,,,

目录
  • python图形用户界面
    • msgbox的使用
    • ccbox的使用
    • buttonbox的使用
      • buttonbox添加图片
    • choicebox的使用
      • multchoicebox的使用
      • 总结

        python的图形用户界面

        我是大帅哥啊 python的图形用户界面msgbox的使用ccbox的使用buttonbox的使用buttonbox添加图片 choicebox的使用multchoicebox的使用

        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
        ###写法1###
        msg = '我是大帅哥吗?'
        title = '魔镜'
        choices = ('贼帅([1])','很帅([2])','最帅([3])')
        
        ax.buttonbox(msg,title,choices)
        ###写法2###
        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
        
        ####写法1####
        msg = '我是大帅哥吗?'
        title = '魔镜'
        choices = ('贼帅([1])','很帅([2])','最帅([3])')
        image = 'oip-c.jpg'
        ax.buttonbox(msg,title,choices,image)
        
        ###写法2###
        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)
        

        总结

        到此这篇关于python的图形用户界面介绍的文章就介绍到这了,更多相关python图形界面内容请搜索以前的文章或继续浏览下面的相关文章希望大家以后多多支持!

        《python的图形用户界面介绍.doc》

        下载本文的Word格式文档,以方便收藏与打印。