This article mainly introduces Python using Windows API to create Windows operations, in conjunction with instance form analysis of Python based on the Win32gui module call Windows API Creation window specific steps and related implementation tips, the need for friends can refer to the following
The examples in this article describe python using the Windows API to create Windows. Share to everyone for your reference, as follows:
One, the code
#-*-Coding:utf-8-*-#! Python3import win32guifrom 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 + 1wc.hcursor = Win32gui. LoadCursor (0,idi_application) wc.lpszclassname = "Python no Windows" Wc.lpfnwndproc = Wndprocreg = 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 ()
The above is the entire content of this article, more relevant content please pay attention to topic.alibabacloud.com.