Python 模塊EasyGui詳細介紹
前言:
在Windows想用Python開發一些簡單的界面,所以找到了很容易上手的EasyGui庫。下面就分享一下簡單的使用吧。
參考的鏈接:官網Tutorial
接下來,我將從簡單,到復雜一點點的演示如何使用這個模塊。希望能給剛接觸easygui的你一點幫助 :-)
msgBox,ccbox,ynbox
# coding:utf-8# __author__ = 'Mark sinoberg'# __date__ = '2016/5/25'# __Desc__ = 一個最簡單的類似于Java的MessageBox的小窗口import easyguititle = easygui.msgbox(msg='提示信息',title='標題部分',ok_button="OOK")msg = easygui.msgbox('Hello Easy GUI')print '返回值:' + msgccbox = easygui.ccbox("here is Continue | Cancel Box!")print '返回值:' + str(ccbox)ynbox = easygui.ynbox("Yes Or No Button Box!")print '返回值: ' + str(ynbox)
bottonbox
# coding:utf-8# __author__ = 'Mark sinoberg'# __date__ = '2016/5/25'# __Desc__ = 能讓你最初選擇的簡單的界面,第二個參數為一個列表import easygui# choice = easygui.buttonbox("這里是提示的語句信息:/n", title='三選一', choices=['one' /# , 'two', 'three'])# easygui.msgbox('您選擇了:' + str(choice))## # choices 內只能有兩個參數 ,選擇哪一個將返回1,否則返回0# bool = easygui.boolbox('msg提示信息', title='標題部分', choices=['A', 'B'])# easygui.msgbox(bool)image = 'me.jpg'msg = 'Here is my photo,a python fan also'choices = ['Yes','No',"Not Sure"]title = 'Am I handsome?'easygui.buttonbox(msg,title,image=image,choices=choices)
choicebox
# coding:utf-8# __author__ = 'Mark sinoberg'# __date__ = '2016/5/25'# __Desc__ = 從一個列表中選擇其中的一個,會有返回值的出現import easyguimsg = '選擇此列表項中你喜歡的一個吧'title = '必須選擇一個哦'choices = ['1','2','3','4','5','6','7']answer = easygui.choicebox(msg,title,choices)print '你選擇了 :' + str(answer)
enterbox
# coding:utf-8# __author__ = 'Mark sinoberg'# __date__ = '2016/5/25'# __Desc__ = 可以滿足用戶輸入的控件import easyguist = easygui.enterbox("請輸入一段文字:/n")print "您輸入了: " + str(st)
mutilchoicebox
# coding:utf-8# __author__ = 'Mark sinoberg'# __date__ = '2016/5/25'# __Desc__ = 一個多選的列表項.呵呵了,這個版本貌似有問題。我的多選并沒有真正的實現import easyguimsg = '選擇此列表項中你喜歡的一個吧'title = '必須選擇一個哦'choices = (1,2,3,4,5,6,7,8,9)answer1 = easygui.multchoicebox(msg,title,choices)for item in answer1: print item
intenterbox,passenterbox
# coding:utf-8# __author__ = 'Mark sinoberg'# __date__ = '2016/5/25'# __Desc__ = 提供給用戶簡單的輸入框,只能是給定的數字的范圍import easyguimsg = '請輸入一個數字,范圍在0-100'title = '限制為數字類型'lowerbound = 0upperbound = 100default = ''image = 'me.jpg'result = easygui.integerbox(msg,title,default,lowerbound,upperbound,image)print result
新聞熱點
疑難解答