Python uses Windows API to create a window example

不言
Release: 2018-05-09 13:31:53
Original
3363 people have browsed it

This article mainly introduces the operation of Python using Windows API to create windows. It analyzes the specific operation steps and related implementation techniques of Python based on the win32gui module to call Windows API to create windows based on examples. Friends in need can refer to the following

The example in this article describes how Python uses the Windows API to create a window. Share it with everyone for your reference, the details are as follows:

1. Code

# -*- coding:utf-8 -*- #! python3 import win32gui from win32con import * rect = win32gui.GetClientRect(hwnd) win32gui.DrawText(hdc,'GUI Python',len('GUI Python'),rect,DT_SINGLELINE|DT_CENTER|DT_VCENTER) win32gui.EndPaint(hwnd,ps) if msg == WM_DESTROY: win32gui.PostQuitMessage(0) return win32gui.DefWindowProc(hwnd,msg,wParam,lParam) wc = win32gui.WNDCLASS() wc.hbrBackground = COLOR_BTNFACE + 1 wc.hCursor = win32gui.LoadCursor(0,IDI_APPLICATION) wc.lpszClassName = "Python no Windows" wc.lpfnWndProc = WndProc reg = win32gui.RegisterClass(wc) hwnd = win32gui.CreateWindow(reg,'www.jb51.net - Python',WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,0,0,0,None) win32gui.ShowWindow(hwnd,SW_SHOWNORMAL) win32gui.UpdateWindow(hwnd) win32gui.PumpMessages()
Copy after login

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

Related recommendations:

Python creates a pop-up menu based on the win32ui module


##

The above is the detailed content of Python uses Windows API to create a window example. 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!