SoFunction
Updated on 2024-11-21

Python using the Windows API to create window example [based on win32gui module].

This article example describes Python using the Windows API to create windows. Shared for your reference, as follows:

I. Code

# -*- coding:utf-8 -*-
#! python3
import win32gui
from win32con import *
def WndProc(hwnd,msg,wParam,lParam):
  if msg == WM_PAINT:
    hdc,ps = (hwnd)
    rect = (hwnd)
    (hdc,'GUI Python',len('GUI Python'),rect,DT_SINGLELINE|DT_CENTER|DT_VCENTER)
    (hwnd,ps)
  if msg == WM_DESTROY:
    (0)
  return (hwnd,msg,wParam,lParam)
wc = ()
 = COLOR_BTNFACE + 1
 = (0,IDI_APPLICATION)
 = "Python no Windows"
 = WndProc
reg = (wc)
hwnd = (reg,' - Python',WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,0,0,0,None)
(hwnd,SW_SHOWNORMAL)
(hwnd)
()

II. Operational results:

Readers interested in more Python related content can check out this site's topic: thePython Data Structures and Algorithms Tutorial》、《Python Socket Programming Tips Summary》、《Summary of Python function usage tips》、《Summary of Python string manipulation techniques》、《Python introductory and advanced classic tutorialsand theSummary of Python file and directory manipulation techniques

I hope that what I have said in this article will help you in Python programming.