EDCD / EDMarketConnector

Downloads commodity market and other station data from the game Elite: Dangerous for use with all popular online and offline trading tools.
GNU General Public License v2.0
987 stars 155 forks source link

Ttk-based theming #2241

Open ElSaico opened 1 month ago

ElSaico commented 1 month ago

Description

This replaces Tk widgets with their Ttk equivalents and makes theme.apply() use actual Ttk themes, which are implemented as Tcl packages. It also sets the colors for all non-Ttk widgets the correct way, via tk_setPalette, and eliminates the need for most of myNotebook (with the exception of EntryMenu, which has added functionality).

Plugins should be minimally affected, and can be encouraged to use Ttk from then on.

Type of Change

UI. As in, all of it.

How Tested

The application is being live tested with my plugin setup - those with interfaces (main screen and/or preferences) are:

In addition, a comprehensive catalog of Ttk widgets was added as a core plugin (accessible only with the --ttk-catalog argument), to showcase them for plugin authors and help any future theme development.

Notes

Closes #2116

ElSaico commented 3 weeks ago

HyperlinkLabel is the last major roadblock - effectively a Label which emulates an active state. The latter is done with event bindings and toggling between two fonts, depending on whether the text must be underlined or not. This is all a bunch of Python-only state that bypasses the theming system, and can turn into a very ugly kludge if not approached correctly.

A trivial solution would be to make it subclass ttk.Button instead, which it actually behaves like, but it breaks plugins such as EDMC-Canonn and Hutton Helper that set Label-specific options...

ElSaico commented 3 weeks ago

Seems like the HyperlinkLabel issue is pretty much solved, but there are some weird bugs upon switching themes:

ElSaico commented 2 weeks ago

Problem: while yeeting the alternative title bar for the Windows native dark one would rid us of the former's gnarly minimize/restore handling, the Transparent theme doesn't work on the latter - as its background color needs to be the exact same as the rest of the window (and worse, it changes upon deselecting).

The only pre-Windows 11 way to change a title bar's color (at least without invoking a mountain of undocumented Win32 calls that'd defeat its purpose anyway) is through the Windows App SDK, a set of WinRT APIs that work all the way back to version 1809. There are bindings thanks to PyWinRT, but it lacks a crucial piece: a Win32 interop API that converts HWNDs from existing windows to the SDK's native WindowId. I made a request (pywinrt/pywinrt#61) and the head maintainer is so prolific that it might not take much long to get it implemented, so there's still hope.

...also, this SDK might open the door for cleaner alternatives of our Win32 API sprawl in the future - even beyond the ongoing move to pywin32.