Python uses Windows API to create a window sample

Source: Internet
Author: User
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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.