How do I force a program to use wxGTK?

Hi all, first post here.

I’m currently working on updating a Python interpreter for an old program, and part of that is updating the libraries to their modern versions. For wxPython, I’m upgrading from 4.0.6 to 4.2.1.

A big issue I’ve run into is that the general appearance of the GUI has changed. My initial thought was that some defaults had changed, and I hadn’t been able to track them down.

However, when I ran across the “Control Appearance” section in the wx.Notebook docs, I realized that I may have been trying to change the style of individual toolbars, etc, when I should be trying to change the appearance as a whole.

Right now, it looks like my program is using wxMSW. How can I force it to use wxGTK, which, from the images in the above link, will make my GUI look like it used to (or at least much closer to what it looked like).

Thanks for the help,

What operating system are you actually using?

On Linux, the following commands show the version of wxPython I am using is built on GTK3.

richardt@Pavilion:~ $ python3
Python 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import wx
>>> wx.version()
'4.2.1 gtk3 (phoenix) wxWidgets'

wxMSW is wx on Microsoft Windows.

The screenshots in the “Control Appearance” sections are rather old and far away from what you can see now.
This is on Windows 10:

I’m writing code for WIndows 10/11. So is it just impossible to get the GTK look on windows?

Perhaps if you run Windows Subsystem for Linux (WSL) or in a Virtual Machine (VM)?

I’m writing code that will be commercially distributed, so that’s sadly not an option.

Really, I don’t think that you want to have gtk.
The screenshot on the documentation page is old and depends on the theme that was used at that time.
This is a recent screenshot from Ubuntu, i.e. gtk:


Why would you want to have this on on Windows? It would not look good.

I’m ultimately trying to get the old look, which most looks like the GTK appearance on the old documentation page. So in that, it’s not GTK as much as changing the appearance.

So pardon my ignorance on that. If there are any suggestions on what style can be used to mimic the dark/light gradient, that would be much appreciated.

Have a look at wx.lib.agw.flatnotebook.FlatNotebook, which “is a full, generic and owner-drawn implementation of class Notebook”.
I have never used it, but if it’s generic, then you should be able to customize it to your needs.
It’s also in the wxPython demo, but it seems that much of the functionality there is not working.

I have not, I’ll check it out. Thanks! I’m hoping the upgrade won’t require implementing a whole different class, but we’ll see.

Also, to be explicit, the top image is an example of what the gui looked like before upgrading the wxPython library, and the bottom is what it looks like after.


So if something jumps out as the cause of that and what could be done to recover the previous look, that would be awesome. My first thought was to search through the different styles, which didn’t help. And then maybe using GTK. But neither have proven fruitful, so any other ideas would be awesome.


And this is the “bottom” image referenced in my previous reply (I’m still too new to post more than one image in a given post)

I don’t understand why you get these differences.
When you use a normal wx.Notebook this is a native Windows widget, which is drawn by Windows, not by wx.

E.g. on Windows 10 there are some style differences here and there, but the notebook tabs themselves are just identical:
Python 2.7, wx

Python 3.7, wx 4.0.4

Python 3.12, wx 4.2.1

Maybe, you could prepare a miniumum code sample and post it here.
I will then run it with these three wx versions.

Possibly, it’s actually quite complex. And thank you for your time. It’s given me a lot of avenues to pursue. And if I do end up making a reduced version to test, I’ll post it here.