'How to register a WndProc to a tkinter window?

I found this answer which seems to say that a custom WndProc will automatically bind itself to a WNDCLASS when it is created. Is there no such thing as RegisterWndProc in the Win32 API that registers a callback to a specified HWND?

It would look like this in code:

import tkinter as tk

def mywndproc(hwnd, message, wparam, lparam):
    ...

hwnd = int(tk.Tk().frame(), 16)

# Fictional function RegisterWndProc
RegisterWndProc(hwnd, mywndproc)    # Use byref() or whatever instead

Maybe this can be possible through Tk so I am tagging it as well.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source