Skip to content

Run tools built upon python-manatools on Windows - #16

Open
xquiet wants to merge 18 commits into
mainfrom
feat/windows-port
Open

xquiet wants to merge 18 commits into
mainfrom
feat/windows-port

Conversation

@xquiet

@xquiet xquiet commented Nov 30, 2026

Copy link
Copy Markdown

This makes python-manatools usable on Windows 10/11 with the Qt, GTK (MSYS2), ncurses (windows-curses) and web backends. All Windows-specific code is guarded by sys.platform == 'win32' or by feature detection, so Linux behaviour is unchanged.

Changes

Packaging

  • dbus-python is a Linux-only dependency; windows-curses is added on Windows.
  • manatools.services imports without dbus and raises a clear RuntimeError when used where systemd is not available.

Backend detection

  • On Windows, YUI tries Qt, then GTK4, then ncurses. The XDG/X11/Wayland session checks do not apply there. MUI_BACKEND still overrides the
    choice.

Paths and configuration

  • AppConfig stores system settings in %PROGRAMDATA%\<app> and user preferences in %APPDATA%\<app>\<app>.yaml. The user directory is created when preferences are saved.
  • documents_dir() asks the Windows shell for the Documents folder, so a folder redirected to OneDrive is also found.

Localization

  • The UI language comes from the Windows user language (LANGUAGE is set unless the user already set one of the locale variables).
  • AppArgs uses gettext's default locale directory on Windows instead of /usr/share/locale.

Icons

  • The new icon_theme_dirs() returns the icon theme roots. Directories in MANATOOLS_ICON_PATH come first, then <python prefix>\share\icons on Windows or the XDG locations elsewhere. Qt, GTK and the web server's /icon/ route all use it.
  • On Windows, Qt picks the first installed theme among breeze, Adwaita and hicolor.
  • The web server also finds Breeze icons at their preferred size (Breeze uses actions/22/ rather than 22x22/actions/).
  • tools/install-icon-theme.ps1 downloads the KDE Breeze icons, checks their SHA-256, installs them without admin rights or Developer Mode, and adds them to MANATOOLS_ICON_PATH.

Qt

  • Ctrl-C wakeup uses a socket pair instead of a pipe plus fcntl. fcntl does not exist on Windows, and there signal.set_wakeup_fd and QSocketNotifier only accept sockets.

ncurses

  • Enter from \r, KEY_ENTER and the PDCurses keypad Enter (PADENTER) is treated as \n.
  • Resizing the console window is handled (resize_term(0, 0) on PDCurses).
  • The window title is set with SetConsoleTitleW, because the legacy console prints escape sequences as text.

Web

  • The server port is claimed with SO_EXCLUSIVEADDRUSE. On Windows, SO_REUSEADDR lets a second process bind a port already in use, so a busy MUI_WEB_PORT was shared instead of falling back to a free port.

Testing

Tested on a Windows VM with Python 3.13 and PySide6 6.12:

  • All headless checks in tests/ pass, the GTK ones under MSYS2 UCRT64 Python (GTK 4.24, PyGObject 3.58).
  • The web smoke check passes.
  • Qt: the HtmlView, pie chart and context-menu demos work, including icons from the installed Breeze theme and context menus opened with the Menu key.
  • ncurses: the HtmlView and bar-chart demos work. Keyboard navigation, link activation and F10 to quit work.
  • GTK (MSYS2): the context-menu, HtmlView and bar-chart demos work; context menus open with the Menu key and items activate. HtmlView uses its text engine there, as MSYS2 has no WebKitGTK.
  • Web in Edge: HtmlView and gauge demos render; events reach the server over the WebSocket.
  • The shared web server lifetime test passes.
  • The Breeze installer script works.

The same checks still pass on Linux.

Not covered

  • GTK on Windows needs MSYS2 (or another GTK 4 build with PyGObject); PyGObject has no pip wheels for Windows. WebKitGTK is not available there, so YHtmlView falls back to its text engine.
  • manatools.services remains Linux-only (systemd over D-Bus).
  • Without an installed icon theme, named icons do not show on Windows; tools/install-icon-theme.ps1 installs one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant