锘??xml version="1.0" encoding="utf-8" standalone="yes"?>JoinoseDemo_EVT_MOTION
]]>
紺轟緥浠g爜涓?
1)x鍙綾籶arent鍐呴儴浣跨敤,浣嗕笉鑳借瀛愮被璋冪敤
2)y鐨勪綔鐢ㄥ煙鍙槸鍦╬arent.__init__鏂規硶鍐?br />3)z鍙綾籶arent鍐呴儴浣跨敤涔熷彲琚瓙綾昏皟鐢?br />紺轟緥浠g爜濡備笅:testGlobal.py
聽1#!/usr/bin/python
聽2#聽-*-聽coding:聽utf-8聽-*-
聽3#聽Filename:聽testGlobal.py
聽4#聽Author聽聽:聽姘存櫠楸?/span>
聽5#聽Date聽聽聽聽:聽2006-06-08
聽6class聽parent:
聽7聽聽聽聽global聽x聽聽聽聽#榪欏氨鏄彧鑳戒緵綾誨唴閮ㄤ嬌鐢ㄧ殑鍙橀噺,瀛愮被涓嶈兘璁塊棶
聽8聽聽聽聽x='xxxx'聽聽聽聽#娉ㄦ剰:璧嬪間笌瀹氫箟瑕佸垎寮鍐?/span>
聽9聽聽聽聽def聽__init__(self):
10聽聽聽聽聽聽聽聽y='yyyy'
11聽聽聽聽聽聽聽聽self.z='zzzz'
12聽聽聽聽def聽test(self):
13聽聽聽聽聽聽聽聽print聽"test.x="+x
14聽聽聽聽聽聽聽聽
15class聽child(parent):
16聽聽聽聽def聽__init__(self):
17聽聽聽聽聽聽聽聽parent.__init__(self)
18
19if聽__name__=='__main__':
20聽聽聽聽#璇曞浘璁塊棶瀹炰緥涓殑x聽聽聽聽聽聽聽聽
21聽聽聽聽p=parent()
22聽聽聽聽try:
23聽聽聽聽聽聽聽聽print聽p.x
24聽聽聽聽except:
25聽聽聽聽聽聽聽聽print聽"1.涓嶈兘鐩存帴璁塊棶瀹炰緥涓殑global鍙橀噺"
26
27聽聽聽聽#鍙互渚涚被涓叾瀹冩柟娉曡闂?
28聽聽聽聽print聽'2.閫氳繃test鏂規硶鎵嶅彲浠ヨ闂畑:',
29聽聽聽聽p.test()
30
31聽聽聽聽c=child()
32聽聽聽聽#璇曞浘璁塊棶鐖剁被涓殑鍙橀噺----x,緇撴灉鏄?澶辮觸
33聽聽聽聽try:
34聽聽聽聽聽聽聽聽print聽c.x
35聽聽聽聽except:
36聽聽聽聽聽聽聽聽print聽"3.涓嶈兘璁塊棶鐖剁被涓殑global鍙橀噺"
37聽聽聽聽聽聽聽聽
38聽聽聽聽print聽"4.浣嗗彲浠ラ氳繃鐖剁被涓殑test鏂規硶寰楀埌:",
39聽聽聽聽c.test()
40
41聽聽聽聽print聽"5.鍙互璁塊棶鐖剁被涓殑self鍙橀噺",c.z
紺轟緥浠g爜杈撳嚭緇撴灉涓?
C:\Documents and Settings\Administrator\妗岄潰>testGlobal.py
1.涓嶈兘鐩存帴璁塊棶瀹炰緥涓殑global鍙橀噺
2.閫氳繃test鏂規硶鎵嶅彲浠ヨ闂畑: test.x=xxxx
3.涓嶈兘璁塊棶鐖剁被涓殑global鍙橀噺
4.浣嗗彲浠ラ氳繃鐖剁被涓殑test鏂規硶寰楀埌: test.x=xxxx
5.鍙互璁塊棶鐖剁被涓殑self鍙橀噺 zzzz
]]>
聽 Eyes 19:58:18
鎬庢牱鎺㈡祴涓涓彉閲忔槸鍚﹀瓨鍦?
姘存櫠楸?20:17:03
錛?
聽 Eyes 20:17:30
鎴戞兂鐭ラ亾涓涓彉閲忔槸鍚﹀瓨鍦?
姘存櫠楸?20:17:53
鏈夊姙娉曠殑
聽 Eyes 20:18:02
璇村晩
姘存櫠楸?20:18:29
local瀛楀吀
姘存櫠楸?20:18:50
locals()
聽 Eyes 20:19:04
璋㈣阿聽
姘存櫠楸?20:19:51
聽
渚嬪瓙錛?br />鎬庢牱鎺㈡祴涓涓彉閲忔槸鍚﹀瓨鍦?
1>>>聽a='f'
2>>>聽locals()
3{'__builtins__':聽<module聽'__builtin__'聽(built-in)>,聽'__name__':聽'__main__',聽'pywin':聽<module聽'pywin'聽from聽'C:\ActivePython24\Lib\site-packages\pythonwin\pywin\__init__.pyc'>,聽'__doc__':聽None,聽'a':聽'f'}
4>>>聽locals().has_key('a')
5True
6>>>聽聽
]]>
鐥呭巻緇勫悎鏌ヨ榪欎釜妯″潡娌℃湁閬囧埌浠涔堝ぇ鐨勫洶闅撅紝涓昏鏄冭檻鐨勬槸鎬庝箞瀹炵幇緇勫悎鏌ヨ榪欎釜鍔熻兘錛岃繖閲屾垜鏄嬌鐢ㄥ姩鎬乻ql鐨勬柟寮忥紝灝嗘煡璇㈠啓鎴愪竴涓鍥撅紝鐒跺悗鏍規嵁緇勫悎鏌ヨ鐣岄潰杈撳叆鐨勬潯浠訛紝鐢熸垚sql錛岀劧鍚庢墽琛屾煡璇紝榪斿洖緇撴灉鐨勬樉紺哄悓鈥滃綋澶╃櫥璁頒竴瑙堣〃鈥濇ā鍧椾竴鏍楓?br />緇勫悎鏌ヨ涓氬姟瀹炵幇鏂規硶浠g爜錛?br />鐥呭巻緇勫悎鏌ヨ
聽聽1聽聽聽聽def聽listPatientInfo(self,conditions={'idtype':'',
聽聽2聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽'identityid':'',
聽聽3聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽'patientid':'',
聽聽4聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽'name':'',
聽聽5聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽'sex':'',
聽聽6聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽'birthday':'',
聽聽7聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽'address':'',
聽聽8聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽'age':'',
聽聽9聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽'registrationid':'',
聽10聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽'diseases':'',
聽11聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽'description':'',
聽12聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽'suggestion':'',
聽13聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽'start':(),
聽14聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽'operator':'',
聽15聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽'regtime':(),
聽16聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽'meds':''}):
聽17聽聽聽聽聽聽聽聽"""
聽18聽聽聽聽聽聽聽聽鐥呭巻緇勫悎鏌ヨ
聽19聽聽聽聽聽聽聽聽"""
聽20
聽21聽聽聽聽聽聽聽聽sql="""
聽22聽聽聽聽聽聽聽聽select聽distinct聽p.registrationid,p.patientid,p.idtype,p.identityid,p.patientname,
聽23聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽p.birthday,p.sex,p.address,p.description,
聽24聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽p.start,p.suggestion,p.operatorname,p.time
聽25聽聽聽聽聽聽聽聽from聽v_patientinfo聽p
聽26聽聽聽聽聽聽聽聽where聽1=1聽
聽27聽聽聽聽聽聽聽聽"""
聽28聽聽聽聽聽聽聽聽if聽conditions.has_key('idtype'):
聽29聽聽聽聽聽聽聽聽聽聽聽聽if聽conditions.get('idtype')<>'':
聽30聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽sql+="聽and聽p.idtype='%s'"聽%聽conditions.get('idtype')
聽31聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
聽32聽聽聽聽聽聽聽聽if聽conditions.has_key('identityid'):
聽33聽聽聽聽聽聽聽聽聽聽聽聽if聽conditions.get('identityid')<>'':
聽34聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽sql+="聽and聽p.identityid='%s'"聽%聽conditions.get('identityid')
聽35聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
聽36聽聽聽聽聽聽聽聽if聽conditions.has_key('patientid'):
聽37聽聽聽聽聽聽聽聽聽聽聽聽if聽conditions.get('patientid')<>'':
聽38聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽sql+="聽and聽p.patientid='%s'"聽%聽conditions.get('patientid')
聽39聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
聽40聽聽聽聽聽聽聽聽if聽conditions.has_key('name'):
聽41聽聽聽聽聽聽聽聽聽聽聽聽if聽conditions.get('name')<>'':
聽42聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽sql+="聽and聽p.patientname='%s'"聽%聽conditions.get('name')
聽43聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
聽44聽聽聽聽聽聽聽聽if聽conditions.has_key('sex'):
聽45聽聽聽聽聽聽聽聽聽聽聽聽if聽conditions.get('sex')<>'':聽聽聽聽聽聽聽聽聽聽聽聽聽
聽46聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽sql+="聽and聽p.sex=%s"聽%聽聽conditions.get('sex')
聽47聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
聽48聽聽聽聽聽聽聽聽if聽conditions.has_key('birthday'):
聽49聽聽聽聽聽聽聽聽聽聽聽聽if聽conditions.get('birthday')<>'':
聽50聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽sql+="聽and聽p.birthday='%s'"聽%聽conditions.get('birthday')
聽51聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
聽52聽聽聽聽聽聽聽聽if聽conditions.has_key('address'):
聽53聽聽聽聽聽聽聽聽聽聽聽聽if聽conditions.get('address')<>'':
聽54聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽sql+="聽and聽p.address聽like聽'%%%s%%'"聽%聽conditions.get('address')
聽55##TODO:鎸夊勾榫勬煡璇?/span>
聽56##聽聽聽聽聽聽聽聽if聽conditions.has_key('age'):
聽57##聽聽聽聽聽聽聽聽聽聽聽聽if聽conditions.get('age')<>'':
聽58##聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽sql+="聽and聽p.age='"+conditions.get('age')+"'"
聽59聽聽聽聽聽聽聽聽if聽conditions.has_key('registrationid'):
聽60聽聽聽聽聽聽聽聽聽聽聽聽if聽conditions.get('registrationid')<>'':
聽61聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽sql+="聽and聽p.registrationid='%s'"聽%聽conditions.get('registrationid')
聽62
聽63聽聽聽聽聽聽聽聽if聽conditions.has_key('diseases'):
聽64聽聽聽聽聽聽聽聽聽聽聽聽if聽conditions.get('diseases')<>'':
聽65聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽sql+="聽and聽p.diseasetype='%s'"聽%聽conditions.get('diseases')
聽66聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
聽67聽聽聽聽聽聽聽聽if聽conditions.has_key('description'):
聽68聽聽聽聽聽聽聽聽聽聽聽聽if聽conditions.get('description')<>'':
聽69聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽sql+="聽and聽p.description聽like聽'%%%s%%'"聽%聽conditions.get('description')
聽70聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
聽71聽聽聽聽聽聽聽聽if聽conditions.has_key('suggestion'):
聽72聽聽聽聽聽聽聽聽聽聽聽聽if聽conditions.get('suggestion')<>'':
聽73聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽sql+="聽and聽p.suggestion聽like聽'%%%s%%'"聽%聽conditions.get('suggestion')
聽74聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
聽75聽聽聽聽聽聽聽聽if聽conditions.has_key('start'):
聽76聽聽聽聽聽聽聽聽聽聽聽聽if聽conditions.get('start')<>():
聽77聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽sql+="聽and聽p.start聽between聽'%s'聽and聽'%s'"聽%聽(conditions.get('start')[0],conditions.get('start')[1])
聽78聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
聽79聽聽聽聽聽聽聽聽if聽conditions.has_key('meds'):
聽80聽聽聽聽聽聽聽聽聽聽聽聽if聽conditions.get('meds')<>'':
聽81聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽sql+="聽and聽p.medname='%s'"聽%聽conditions.get('meds')
聽82聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
聽83聽聽聽聽聽聽聽聽if聽conditions.has_key('operator'):
聽84聽聽聽聽聽聽聽聽聽聽聽聽if聽conditions.get('operator')<>'':
聽85聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽sql+="聽and聽p.operatorname='%s'"聽%聽conditions.get('operator')
聽86聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
聽87聽聽聽聽聽聽聽聽if聽conditions.has_key('regtime'):
聽88聽聽聽聽聽聽聽聽聽聽聽聽if聽conditions.get('regtime')<>():
聽89聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽sql+="聽and聽p.time聽between聽'%s'聽and聽'%s'"聽%聽(conditions.get('regtime')[0],conditions.get('regtime')[1])
聽90
聽91聽聽聽聽聽聽聽聽sql+="聽order聽by聽p.registrationid,p.patientid"聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
聽92聽聽聽聽聽聽聽聽result=self.execute(sql)
聽93
聽94聽聽聽聽聽聽聽聽colname=('鎸傚彿','鐥呬漢緙栧彿','璇佷歡綾誨瀷','璇佷歡鍙風爜','濮撳悕',
聽95聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽'鍑虹敓鏃ユ湡','鎬у埆','灞呬綇鍦板潃','鐥呯棁鎻忚堪',
聽96聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽'鐢熺梾鏃墮棿','鍖葷敓寤鴻','鎿嶄綔鍛?/span>','鐧昏鏃墮棿')
聽97聽聽聽聽聽聽聽聽total=('璁板綍鏁幫細',str(len(result))+"鏉?/span>",'','','','','','','','','','','')
聽98聽聽聽聽聽聽聽聽result.insert(0,colname)
聽99聽聽聽聽聽聽聽聽result.append(total)
100聽聽聽聽聽聽聽聽return聽result
鑷蟲錛岀梾鍘嗙鐞嗘ā鍧楀熀鏈姛鑳藉畬鎴?br />銆愪笅鏈熸彁紺恒?/font>瀹屾垚瀛楀吀緇存姢
]]>
鍦ㄥ仛銆愬綋澶╃櫥璁頒俊鎭竴瑙堛戣繖涓ā鍧楁椂錛岀粨鍚堝鉤鏃剁殑嫻嬭瘯緇忛獙錛岃璁¤〃鐜板艦寮忥紝鍐沖畾鐢╳x.Notebook鏉ュ仛鏁版嵁鏄劇ず錛岀涓欏墊樉紺哄垪琛紝絎簩欏墊樉紺哄垪琛ㄤ腑閫変腑璁板綍鐨勮緇嗕俊鎭?br />鍒楄〃欏典嬌鐢╳x.ListCtrl鏉ユ樉紺烘暟鎹紝榪欓噷涓烘眰蹇熺畝鍗曪紝灝卞啓浜嗕竴涓狣ataListCtrl綾葷畝鍗曞湴緇ф壙浜唚x.ListCtrl榪欎釜綾伙紝涓昏鎵╁厖浜嗘暟鎹~鍏呮柟娉曪紝鑳藉皢涓涓瓧鍏告暟鎹~鍏ュ垪琛ㄣ備富瑕佺殑浠g爜鐗囨柇錛?br />
聽聽1class聽PatientManageTodayListPanel(wx.Notebook):
聽聽2聽聽聽聽"""
聽聽3聽聽聽聽褰撳ぉ鐧昏涓瑙?br />聽聽4
聽聽聽聽"""
聽聽5聽聽聽聽def聽__init__(self,聽parent):
聽聽6聽聽聽聽聽聽聽聽wx.Notebook.__init__(self,聽parent,聽wx.ID_ANY,style=wx.NB_NOPAGETHEME|wx.NB_BOTTOM)
聽聽7聽聽聽聽聽聽聽聽self.listPanel=PatientManageListPanel(self)
聽聽8聽聽聽聽聽聽聽聽self.detailPanel=PatientManageDetailPanel(self)
聽聽9聽聽聽聽聽聽聽聽self.AddPage(self.listPanel,聽"褰撳ぉ鐧昏淇℃伅鍒楄〃",select=True)
聽10聽聽聽聽聽聽聽聽self.AddPage(self.detailPanel,聽"褰撳ぉ鐧昏淇℃伅璇︾粏淇℃伅",select=False)
聽11聽聽聽聽聽聽聽聽self.currentItem=0
聽12聽聽聽聽聽聽聽聽
聽13聽聽聽聽聽聽聽聽self.listPanel.list.Bind(wx.EVT_LIST_ITEM_SELECTED,聽self.OnItemSelected)
聽14聽聽聽聽聽聽聽聽self.listPanel.list.Bind(wx.EVT_LEFT_DCLICK,聽self.OnDoubleClick)
聽15聽聽聽聽聽聽聽聽
聽16聽聽聽聽def聽OnItemSelected(self,聽event):
聽17聽聽聽聽聽聽聽聽self.currentItem聽=聽event.m_itemIndex
聽18聽聽聽聽聽聽聽聽
聽19聽聽聽聽def聽OnDoubleClick(self,聽event):
聽20聽聽聽聽聽聽聽聽self.detailPanel.ShowPatientInfo(self.listPanel.list.GetItemText(self.currentItem))
聽21聽聽聽聽聽聽聽聽self.SetSelection(1)
聽22聽聽聽聽聽聽聽聽
聽23class聽PatientManageListPanel(wx.Panel,PatientManageBase):
聽24聽聽聽聽"""
聽25聽聽聽聽褰撳ぉ鐧昏涓瑙堝垪琛?br />聽26
聽聽聽聽"""
聽27聽聽聽聽def聽__init__(self,聽parent):
聽28聽聽聽聽聽聽聽聽wx.Panel.__init__(self,聽parent,聽wx.ID_ANY,聽style=wx.WANTS_CHARS)
聽29聽聽聽聽聽聽聽聽PatientManageBase.__init__(self)
聽30聽聽聽聽聽聽聽聽data=utils.list2dic(self.pm.listTodayRegInfo())
聽31聽聽聽聽聽聽聽聽self.list=DataListCtrl.DataListCtrl(self,data)
聽32聽聽聽聽聽聽聽聽self.Bind(wx.EVT_SIZE,聽self.OnSize)
聽33聽聽聽聽聽聽聽聽self.list.Select(0)
聽34聽聽聽聽聽聽聽聽
聽35聽聽聽聽def聽OnSize(self,聽event):
聽36聽聽聽聽聽聽聽聽w,h聽=聽self.GetClientSizeTuple()
聽37聽聽聽聽聽聽聽聽self.list.SetDimensions(0,聽0,聽w,聽h)
聽38
聽39class聽PatientManageDetailPanel(PatientManagePanelBase):
聽40聽聽聽聽"""
聽41聽聽聽聽褰撳ぉ鐧昏璇︾粏淇℃伅
聽42聽聽聽聽"""
聽43聽聽聽聽def聽__init__(self,聽parent):
聽44聽聽聽聽聽聽聽聽PatientManagePanelBase.__init__(self,parent,False)
聽45聽聽聽聽聽聽聽聽self.btnAdd.Show(False)
聽46聽聽聽聽聽聽聽聽self.btnCancel.Show(False)
聽47聽聽聽聽聽聽聽聽self.lblNew.Show(False)聽聽聽聽聽聽聽聽
聽48
聽49聽聽聽聽def聽InitBasicInfo(self):
聽50聽聽聽聽聽聽聽聽self.idType=self.pm.listAllIdTypes()聽聽聽聽聽聽聽聽
聽51聽聽聽聽聽聽聽聽self.sex=['鐢?/span>','濂?/span>']
聽52
聽53聽聽聽聽def聽InitDiseaseHistory(self):
聽54聽聽聽聽聽聽聽聽self.diseaseList=self.dic.listAllAvailableDiseaseTypeName()
聽55
聽56聽聽聽聽def聽InitPrescription(self):
聽57聽聽聽聽聽聽聽聽self.medsList聽=聽self.dic.listAllAvailableGoodsName()
聽58
聽59聽聽聽聽def聽InitControlPanel(self):
聽60聽聽聽聽聽聽聽聽self.operator=self.pm.listAllOperatorNames()
聽61聽聽聽聽聽聽聽聽
聽62聽聽聽聽def聽SetEditable(self,editable=True):
聽63聽聽聽聽聽聽聽聽controls=[self.cbIdType,self.txtPatientId,self.txtId,self.txtName,self.cbSex,self.dpcBirthday,self.txtAge,self.txtAddress,
聽64聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽self.txtRegId,self.diseaseType,self.txtDisease,self.dpcStart,self.txtSuggestion,
聽65聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽self.meds,
聽66聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽self.cbOperator
聽67聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽]
聽68聽聽聽聽聽聽聽聽for聽control聽in聽controls:
聽69聽聽聽聽聽聽聽聽聽聽聽聽control.Enable(editable)
聽70聽聽聽聽聽聽聽聽聽聽聽聽
聽71聽聽聽聽def聽ShowPatientInfo(self,registrationId):
聽72聽聽聽聽聽聽聽聽vals=self.pm.getPatientInfo(registrationId)
聽73聽聽聽聽聽聽聽聽self.FillData(vals)
聽74聽聽聽聽聽聽聽聽
聽75聽聽聽聽def聽FillData(self,dic):
聽76聽聽聽聽聽聽聽聽"""
聽77聽聽聽聽聽聽聽聽濉厖鎺т歡
聽78聽聽聽聽聽聽聽聽"""
聽79聽聽聽聽聽聽聽聽d=wx.DateTime()
聽80聽聽聽聽聽聽聽聽
聽81聽聽聽聽聽聽聽聽self.cbIdType.SetValue(dic.get('idtype'))
聽82聽聽聽聽聽聽聽聽self.txtId.SetValue(dic.get('identityid'))
聽83聽聽聽聽聽聽聽聽self.txtPatientId.SetValue(dic.get('patientid'))
聽84聽聽聽聽聽聽聽聽self.txtName.SetValue(dic.get('name'))
聽85聽聽聽聽聽聽聽聽self.cbSex.SetValue(dic.get('sex'))
聽86聽聽聽聽聽聽聽聽
聽87聽聽聽聽聽聽聽聽list=dic.get('birthday').split('-')
聽88聽聽聽聽聽聽聽聽d.Set(int(list[2]),int(list[1])-1,int(list[0]))聽聽聽聽聽聽聽聽
聽89聽聽聽聽聽聽聽聽self.dpcBirthday.SetValue(d)
聽90
聽91聽聽聽聽聽聽聽聽self.txtRegId.SetValue(dic.get('registrationid'))聽聽聽聽聽聽聽聽
聽92聽聽聽聽聽聽聽聽self.txtAddress.SetValue(dic.get('address'))
聽93聽聽聽聽聽聽聽聽self.txtDisease.SetValue(dic.get('description'))
聽94
聽95聽聽聽聽聽聽聽聽list=dic.get('start').split('-')
聽96聽聽聽聽聽聽聽聽d.Set(int(list[2]),int(list[1])-1,int(list[0]))聽聽聽聽聽聽聽聽聽聽聽聽
聽97聽聽聽聽聽聽聽聽self.dpcStart.SetValue(d)
聽98聽聽聽聽聽聽聽聽
聽99聽聽聽聽聽聽聽聽self.txtSuggestion.SetValue(dic.get('suggestion'))
100聽聽聽聽聽聽聽聽self.cbOperator.SetValue(dic.get('operator'))
101
102聽聽聽聽聽聽聽聽self.diseaseType.Set(self.diseaseList)
103聽聽聽聽聽聽聽聽for聽item聽in聽dic.get('diseases'):
104##聽聽聽聽聽聽聽聽聽聽聽聽print聽item
105聽聽聽聽聽聽聽聽聽聽聽聽for聽i聽in聽self.diseaseList:
106##聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽print聽i
107聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽if聽item==i:
108聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽self.diseaseType.Check(self.diseaseList.index(i),True)
109聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
110聽聽聽聽聽聽聽聽self.meds.Set(self.medsList)聽聽聽
111聽聽聽聽聽聽聽聽for聽item聽in聽dic.get('meds'):
112聽聽聽聽聽聽聽聽聽聽聽聽for聽i聽in聽self.medsList:
113聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽if聽item==i:
114聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽self.meds.Check(self.medsList.index(i),True)
鍒氬紑濮嬫垜鎶婇変腑鍗曟潯璁板綍(OnItemSelected)鍜屽弻鍑誨崟鏉¤褰?OnDoubleClick)榪欎袱涓柟娉曚篃鍐欏湪DataListCtrl綾諱腑錛屼絾鍚庢潵鍙戠幇榪欐牱鍐欎笉澶氱敤錛屼簬鏄妸瀹冧滑鎻愬嚭鏉ュ啓鍦≒atientManageTodayListPanel榪欎釜綾諱腑錛岀劧鍚庡湪榪欓噷緇戝畾DataListCtrl鐨勫崟閫夊拰鍙屽嚮浜嬩歡銆?br />涔嬪墠閬囧埌涓涓棶棰橈細濡備綍鍦ㄥ崟鍑昏彍鍗曞悗鎵撳紑涓涓獁x.Notbook鐨凱age錛屽啀嬈″崟鍑昏繖涓彍鍗曟椂鑳借嚜鍔ㄨ煩鍒拌繖涓墦寮鐨凱age涓婏紵鏌ヨ繃wx.Notebook鐨凙PI鏂囨。錛屾病鏈夊彂鐜扮幇瀛樼殑鏌ユ壘Page鐨勬柟娉曪紝浜庢槸灝辮嚜宸辨兂鍔炴硶瑙e喅錛屽悗鏉ユ垜鏄繖鏍瘋В鍐崇殑錛?br />鐢ㄤ竴涓瓧鍏告潵璁板綍Page鏄惁鎵撳紑錛屼互鍙婂畠鐨刬ndex
鐒跺悗鍦ㄦ樉紺鴻繖涓狿age鐨勬椂鍊欐洿鏂拌繖涓瓧鍏革細濡備綍璺沖埌鎵撳紑鐨凱age涓?/span>
聽1聽聽聽聽聽聽聽聽##鐢ㄤ簬璁板綍鑿滃崟鐣岄潰鏄惁宸茬粡鎵撳紑
聽2聽聽聽聽聽聽聽聽self.dicMenu={'鐥呬漢璧勬枡褰曞叆':(False,-1),
聽3聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽'鐥呬漢璧勬枡淇敼':(False,-1),
聽4聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽'褰撳ぉ鐧昏淇℃伅涓瑙?/span>':(False,-1)
聽5聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽}
聽6聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
聽7聽聽聽聽def聽ShowPatientInfoReg(self):
聽8聽聽聽聽聽聽聽聽"""
聽9聽聽聽聽聽聽聽聽鏄劇ず鐥呭巻鐧昏鐣岄潰
10聽聽聽聽聽聽聽聽"""
11聽聽聽聽聽聽聽聽if聽self.dicMenu.get('鐥呬漢璧勬枡褰曞叆')[0]==True:
12聽聽聽聽聽聽聽聽聽聽聽聽self.win.SetSelection(self.dicMenu.get('鐥呬漢璧勬枡褰曞叆')[1])
13聽聽聽聽聽聽聽聽else:
14聽聽聽聽聽聽聽聽聽聽聽聽pm聽=PM.PatientManageRegPanel(self.win)
15聽聽聽聽聽聽聽聽聽聽聽聽exists=self.win.AddPage(pm,聽"鐥呬漢璧勬枡褰曞叆",select=True)
16聽聽聽聽聽聽聽聽聽聽聽聽index=self.win.GetPageCount()-1
17聽聽聽聽聽聽聽聽聽聽聽聽text=unicode(self.win.GetPageText(index)).encode('cp936')
18聽聽聽聽聽聽聽聽聽聽聽聽self.dicMenu.__setitem__('鐥呬漢璧勬枡褰曞叆',(exists,index))
19聽聽聽聽聽聽聽聽self.Refresh()
鎴浘錛?br />
銆愪笅鏈熸彁紺恒?/font>瀹屾垚鐥呭巻緇勫悎鏌ヨ
]]>
]]>
浜斾竴鍓嶇湡鏄お蹇欎簡,娌$┖鐮旂┒榪欎釜緋葷粺,涓嶈繃闆墮浂紕庣鍦版湁鍋氫竴浜?浣嗕笂鑺傝鍒掕鍋氱殑瀛楀吀緇存姢妯″潡閬囧埌涓浜涙妧鏈棶棰?鏆備笖鏀懼悗澶勭悊,榪欏懆涓昏鎶?/font>鐥呬漢璧勬枡鐧昏妯″潡鐨勬牳蹇冧笟鍔″仛濂戒簡,鎴浘濡備笅:
瀛楀吀緇存姢妯″潡閬囧埌鐨勯棶棰樻湁:
1.鎬庝箞鐢╣rid瀹屾垚澧炲姞,鏇存柊鍙婂垹闄よ褰?br />2.濡備綍鍋氭垚涓涓氱敤鐨勬ā鏉垮簲鐢ㄥ湪鎵鏈夊瓧鍏哥殑緇存姢涓?br />銆愪笅鏈熸彁紺恒?font color="#000000">瀹屾垚鐥呬漢璧勬枡淇敼妯″潡
]]>
娌夊瘋涓鏁村懆浜嗭紝浠婂ぉ緇堜簬鎶婁富鐣岄潰鍋氬ソ浜嗐?br />鏈榪?澶╃壒鍒繖錛岃刀涓婂叕鍙擱」鐩彂甯冩渶鏂扮増鏈紝涓澶у爢鐨勬祴璇曚換鍔′笉鏁㈡噲鎬狅紝褰撳涔犱笌宸ヤ綔鍐茬獊鏃惰繕鏄簲褰撲互宸ヤ綔涓洪噸錛屽涔犳殏鏀句竴杈癸紝鎵浠ヨ繖嬈″涔犳瘮璁″垝澶氳姳浜嗗嚑澶╋紝涓嶈繃铏界劧鍐呭寰堝皯錛屼絾涔熼亣鍒頒簡鍑犱釜闅鵑錛?br />1.濡備綍緇欑獥浣撳姞涓婁竴涓儗鏅浘鐗囷紵
2.濡備綍浣縃tmlWindow鍐呯殑閾炬帴姝e父鎵撳紑錛?br />鎴戞兂鍦ㄧ獥浣撲笂鏄劇ず涓寮犺儗鏅浘鐗囷紝浜庢槸緲葷湅wxPthon 鐨凙PI鏂囨。錛屾兂鎵炬壘鏈夋病鏈夊儚VB閲岀殑frame鐨刾icture灞炴э紝浣嗗嚭涔庢剰鏂欑殑鏃訛紝wx.Window涓茍娌℃湁榪欑灞炴э紝铏界劧鍙互鍦ㄦ涔嬩笂鍐嶆斁涓涓浘鐗囨帶浠訛紝鏉ヨ揪鍒板悓鏍風殑鏁堟灉錛屾鍦ㄥ彂鎰侊紝浜庢槸鎷胯搗銆?strong>wxPython in Action 銆?涓嬫枃綆縐頒負PA)榪欐湰涔﹀揩閫熸帰绱竴閬嶏紝緇堜簬鎵懼埌鍔炴硶浜嗭紝鍘熸潵瑕佸疄鐜拌繖鏍風殑鏁堟灉錛岄渶瑕佸緩绔嬪畾鍒訛紝鍙傜収閲岄潰鐨勫姙娉曞啓浜嗕竴涓彲浠ラ厤緗儗鏅浘鐗囩殑window綾?import聽wx
聽2
聽3class聽ImageBackGroundWindow(wx.Window):
聽4聽聽聽聽def聽__init__(self,聽parent,聽image):
聽5聽聽聽聽聽聽聽聽wx.Window.__init__(self,聽parent)
聽6聽聽聽聽聽聽聽聽self.photo聽=聽image.ConvertToBitmap()
聽7聽聽聽聽聽聽聽聽self.positions聽=聽[(0,0)]
聽8聽聽聽聽聽聽聽聽self.Bind(wx.EVT_PAINT,聽self.OnPaint)
聽9聽聽聽聽def聽OnPaint(self,聽evt):
10聽聽聽聽聽聽聽聽dc聽=聽wx.PaintDC(self)
11聽聽聽聽聽聽聽聽brush聽=聽wx.Brush("sky聽blue")
12聽聽聽聽聽聽聽聽dc.SetBackground(brush)
13聽聽聽聽聽聽聽聽dc.Clear()
14聽聽聽聽聽聽聽聽for聽x,y聽in聽self.positions:
15聽聽聽聽聽聽聽聽聽聽聽聽dc.DrawBitmap(self.photo,聽x,聽y,聽True)
def聽OnLinkClicked(self,聽linkinfo):
2聽聽聽聽聽聽聽聽聽聽聽聽import聽webbrowser
3聽聽聽聽聽聽聽聽聽聽聽聽webbrowser.open(linkinfo.GetHref(),聽1)
涓葷晫闈㈠拰鍏充簬紿椾綋鎴浘濡備笅錛?br />
銆愪笅鏈熸彁紺恒?/font>
瀹屾垚瀛楀吀綆$悊妯″潡
]]>
wxPthon鏄竴涓潪甯稿己澶х殑鐣岄潰鍒朵綔妯″潡錛屼笅杞藉湴鍧鏄?a >http://www.wxpython.org/銆倃xPython瀹夎鍖呬腑闄勯佷簡澶ч噺瀹炰緥浠g爜錛屾瘡涓晫闈㈡帶浠剁殑浣跨敤鏂規硶閮芥湁浠嬬粛錛屽悓鏃惰繕鍙互鍘繪煡鐪嬪湪綰縜pi鏂囨。http://www.wxpython.org/docs/api/wx-module.html錛岃繖涓枃妗g殑椋庢牸寰堝儚javadoc錛屼範鎯簡java api 鏂囨。鐨勪漢涓鐪嬪氨娓呮錛屽鏋滄兂緋葷粺鍦頒簡瑙d竴涓媤yPython鍒欏彲浠ヤ笅杞藉畼鏂規帹鑽愮殑銆?strong>wxPython in Action 銆嬩竴涔︺?br />綺楃暐嫻忚涓涓媤yPtyhon Demo錛屼究绔嬪嵆寮濮嬪皾璇曠紪鍐機linicOS鐨勭櫥褰曟ā鍧楋紝棣栧厛紜涓涓嬬晫闈㈣〃鐜板姏鍜屽姛鑳斤細
鐣岄潰鍏冪礌錛?br />1.涓涓櫥褰曠獥浣?br />2.甯愬彿鏍囩鍙婃枃鏈錛屽瘑鐮佹爣絳懼強鏂囨湰妗?br />3.紜畾鍜屽彇娑堟寜閽?br />鍔熻兘錛?br />1.鍗曞嚮銆庣‘瀹氥忔寜閽椂鑳介獙璇佽緭鍏ョ殑甯愬彿鍜屽瘑鐮佹槸鍚︽紜紝濡傛灉姝g‘鍒欐樉紺篊linic涓葷晫闈?TODO錛屾殏鏃惰瀹冩樉紺轟竴涓垚鍔熸秷鎭)錛屽惁鍒欐彁紺衡滃笎鍙鋒垨瀵嗙爜閿欒鈥濄?br />2.鍗曞嚮銆庡彇娑堛忔寜閽鍑虹櫥褰曟ā鍧?br />緇忚繃涓鐣姫鍔涳紝緇堜簬鎶婄晫闈㈢敾濂戒簡錛屾殏鏃朵笐浜嗙偣錛屽緟浠ュ悗緇欏畠緹庡銆?br />
涓嶈繃鐢昏繖鐐圭晫闈㈠緢涓嶆柟渚匡紝寰楁湁鐐硅愬績錛岀壒鍒槸鎺т歡鐨勪綅緗鍏ㄦ墜宸ュ湴璋冨潗鏍囷紝榪欏浜庣己涔忔柟鍚戝拰浣嶇疆鎰熺殑鎴戞潵璇存洿鏄棝鑻?img height="19" src="http://m.tkk7.com/Emoticons/red_smile.gif" width="19" border="0" />錛屾兂鎵句竴涓彲浠ュ仛鐣岄潰鐢ㄧ殑IDE for python錛屽嵈濮嬬粓娌℃壘鍒幫紝娌″姙娉曪紝鍙ソ灝嗙棝鑻﹀繊鍙楀埌搴曘?br />浠ヤ笅鏄畬鏁寸殑浠g爜錛?br />
聽1#!/usr/bin/python
聽2#聽-*-聽coding:聽UTF-8聽-*-
聽3#聽$Id:聽login.py聽12聽2006-04-11聽03:20:48Z聽Administrator聽$
聽4"""
聽5鐧誨綍妯″潡
聽6"""
聽7import聽wx
聽8import聽dbconnect,utils
聽9
10class聽LoginFrame(wx.Frame):
11聽聽聽聽"""
12聽聽聽聽鐧誨綍鐣岄潰
13聽聽聽聽"""
14聽聽聽聽def聽__init__(self):
15聽聽聽聽聽聽聽聽"""
16聽聽聽聽聽聽聽聽鍒涘緩涓涓嚜瀹氫箟鐨勭獥浣?br />17
聽聽聽聽聽聽聽聽"""
18聽聽聽聽聽聽聽聽loginstyle=wx.DEFAULT_FRAME_STYLE^(wx.RESIZE_BORDER|
19聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽wx.MINIMIZE_BOX|
20聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽wx.MAXIMIZE_BOX|
21聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽wx.CLOSE_BOX)
22聽聽聽聽聽聽聽聽wx.Frame.__init__(self,None,id=-1,title="鐧誨綍",style=loginstyle,size=(400,300))
23
24聽聽聽聽聽聽聽聽panel=wx.Panel(self)
25聽聽聽聽聽聽聽聽
26聽聽聽聽聽聽聽聽lblAccount=wx.StaticText(panel,label="甯惵犅犅犅犲彿錛?/span>",pos=(100,100))
27聽聽聽聽聽聽聽聽self.txtAccount=wx.TextCtrl(panel,size=(125,-1),pos=(160,100))
28聽聽聽聽聽聽聽聽
29聽聽聽聽聽聽聽聽lblPwd=wx.StaticText(panel,label="瀵喡犅犅犅犵爜錛?/span>",pos=(100,150))
30聽聽聽聽聽聽聽聽self.txtPwd=wx.TextCtrl(panel,size=(125,-1),pos=(160,150),style=wx.TE_PASSWORD)
31聽聽聽聽聽聽聽聽
32聽聽聽聽聽聽聽聽btnOK=wx.Button(panel,label="紜畾(&O)",pos=(150,200))
33聽聽聽聽聽聽聽聽self.Bind(wx.EVT_BUTTON,self.OnClickOK,btnOK)
34聽聽聽聽聽聽聽聽
35聽聽聽聽聽聽聽聽btnQuit=wx.Button(panel,label="鍙栨秷(&C)",pos=(240,200))聽聽聽聽聽聽聽聽
36聽聽聽聽聽聽聽聽self.Bind(wx.EVT_BUTTON,self.OnClickQuit,btnQuit)
37聽聽聽聽聽聽聽聽self.Bind(wx.EVT_CLOSE,self.OnCloseWindow)
38聽聽聽聽def聽MessageBox(self,description,title):
39聽聽聽聽聽聽聽聽dlg聽=聽wx.MessageDialog(self,description,
40聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽title,
41聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽wx.OK聽|聽wx.ICON_INFORMATION
42聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽#wx.YES_NO聽|聽wx.NO_DEFAULT聽|聽wx.CANCEL聽|聽wx.ICON_INFORMATION
43聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽)
44聽聽聽聽聽聽聽聽dlg.ShowModal()
45聽聽聽聽聽聽聽聽dlg.Destroy()
46聽聽聽聽def聽OnClickOK(self,event):
47聽聽聽聽聽聽聽聽"""
48聽聽聽聽聽聽聽聽鍗曞嚮紜畾鎸夐挳鍝嶅簲浜嬩歡
49聽聽聽聽聽聽聽聽"""
50聽聽聽聽聽聽聽聽sql="""
51聽聽聽聽聽聽聽聽select聽count(id)聽as聽count聽from聽d_operator
52聽聽聽聽聽聽聽聽"""
53聽聽聽聽聽聽聽聽sql=sql+"聽where聽account='"+self.txtAccount.GetValue()+"'"+"聽and聽password='"+utils.encrypt(self.txtPwd.GetValue())+"'"
54
55聽聽聽聽聽聽聽聽conn=dbconnect.SqliteConnection()
56聽聽聽聽聽聽聽聽list=conn.execute(sql)
57聽聽聽聽聽聽聽聽if聽int(list[0][0])==1:
58聽聽聽聽聽聽聽聽聽聽聽聽self.MessageBox("鐧誨綍鎴愬姛","鎴愬姛")
59聽聽聽聽聽聽聽聽else:
60聽聽聽聽聽聽聽聽聽聽聽聽self.MessageBox("甯愬彿鎴栧瘑鐮侀敊璇紝璇烽噸鏂拌緭鍏?","鐧誨綍")
61聽聽聽聽def聽OnClickQuit(self,event):
62聽聽聽聽聽聽聽聽"""
63聽聽聽聽聽聽聽聽鍗曞嚮鍙栨秷鎸夐挳鍝嶅簲浜嬩歡
64聽聽聽聽聽聽聽聽"""
65聽聽聽聽聽聽聽聽self.Close(True)聽聽聽聽聽聽聽聽
66聽聽聽聽def聽OnCloseWindow(self,event):
67聽聽聽聽聽聽聽聽self.Destroy()
68class聽LoginApp(wx.App):
69聽聽聽聽"""
70聽聽聽聽鐧誨綍妯″潡
71聽聽聽聽"""
72聽聽聽聽def聽OnInit(self):
73聽聽聽聽聽聽聽聽frame=LoginFrame()
74聽聽聽聽聽聽聽聽frame.Show()
75聽聽聽聽聽聽聽聽return聽True
76
77if聽__name__=='__main__':
78聽聽聽聽app=LoginApp()
79聽聽聽聽app.MainLoop()
1.瀵煎叆md5鍜宐ase64錛歩mport md5,base64
2.鍒涘緩涓涓猰d5瀵硅薄瀹炰緥錛?md5.new("瀛楃涓?).digest()
3.灝嗙敓鎴愮殑md5涓插仛涓猙ase64杞崲錛歜ase64.b64encode(md5.new("瀛楃涓?).digest()榪欎釜榪斿洖鐨勫氨鏄姞瀵嗗瓧絎︿覆銆?br />
銆愪笅鏈熸彁紺恒?/font>閫愭娣卞叆瀛︿範wxPython錛?/font> 鍒朵綔ClinicOS涓葷晫闈?img src ="http://m.tkk7.com/joinose/aggbug/40459.html" width = "1" height = "1" />
]]>
Python瑕佹搷浣淪QLite鍙互浣跨敤Pyslqite妯″潡錛屾渶鏂扮殑妯″潡鍙互鍘?a >www.pysqlite.org涓嬭澆錛屽綋鍒濅笅杞界殑鏃跺欓『渚跨畝鍗曠湅浜嗙湅usage-guide(http://initd.org/pub/software/pysqlite/doc/usage-guide.html)錛岃寰楁尯綆鍗曠殑錛屾病鏈変粩緇嗙爺絀朵究寮濮嬭冭檻緙栧啓錛屾垜鑰冭檻鎶妔qlite鐨勮闂啓鎴愪竴涓被錛屽湪綾葷殑鍒濆鍖栧拰閿姣佹椂鍊欏垎鍒緩绔嬭繛鎺ュ拰鍏抽棴榪炴帴錛岀劧鍚庡啀娣誨姞涓涓墽琛宻ql璇彞鐨勬柟娉曪紝鐢變簬浼犲叆鐨剆ql鍙兘娌℃湁榪斿洖鍊間篃鍙兘鏈夎繑鍥炲鹼紝鑰岃繑鍥炵殑鍊煎彲鑳芥槸鍗曞垪鍊間篃鍙兘鏄鏉¤褰曪紝鍩轟簬榪欑澶嶆潅鎯呭喌錛屽氨璁╄繖涓柟娉曡繑鍥炰竴涓垪琛紝綆″畠榪斿洖浠涔堬紝閫氶氬姞鍒板垪琛ㄤ腑鐒跺悗榪斿洖錛屾垜瑙夊緱鍦ㄨ繖涓鐐逛笂錛宲ython姣斿叾瀹冭璦鏂逛究澶氫簡銆備笅闈㈡槸榪欎釜綾伙細#!/usr/bin/python
#聽-*-聽coding:聽UTF-8聽-*-
#聽$Id:聽dbconnect.py聽8聽2006-04-08聽14:21:32Z聽Administrator聽$
import聽ConfigParser
import聽locale
from聽pysqlite2聽import聽dbapi2聽as聽sqlite
class聽SqliteConnection:
聽聽聽聽
聽聽聽聽def聽__init__(self,dbname):
聽聽聽聽聽聽聽聽"""
聽聽聽聽聽聽聽聽鍒濆鍖栨暟鎹簱榪炴帴
聽聽聽聽聽聽聽聽聽"""聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽self.conn聽=聽sqlite.connect(dbname)
聽聽聽聽def聽execute(self,sql):
聽聽聽聽聽聽聽聽"""
聽聽聽聽聽聽聽聽鎵ц浼犲叆鐨剆ql璇彞,榪斿洖涓涓厓緇勬垨鑰匩one
聽聽聽聽聽聽聽聽"""
聽聽聽聽聽聽聽聽self.cu=self.conn.cursor()
聽聽聽聽聽聽聽聽self.cu.execute(sql)
聽聽聽聽聽聽聽聽self.conn.commit()
聽聽聽聽聽聽聽聽self.rows=[]
聽聽聽聽聽聽聽聽for聽self.row聽in聽self.cu:
聽聽聽聽聽聽聽聽聽聽聽聽self.rows.append(self.row)
聽聽聽聽聽聽聽聽return聽self.rows
聽聽聽聽def聽__del__(self):
聽聽聽聽聽聽聽聽"""鍏抽棴鏁版嵁搴撹繛鎺?/span>"""
聽聽聽聽聽聽聽聽self.conn.close()
def聽test():
聽聽聽聽"""嫻嬭瘯鏂規硶"""
聽聽聽聽config=ConfigParser.ConfigParser()
聽聽聽聽config.read('config')
聽聽聽聽dbname=config.get('SQLiteDB','filename')
聽聽聽聽
聽聽聽聽test=聽SqliteConnection(":memory:")
聽聽聽聽test.execute("create聽table聽person(lastname,聽firstname)")
聽聽聽聽test.execute("insert聽into聽person(lastname,firstname)聽values('涓?,'寮?)")
聽聽聽聽test.execute("insert聽into聽person(lastname,firstname)聽values('鍥?,'鏉?)")
if聽__name__=='__main__':
聽聽聽聽test()
Traceback (most recent call last):
聽 File "D:\source\dbconnect.py", line 49, in
?
聽聽聽 test()
聽 File "D:\source\dbconnect.py", line 42, in
test
聽聽聽 temp=test.execute("select * from person")
聽 File "D:\source\dbconnect.py", line 22, in
execute
聽聽聽 self.cu.execute(sql)
pysqlite2.dbapi2.OperationalError: Could not decode to UTF-8 column firstname wi
th text 寮?br />鏃㈢劧鍑洪敊浜嗭紝閭d箞澶ф鏄繖鍑犵鎯呭喌錛?br />1.pysqlite涓嶆敮鎸佷腑鏂?br />2.sqlite涓嶆敮鎸佷腑鏂?br />3.浠g爜鍑轟簡闂
鍑洪敊涔嬪悗錛岀粡榪囨祴璇曪紝鎺掗櫎絎?鍜?涓ょ鍙兘錛?br />浜庢槸鎴戜粩緇嗙畝鍗曚唬鐮侊紝鍙繕鏄病鏈夋壘鍒板嚭閿欏師鍥狅紝浜庢槸鎯蟲煡鐪媝ysqlite婧愪唬鐮侊紝鍙槸浠栫殑浠g爜鏄皝闂湪涓涓猵yd鐨勪簩榪涘埗鏂囦歡涓殑錛屾病鍔炴硶鏌ョ湅錛屼簬鏄幓涓嬭澆pysqlite鐨勬簮浠g爜錛屾嬁鍒版簮浠g爜鍚庡湪pysqlite-2.2.0\src\cursor.c榪欎釜浠g爜涓壘鍒頒簡OperationalError閿欒綾誨瀷錛岀煡閬撳師鏉ユ槸瀛楃杞崲鏃跺嚭榪欎釜閿欍備簬鏄垜灝辮瘯璇曞皢榪斿洖鍊艱漿涓哄彲鏄垜寮勪簡寰堜箙閮芥病鏈夊紕濂斤紝鍦ㄧ綉涓奼oogle涓涓嬩篃娌℃湁鎵懼埌榪欐柟闈㈢殑璧勬枡錛屾壘浜嗕竴澶╀簡涔熸病鏈夋壘鍒拌В鍐崇殑鍔炴硶錛屾棤濂堜箣涓嬮櫓浜涙硠姘斻傝櫧鐒朵箣鍓嶇湅榪噋ysqlite鏂囨。錛屼絾鐪嬪緱涓嶄粩緇嗭紝鍙槸綆鍗曟祻瑙堬紝褰撴椂鍙槸鎯寵繖涓滆タ搴旇鎸虹畝鍗曠殑錛屼緥瀛愪篃澶熻緇嗗氨娌℃湁鑺卞お澶氭椂闂村幓鐪嬫枃妗o紝涓哄緱涔熸槸鑺傜渷鏃墮棿銆傜幇鍦ㄩ亣鍒伴棶棰樹簡錛岃繕鏄佽佸疄瀹炰粩緇嗙湅鐪媝ysqlite鏂囨。鍚с傛灉鐒朵笉鏋夋垜婊寸潃鐪艱嵂姘存妸瀹冪湅瀹岋紝緇堜簬鎵懼埌鍘熷洜浜嗭紝鍘熸潵pysqlite涓湁涓?span class="p_identifier">con.text_factory鍙互瑙e喅榪欎釜闂錛岃繖涓弬鏁伴粯璁ゅ兼槸unicode 錛岀幇鍦ㄥ彧闇瑕佹妸瀹冭緗垚str灝卞彲浠ヤ簡錛?br />
聽1#!/usr/bin/python
聽2#聽-*-聽coding:聽UTF-8聽-*-
聽3#聽$Id:聽dbconnect.py聽8聽2006-04-08聽14:21:32Z聽Administrator聽$
聽4import聽ConfigParser
聽5import聽locale
聽6from聽pysqlite2聽import聽dbapi2聽as聽sqlite
聽7
聽8class聽SqliteConnection:
聽9聽聽聽聽
10聽聽聽聽def聽__init__(self,dbname):
11聽聽聽聽聽聽聽聽"""
12聽聽聽聽聽聽聽聽鍒濆鍖栨暟鎹簱榪炴帴
13聽聽聽聽聽聽聽聽"""聽聽聽聽聽聽聽聽
14聽聽聽聽聽聽聽聽self.conn聽=聽sqlite.connect(dbname)
15聽聽聽聽聽聽聽聽self.conn.row_factory聽=聽sqlite.Row聽#鍔犱笂榪欏彞鎵嶈兘浣跨敤鍒楀悕鏉ヨ繑鍥炲?/span>
16聽聽聽聽聽聽聽聽self.conn.text_factory=str聽#鍔犱笂榪欎竴鍙?鍚﹀垯鍑虹幇"Could聽not聽decode聽to聽UTF-8聽column"閿欒
17聽聽聽聽def聽execute(self,sql):
18聽聽聽聽聽聽聽聽"""
19聽聽聽聽聽聽聽聽鎵ц浼犲叆鐨剆ql璇彞,榪斿洖涓涓厓緇勬垨鑰匩one
20聽聽聽聽聽聽聽聽"""
21聽聽聽聽聽聽聽聽self.cu=self.conn.cursor()
22聽聽聽聽聽聽聽聽self.cu.execute(sql)
23聽聽聽聽聽聽聽聽self.conn.commit()
24
25聽聽聽聽聽聽聽聽self.rows=[]
26聽聽聽聽聽聽聽聽for聽self.row聽in聽self.cu:
27聽聽聽聽聽聽聽聽聽聽聽聽self.rows.append(self.row)
28聽聽聽聽聽聽聽聽return聽self.rows
29聽聽聽聽def聽__del__(self):
30聽聽聽聽聽聽聽聽"""鍏抽棴鏁版嵁搴撹繛鎺?/span>"""
31聽聽聽聽聽聽聽聽self.conn.close()
32def聽test():
33聽聽聽聽"""嫻嬭瘯鏂規硶"""
34聽聽聽聽config=ConfigParser.ConfigParser()
35聽聽聽聽config.read('config')
36聽聽聽聽dbname=config.get('SQLiteDB','filename')
37聽聽聽聽
38聽聽聽聽test=聽SqliteConnection(":memory:")
39聽聽聽聽test.execute("create聽table聽person(lastname,聽firstname)")
40聽聽聽聽test.execute("insert聽into聽person(lastname,firstname)聽values('涓?,'寮?)")
41聽聽聽聽test.execute("insert聽into聽person(lastname,firstname)聽values('鍥?,'鏉?)")
42聽聽聽聽temp=test.execute("select聽*聽from聽person")
43聽聽聽聽print聽temp
44聽聽聽聽encoding聽=聽locale.getdefaultlocale()[1]
45聽聽聽聽print聽str('絎竴鏉¤褰?').decode(encoding)+str(temp[0][1]).decode(encoding)+str(temp[0][0]).decode(encoding)
46聽聽聽聽print聽str('絎簩鏉¤褰?').decode(encoding)+str(temp[1][1]).decode(encoding)+str(temp[1][0]).decode(encoding)
47聽聽聽聽assert聽str(temp[0][1]).decode(encoding)+str(temp[0][0]).decode(encoding)==str("寮犱笁").decode(encoding)
48if聽__name__=='__main__':
49聽聽聽聽test()
]]>
1.鑳藉惁淇濆瓨澶嶆潅鏁版嵁錛屾敮鎸丅lob銆?br />2.鏀寔鑷姩緙栧彿銆備絾鍓嶆彁鏄皢涓婚敭涓瀹氳鏄疘nteger綾誨瀷銆傝兘鑷姩鏍規嵁褰撳墠璁板綍鏈澶у煎悜涓嬬戶緇紪鍙楓?br />3.鏀寔鏍囧噯SQL璇彞銆傚鏁版嵁綾誨瀷媯鏌ヤ笉涓ユ牸錛岃兘鑷姩灝嗘暟鎹被鍨嬭漿鎴怱QLite鏍囧噯鏁版嵁綾誨瀷錛岃繖涓鐐瑰湪鑴氭湰縐繪寰堢鐢紝鑳藉皢鍏跺畠鏁版嵁搴撶鐞嗙郴緇熺殑鑴氭湰鐩存帴瀵煎叆錛屼絾瑕佹敞鎰忛伩鍏嶄嬌鐢⊿QLite鏆備笉鏀寔鐨勫懡浠ゃ?br />4.鏀寔瑙﹀彂鍣ㄣ傝繖涓姛鑳戒笉閿欍備粈涔堟椂鍊欐敮鎸佸瓨鍌ㄨ繃紼嬪氨鏇村ソ浜嗭紝^_^
瀵筍QLite浜嗚В榪樹笉鏄緢娣卞叆錛岃竟鐢ㄨ竟瀛﹀惂銆?br />寮濮嬬潃鎵嬪緩鏁版嵁搴擄紝鎼滅儲浜嗕竴涓嬫暟鎹簱妯″瀷宸ュ叿錛屼互鍓嶆病鏈夌敤榪囦粈涔堣繖鏂歸潰鐨勫伐鍏鳳紝闅忎究鎼滃埌涓涓狢ASEStudio銆傜敤浜嗕竴涓嬶紝鎰熻鍔熻兘榪樹笉閿欙紝鏀寔寰堝鏁版嵁搴擄紝鑳借嚜鍔ㄧ敓鎴愭暟鎹簱鑴氭湰錛屽彲鎯滀笉鏀寔SQLite鏁版嵁搴撳紩鎿庛傝儭涔辯敾浜嗕竴閫氾紝緇堜簬鎶奀linicOS鏁版嵁搴揈-R鍥劇敾濂戒簡錛?br />
涔熼『渚跨敓鎴愪簡鏁版嵁搴撹剼鏈紝緇忚繃闆墮浂鏁f暎鐨勮繎5涓皬鏃剁殑鍔姏錛屾暟鎹簱緇撴瀯鎬葷畻鎼緩濂戒簡銆?br />銆愪笅鏈熸彁紺恒?/font>鍑嗗瀛︿範Python浜嗭紝鍏堝涔燩ySQLite錛岃В鍐崇紪鍐欐暟鎹簱璇誨啓闂
]]>
宸ヤ綔浠誨姟寰堥噸錛屾病浠涔堟椂闂村涔狅紝寰堜笉瀹規槗鎸ゅ嚭涓鐐規椂闂存潵鐮旂┒鎴戠殑瀛︿範浠誨姟銆?br />榪欎竴鑺傛垜鎶婇鐩彨浣溿婇渶姹傚垎鏋愩嬪疄鍦?img height="19" src="http://m.tkk7.com/Emoticons/red_smile.gif" width="19" border="0" />......鎯劎銆傛病鏈夊榪囪蔣浠跺伐紼嬶紝鏇存病鏈夊仛榪囬渶姹傚垎鏋愶紝鍙槸鍦ㄥ嚟鍊熻嚜宸辯殑鎯沖綋鐒舵潵緗楀垪鍔熻兘錛屾墦綆楁湁絀虹殑鏃跺欏幓鎵炬湰濂戒功濂藉ソ瀛﹀杞歡宸ョ▼銆傛帴涓嬫潵榪樻槸緗楀垪涓涓嬫垜鐨勬兂娉曞惂錛屾垜瑙夊緱榪欐牱鐨勪竴涓皬緋葷粺搴旇鍖呮嫭浠ヤ笅鍔熻兘錛?br />涓.鐥呬漢鐥呭彶妗f綆$悊
聽1.鐧昏鐥呬漢鍩烘湰淇℃伅
聽2.鐧昏鐥呬漢鏈鐥呭巻
聽3.鐧昏鏈鐥呬漢鐥囩姸銆佸尰鐢熷鏂廣佹墍鐢ㄦ不鐤楄嵂鍝?br />聽4.鎵撳嵃鐥呭巻鍗?br />聽5.鏌ヨ鐥呭彶妗f
浜?鑽搧綆$悊
聽1.鑽搧鍏ュ簱鐧昏
聽2.鍏ュ簱瀹℃牳
聽3.鑽搧鍑哄簱鐧昏錛屽寘鎷姤搴熷嚭搴撳強棰嗚嵂鍑哄簱
聽4.鍑哄簱瀹℃牳
聽5.鐗╁搧鐘舵佹彁閱掞細榪囨湡鑽搧璀︽垝,搴撳瓨鏁伴噺璀︽垝
聽6.鍏ュ簱鏌ヨ鍙婄粺璁?br />聽7.搴撳瓨鏌ヨ鍙婄粺璁?br />聽8.鍑哄簱鏌ヨ鍙婄粺璁?br />聽9.鎶ュ簾鑽搧鍙婄粺璁?br />涓?璐㈠姟緇撶畻
聽1.鐥呬漢鏀惰垂鐧昏錛氳瘖鏂垂+鑽搧璐?br />聽2.鑽搧閲囪喘鏀嚭鐧昏
聽3.姣忔棩鏀舵敮鎶ヨ〃
聽4.姣忔湀鏀舵敮鎯呭喌鎶ヨ〃
聽5.騫村害鏀舵敮緇熻鍒嗘瀽琛?/font>
銆愪笅鏈熸彁紺恒?/font>瑕佸涔犵殑涓滆タ寰堝錛屼笅鏉ユ垜鎯寵繕鏄粠綆鍗曞叆鎵嬶紝鍏堝Sqlite錛屼笉鐭ラ亾鏈夋病鏈変粈涔堝ソ鐢ㄧ殑鐢ㄦ潵鍐橲qlite鑴氭湰鐨勫鎴風宸ュ叿?