相思资源网 Design By www.200059.com

python 创建弹出式菜单的实现代码

           实现效果图:

python 创建弹出式菜单的实现代码

           Python代码 

import win32ui 
import win32api 
from win32con import * 
from pywin.mfc import window 
class MyWnd(window.Wnd): 
  def __init__ (self): 
    window.Wnd.__init__(self,win32ui.CreateWnd()) 
    self._obj_.CreateWindowEx(WS_EX_CLIENTEDGE,\ 
                 win32ui.RegisterWndClass(0,0,COLOR_WINDOW+1),\ 
                 'MFC GUI',WS_OVERLAPPEDWINDOW,\ 
                 (10,10,800,500),None,0,None) 
    self.HookMessage(self.OnRClick,WM_RBUTTONDOWN) 
     
  def OnClose(self): 
    self.EndModalLoop(0) 
  def OnRClick(self,param): 
    submenu = win32ui.CreatePopupMenu() 
    submenu.AppendMenu(MF_STRING,1054,'Copy') 
    submenu.AppendMenu(MF_STRING,1055,'Paste') 
    submenu.AppendMenu(MF_STRING,1056,None) 
    submenu.AppendMenu(MF_STRING,1057,'Cut') 
    flag = TPM_LEFTALIGN|TPM_LEFTBUTTON|TPM_RIGHTBUTTON 
    submenu.TrackPopupMenu(param[5],flag,self) 
w = MyWnd() 
w.ShowWindow() 
w.UpdateWindow() 
w.RunModalLoop(1) 

         以上使用python 创建弹出式菜单的简单实例,如有疑问,大家可以到本站社区交流,感谢阅读,谢谢大家对本站的支持!

标签:
python,创建弹出式菜单,Python,弹窗

相思资源网 Design By www.200059.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
相思资源网 Design By www.200059.com

评论“python 创建弹出式菜单的实现代码”

暂无python 创建弹出式菜单的实现代码的评论...