python處理按鈕消息的實(shí)例詳解
python處理按鈕消息的實(shí)例詳解
最新學(xué)習(xí)Python的基礎(chǔ)知識(shí),在論壇中看到不錯(cuò)的實(shí)例,這里記錄下,也希望能幫助到大家,
效果圖:
實(shí)現(xiàn)代碼:
import win32ui import win32con from pywin.mfc import dialog classMyDialog(dialog.Dialog): defOnInitDialog(self): dialog.Dialog.OnInitDialog(self) self.HookCommand(self.OnButton1,1051) self.HookCommand(self.OnButton2,1052) defOnButton1(self,wParam,lParam): win32ui.MessageBox('Button1',\ 'Python',\ win32con.MB_OK) self.EndDialog(1) defOnButton2(self,wParam,lParam): text = self.GetDlgItemText(1054) win32ui.MessageBox(text,\ 'Python',\ win32con.MB_OK) self.EndDialog(1) style =(win32con.DS_MODALFRAME| win32con.WS_POPUP| win32con.WS_VISIBLE| win32con.WS_CAPTION| win32con.WS_SYSMENU| win32con.DS_SETFONT) childstyle =(win32con.WS_CHILD| win32con.WS_VISIBLE) buttonstyle =win32con.WS_TABSTOP|childstyle di =['Python', (0,0,300,180), style, None, (8,"MS Sans serif")] Button1=(['Button', 'Button1', 1051, (80,150,50,14), buttonstyle|win32con.BS_PUSHBUTTON]) Button2=(['Button', 'Button2', 1052, (160,150,50,14), buttonstyle|win32con.BS_PUSHBUTTON]) stadic =(['Static', 'Python Dialog', 1053, (130,50,60,14), childstyle]) Edit=(['Edit', "", 1054, (130,80,60,14), childstyle|win32con.ES_LEFT| win32con.WS_BORDER|win32con.WS_TABSTOP]) init =[] init.append(di) init.append(Button1) init.append(Button2) init.append(stadic) init.append(Edit) mydialog =MyDialog(init) mydialog.DoModal()
感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!
相關(guān)文章
一份python入門應(yīng)該看的學(xué)習(xí)資料
關(guān)于python入門你應(yīng)該看這些資料,幫助你快速入門python,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-04-04利用Python判斷整數(shù)是否是回文數(shù)的3種方法總結(jié)
這篇文章主要給大家介紹了關(guān)于如何利用Python判斷整數(shù)是否是回文數(shù)的3種方總結(jié),回文數(shù)是指正序(從左向右)和倒序(從右向左)讀都是一樣的整數(shù),需要的朋友可以參考下2021-07-07python中pandas.read_csv()函數(shù)的深入講解
這篇文章主要給大家介紹了關(guān)于python中pandas.read_csv()函數(shù)的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2021-03-03OpenCV3.0+Python3.6實(shí)現(xiàn)特定顏色的物體追蹤
這篇文章主要為大家詳細(xì)介紹了OpenCV3.0+Python3.6實(shí)現(xiàn)特定顏色的物體追蹤,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2019-07-07python 列表輸出重復(fù)值以及對應(yīng)的角標(biāo)方法
今天小編就為大家分享一篇python 列表輸出重復(fù)值以及對應(yīng)的角標(biāo)方法,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧2019-06-06python使用pandas讀寫excel文件的方法實(shí)例
pandas是一個(gè)十分強(qiáng)大的數(shù)據(jù)處理工具,最近需要處理數(shù)據(jù)并輸入到excel,簡單列舉它的用法,這篇文章主要給大家介紹了關(guān)于python使用pandas讀寫excel文件的相關(guān)資料,文中通過實(shí)例代碼介紹的非常詳細(xì),需要的朋友可以參考下2022-08-08