µÚÒ»´ÎдÍêÕûµÄPython GUI³ÌÐò
Ò¹ÀïÓÃÍâ¹ÒÈÝÒ×±»²é£¬Òò´ËÏëÈòËÊìµÄʱ¼ä¼¯Öе½°×Ì죬ÿ´Î¶¼Òª¿ÚË㣬Âé·³£¬ÕýºÃ¸Õ¸ÕѧÁËwxPython£¬Ò»Ê±ÊÖÑ÷£¬À´×Ô¼ºÐ´¸ö°É¡£Ëä˵´¿Êô×ÔÓé×ÔÀÖ£¬µ«Ò²Ñ§µ½²»ÉÙ¶«Î÷¡£ÏÖ¼ÇÓÚÏ¡£
1. ¹ØÓÚPythonµÄGUIÉè¼Æ
Ò»Ö±ÒÔÀ´¶¼Ã»ÓÐÒ»¸ö×ã¹»ºÃµÄKiller IDE£¬ÕâÒ²¹Ö²»µÃ£¬Ã»ÓÐÒ»¸ö×㹻ǿ´óµÄºǫ́£¬ÒªÏë×ö³ÉÖØÁ¿¼¶µÄIDE̸ºÎÈÝÒ×£¨ÒªÊÇGoogleÀÒ»°Ñ¾ÍºÃÁË£¬¿ÉϧGoogle³öÁË×Ô¼ºµÄÓïÑÔ£©¡£
ÊÔ¹ýÎÞÊýÉè¼ÆÆ÷£¬×îÖÕ»¹ÊǾõµÃBoa Constructor²»´í£¬ËäÈ»ËüµÄ½çÃæÏ൱³óª£¨·ÂЧDelphiÓַµò»ºÃ£¬¶«Ê©Ð§ò£¬´°¿Ú±»²ð³É4¡¢5¸ö£¬ÓÖͬ²½µÃ²»ºÃ£¬º¦µÃÎÒ²»Í£µØÒªÇл»ËüÃÇ£©£»ËäÈ»Ëü¼¸ºõ¾Í²»Ö§³ÖÖÐÎÄ£»ËäÈ»Ëü»¹ÊÇ07Äê¸üйý¡£¡£¡£
µ«ÒѾÊÇÕâЩµ±ÖÐ×îºÃÓõÄÁË¡£
Õë¶ÔÒÔÉϵIJ»×㣬ÎÒÖ»ºÃÔö¼ÓÈËÊÖ°ïæÁË£º
ÓÃBoa¹¹½¨´¿GUI£¬¼¸ºõûÓÐÈκÎÒµÎñÂß¼¡£ÁíÍâÔÚBoaÉú³ÉµÄÎļþÖÐ_init_ctrls
ÀïÃæµÄ´úÂëÒ»¶¨±ðÈ¥ÅöËü£¬·ñÔò»áÔì³ÉFrame DesignerÎÞ·¨¼ÓÔØ£¬¶øÕâ¾ÍÊÇBoa×îÓмÛÖµµÄËùÔÚÁË¡£µ«BoaûÓÐʲô´úÂëÌáʾ£¬±à¼¹¦ÄÜÒ²±ÈÏÂÃæÁ½ÕßÈõ²»ÉÙ£¬¾ÍÖ»ÓÃËüÀ´×öGUIÁË¡£
ÒµÎñÂß¼µÄ´úÂëÓÃPyDev£¬ÕâÊǸö·Ç³£ÓÅÐãµÄIDE£¬»ùÓÚEclipse£¬´Ë´ÎÎÒҲѧϰµ½ÁËËü¸ü¶àµÄÓ÷¨¡££¨ÈçEdit->Set Encoding¡¢ÔÚSrcÉÏÓÒ¼üRefreshµÈµÈ£©
ÐÞ¸ÄBoaÉú³ÉµÄPython´úÂëÎÒÓÃPyScripter£¬ÔÒòÓÐÈý£ºÃ»ÕÒµ½EclipseÔõô¼ÓÈëËü£¨Ì«±¿£¬ºóÀ´Ãþ³öÀ´ÊÇSrcÉÏÓÒ¼üRefresh£©¡¢Ð޸ıàÂë¸ñʽ£¨ÏÖÔÚÖªµÀ¿ÉÒÔÓÃEclipseµÄSet Encoding£©¡¢¶ÔwxPythonµÄº¯ÊýÌáʾ֧³Ö±ÈEclipseºÃ£¨ÕâÒ»µãÎÒÄ¿Ç°»¹Ã»ÕÒµ½ºÃµÄ½â¾ö·½·¨£©¡£
ÔÙ˵PyScripter»¹Óиö±ÈIDLEºÃÓõöàµÄÃüÁîÐй¤¾ß¡£ÁíÍâÓÃËü¶ÔһЩ¹¦ÄÜ×ö×ö²âÊÔÒ²²»´í¡£
ÈýÕßÅäºÏ£¬ÔÙ¼ÓÉÏwxPythonµÄDemonstration¡¢PythonµÄ¹Ù·½Îĵµ£¬ÒÔ¼°ÍòÄܵÄGoogle£¬¿ª·¢ÆðÀ´»¹Ëã²»´íÁË¡£
2. ¹ØÓÚPythonÓïÑÔѧµ½µÄ
¢Ù½«GUIÓëÒµÎñÂß¼¼¸ºõ£¨´ó¸Å90%£©ÍêÈ«·Ö¿ª£¬´ÓÖÐÌå»áµ½ÁËÕâÖÖÉè¼Æ¶ÔÓÚ²âÊԵķ½±ãÐÔ¡¢ÒµÎñÓëGUI·ÖÀë´øÀ´µÄ´úÂëÇåÎú¡£
¢ÚÀàµÄ¾²Ì¬·½·¨£º
@staticmethod
def GetCurrentTime(): pass
¢ÛÓÃdatetime¶Ôʱ¼ä½øÐз½±ãµÄ¼Ó¼õ£º
import datetime
#¹ýahourСʱaminute·ÖÖÓÖ®ºóÊÇʲôʱ¼ä
dt = datetime.datetime(year=2009, month=11, day=11, hour=ahour, minute=aminute)
delta = datetime.timedelta(hours = bhour)
dt += delta
print dt.strftime('%H:%M')
ÁíÍâCSDNµÄÒ»¸öÌù×ÓÖÐ˵ÓÐparse£¬Ê²Ã´Ê±ºòÊÔÊÔ¡£
¢ÜÔÚwxPythonÖÐʹÓöà¸ö¶¨Ê±Æ÷
def InitData(self):
#ËùÓеĶ¨Ê±Æ
Ïà¹ØÎĵµ£º
Á½ÖÖ²»Í¬µÄÓïÑÔ,²»Í¬µÄ±í´ï!
Python½Å±¾ÊµÏÖ.
""
"
File Name : clean.py
File Date : 2009/11/5 14:22:56
Author : DannyLai
Purpose : Cle ......
PythonÇ¿µÄ¹¦ÄܾÍÔÚÓÚËüÎÞËù²»ÄÜ¡£
ʹÓÃwin32comÄ£¿é¿ª·¢window ActiveXµÄʾÀý£º£¨Èç¹ûÄ㻹ûÓÐ×°win32comÄ£¿éµÄ»°£¬Çëµ½http://python.net/crew/skippy/win32/Downloads.htmlÏÂÔØ£©¡£
# SimpleCOMServer.py
class PythonUtilities:
_public_methods_ = ['SplitString']
_reg_progid_ = "Python.Utilities"
......
½üÀ´ÐèÒªÓÃPython¶ÔMySQLÊý¾Ý¿â½øÐвÙ×÷¡£Python¾ÃÎÅÆäÃû£¬Î´¼ûÆä“ÈË”£»Êý¾Ý¿âÔø¾ºÜ¸ß·Ö£¬ÔçÒÑ»¹¸øÏÈÉú£¬¸üÎÞMySQL¾Ñé¡£ÓÚÊÇÒ»ÇдÓÁ㿪ʼ£¬½è»úºÃºÃѧϰһ·¬¡£
PythonÕâ¸ö½Å±¾ÓïÑÔȷʵÃû¸±Æäʵ£¬ÓÃÁ˼¸Ìì±ãϲ»¶ÉÏËüÀ²¡£ºÜ¼ò½à£¬ºÜ·½±ã¡£ÒÔËõ¼õ×÷Ϊģ¿é·Ö¸î·û£¬¶ÁÆðÀ´ÉÍÐÄÔÃÄ¿¡£pythonµÄÄÚ½¨Êý¾ÝÀàÐÍ£¨ ......
1£®»ñµÃµ±Ç°Â·¾¶
ÔÚPythonÖпÉÒÔʹÓÃos.getcwd()º¯Êý»ñµÃµ±Ç°µÄ·¾¶¡£ÆäÔÐÍÈçÏÂËùʾ¡£
os.getcwd()
¸Ãº¯Êý²»ÐèÒª´«µÝ²ÎÊý£¬Ëü·µ»Øµ±Ç°µÄĿ¼¡£ÐèҪ˵Ã÷µÄÊÇ£¬µ±Ç°Ä¿Â¼²¢²»ÊÇÖ¸½Å±¾ËùÔÚµÄĿ¼£¬¶øÊÇËùÔËÐнű¾µÄĿ¼¡£ÀýÈ磬ÔÚPythonWinÖÐÊäÈëÈçϽű¾¡£
>>> import os
>>> print 'current director ......
½ñÌìÓÖɨÁËÒ»±éÊý×ÖÕâÒ»ÕÂ.. ¿´µ½ÁËround()º¯Êý, ÊÇÔÚpythonºËÐıà³Ì˼ÏëµÄ5.6.2½ÚµÄĩβ, ÔÎÄÈçÏÂ:
round(flt, ndig=0) ½ÓÊÜÒ»¸ö¸¡µãÊý flt ²¢¶ÔÆäËÄÉáÎåÈ룬±£´æ ndigλСÊý¡£
Èô²»Ìṩndig ²ÎÊý£¬ÔòĬÈÏСÊýµãºó0λ¡£
round()½öÓÃÓÚ¸¡µãÊý¡££¨ÒëÕß×¢£ºÕûÊýÒ²¿ÉÒÔ£¬ ²»¹ý²¢Ã»ÓÐʲô
ʵ¼ÊÒâÒ壩
Æäʵ, ×ö¸ö浄 ......