Python creates pop-up menu based on win32ui module

不言
Release: 2018-05-09 11:46:15
Original
3446 people have browsed it

This article mainly introduces Python to create a pop-up menu based on the win32ui module. It analyzes the specific steps and related operating techniques of using the win32ui module to create a pop-up menu in Python with examples. It also explains the installation command of the win32ui module. You need to Friends can refer to the following example

This article describes the creation of a pop-up menu in Python based on the win32ui module. Share it with everyone for your reference, the details are as follows:

1. Code:

# -*- coding:utf-8 -*- #! python3 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),\ 'www.jb51.net - 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)
Copy after login

Note:The win32uimodule can be installed directly using thepipcommand, as follows:

pip install pypiwin32
Copy after login

The above is the entire content of this article. For more related content, please pay attention to the PHP Chinese website.

Related recommendations:

Use Python to write and save Word documents through win32 COM

The above is the detailed content of Python creates pop-up menu based on win32ui module. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!