原文地址:http://hi.baidu.com/hjsr1108/item/7e05e1cd206da32a46d5c08c
基础要像磐石...夯实原理
EasyGui是基于TKinter的,所以可以跨平台使用。使用方法很简单,下载之后解压把easygui.py放到python安装目录下的lib/site-packages/下面或者运行安装:D:\resources\tools\easygui-0.96>setup.py install。如果要使用一些特殊的,记得将这些.py考到你的工程中,比如要使用easygui,就得将easygui.py考到你的工程中。
下面这个例子显示如何import,如何赋值,如何使用while循环和if判断语句,以及如何使用简单的gui工具easygui和函数random:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
import easygui, random secret = random.randint( 1 , 10 ) guess = 0 tries = 0 easygui.msgbox( "Please click 'Start' to start guess! Please try 1 to 10 numbers." + "You have 5 times to try" , title = "Lucky" ,ok_button = "Start" ) while guess ! = secret and tries < 5 : guess = int (easygui.integerbox( "Please input your lucky number: " , title = "Lucky" )) if not guess: break tries = tries + 1 if guess < secret: easygui.msgbox( "Lower, please try again! " + "You have tried " + str (tries) + " times, you only have " + str ( 5 - tries) + " times left" ) elif guess > secret: easygui.msgbox( "Larger, please try again! " + "You have tried " + str (tries) + " times, you only have " + str ( 5 - tries) + " times left" ) if guess ! = secret: easygui.msgbox( "You have tried " + str (tries) + " times, still guess wrong!" ) if guess = = secret: easygui.msgbox( "Guess Right! " + "The secret number is " + str (secret) + ". You tried " + str (tries) + " times to find it" ) |
Details for easygui, please check the link: http://www.ferg.org/easygui/tutorial.html
可以通过调用windows的
import ctypes
ctypes.windll.user32.MessageBoxA(0, 'xxxxx', 'hi', 0)