Set window class name

I’m developing a Pageant-like compatible appwhich used PIV cards for keys, for Windows only. I need to set the window class name to a specific string. Using wxPython, the class name seems to be hardcoded and not changeable, set as “wxWindowNR”.
There’s a method in wx to do so, named CreateUsingMSWClass. But I don’t find how to use this from wxPython.

I also tried with Tk, same issue of the constant class name, so I ended up using ctypes and raw win32 calls to manage the window. That works well for the first step, but then it is very limited and very painful to progress on the design of the application (button, clipboard, tray icon,…), that loses all the benefits from using Python. I want to benefit from wxPython which I like, and make the design and development easy.
The other way I think is to restart this app in C++ so I can benefit win32 and wx. But that would requires to rewrite many things and especially the PIV communication, and cryptography computations.

To reach this goal of changing the window class name with wxPython, I can think of some ways :

  • Set up afterwards by changing the right deep property : can this be modifiable after the window creation? If so : dig down into the objects layers down to the classname field and change it.
  • Reach the CreateUsingMSWClass wx method and create the window using this method.
  • Change the wxPython code
    • adding classname option in Frame, or
    • modifying app SetClassName so all the app frames are using this as class name.

Looks like any way, I have to cross into the C++ world (wx) to make this happens, and from the Python code, that is not easy. I hope some people here would have some experiences with this and/or figure out an easy way to manage this MSW classname.

OK, I finally ended up to start an invisible window with ctypes, so I can setup the window class name. And this window is instantiated with callbacks which are called when a message is sent to this window. And these callback are used to go back to the Python app script I manage. Also the main app window is a different one, like a parent for this invisible other window, so I can have a standard wx app. At the end this is like the “ctypes” window is a proxy or a gateway for the events. Its purpose is just to get the events and reply, but all the processing is done elsewhere, and this window is not even displayed to the user.

When the user quit the app, it sends a close event to this “child” window, else it requires kill (CTRL+C if CLI), but the closing bar button was ineffective, like locked by the remaining win32 window.

For curiosity, you can see the result there : GitHub - bitlogik/PIVageant: Pageant Windows SSH agent with PIV dongle Yubico 5. The proxy win32 ctypes windows is pageant_win.py. The app frames are designed with wxFormBuilder as I’m used to.

I have to say, except for this class name part, wxPython is still great and really helpful.