Edit: The key was using msys2. After installing Gtk3 and PyGObject following the PyGObject guide for msys2 everything worked fine. Packaging with PyInstaller and nuitka was fine.

I’ve been developing an image halftoning app for a while using GTK on Linux, thinking GTK is cross platform, and delaying testing it on Windows for quite some time.

Today I decided to finally install Windows 10 (for the first time in more than a decade) on a separate machine and see what works and what does not.

For the past few hours I’ve been through hell trying to get GTK3 to work. I’ve followed multiple guides, none of which worked, including wingtk.

Furthermore, even if I successfully compile (or install) GTK, would it be possible to package it all up using something like PyInstaller or nuitka.

At this point I’m thinking of keeping the functions and writing a whole new GUI in Tk for the Windows port, as at least that seems to work.

Am I missing something?

  • redcalcium@lemmy.institute
    link
    fedilink
    arrow-up
    5
    ·
    1 year ago

    PyQT and WxPython have much better cross platform support. If you plan to rewrite your app anyway, maybe take a look at them to see if they fit your needs.

    • Luis NorambuenaM
      link
      fedilink
      arrow-up
      2
      ·
      1 year ago

      PyQT / PySide are huge, but they have been very good in my experience coding cross platform desktop programs. macOS, Windows and Linux (even on ARM) are very well supported.

  • wvstolzing@lemmy.ml
    link
    fedilink
    arrow-up
    2
    ·
    1 year ago

    Am I missing something?

    It’s impossible to tell without knowing what specific aspect had failed.

    Before we even get to GTK; there are some issues with python wheels under msys2; check out: https://www.msys2.org/docs/python/ – some wheels just can’t be built under msys2 due to various incompatibilities. Not being able to replace such packages with ‘pure’ python equivalents could end up being a (very annoying) roadblock.

    The roadblock that I recently ran into with my simple GTK4 app was unpredictable ids on d-bus interface exports. D-bus does work under msys2; though you have to start the user session manually; d-feet and gdbus also work; though, as always, there’s a catch. On Linux I can automaticaly export ‘action groups’ that belong to GtkApplicationWindow widgets; & their 'object path’s show up predictably under the application’s path + / + the window’s id. This makes it really convenient when you want to add basic ‘remote controls’ to your widgets. Under msys2, though, I can’t figure out how to find those paths; which throws a monkey wrench, so to speak, in my ‘remote control’ implementation. Granted, d-bus is a linux-native technology; and expecting it to work w/o issues on windows is probably a bit too much.

    – apart from those, I haven’t run into any issues with GTK4 under msys2. The GTK3 packages available in their repos also work just fine.

    I do agree with the others who recommend PySide, though. Their cross platform support appears to be more robust. Their documentation has been improving as well.

    • crunchpaste@lemmy.dbzer0.comOP
      link
      fedilink
      English
      arrow-up
      1
      ·
      edit-2
      1 year ago

      Tagging @[email protected] as they’ve asked the same question.

      Last night i was failing because of some VS components missing (iirc cl.exe, which was actually not missing at all).

      Today, I’ve reinstalled Windows 10, to get a fresh start and follow wingtk’s guide. First of all it failed as “choco install python” (as mentioned in the guide) installs python 3.12, which does not include distutils.

      After that I’ve tried uninstalling python and installing python --version 3.10.11 with choco and got the same error as gvsbuild still defaulted to python 3.12, even after a few reboots.

      Not knowing how to clean it up, decided on reinstalling Windows again, and installing python 3.10 only. Half an hour ago the build process failed for some (probably) network related issues ( ).

      Currently I’ve installed a driver for the wireless card instead of using the built in one, and the build process has been stuck at “Opening https://download.gnome.org/sources/pango/1.51/pango-1.51.0.tar.xz …” for at least the last half hour.

      As for msys2, I haven’t went that route yet, as I can’t quite understand what it is and what it does. I can understand even less how to package a package installed with msys2 using either PyInstaller or nuitka, to have a (hopefully) single file executable, as I’m trying to distribute the app to my students, which are extremely non-technical.

      I wish there was something like Wine for Windows.

      • wvstolzing@lemmy.ml
        link
        fedilink
        arrow-up
        2
        ·
        edit-2
        1 year ago

        Yeah I keep running into similar issues when trying to build pretty much anything on windows; for stuff that can’t be ‘nicely’ configured & dependency-managed through an IDE, windows is pure pain.

        It really sounds like PySide would fit your use case better. Check out this website for a great starting point: https://www.pythonguis.com/pyqt6/ – the author also has an entire book on packaging PySide programs for cross-platform distribution.

        As for installing Python itself; I think I’d stick with the plain installer from python.org, and afterwards, pip. In case of dependencies that are hard to get through PyPi, I think anaconda might be worth looking at as well: https://www.anaconda.com/download

        msys2 provides a package manager, & several development toolchains; it’s an easy way to get native (mingw) gcc & bash on windows; cross-platform programs rely on it heavily, because it saves them from all the ‘visual studio’ BS: https://www.msys2.org/docs/what-is-msys2/ – I believe any implementation of GTK on windows requires a mingw toolchain.

        • crunchpaste@lemmy.dbzer0.comOP
          link
          fedilink
          English
          arrow-up
          2
          ·
          1 year ago

          Yeah I keep running into similar issues when trying to build pretty much anything on windows; for stuff that can’t be ‘nicely’ configured & dependency-managed through an IDE, windows is pure pain.

          You seem to be right. It finally compiled successfully a few minutes ago, installed pygobject successfully, following the instructions and it claims the gi module could not be found, even though pip lists it as installed. I really don’t know how Windows developers deal with such things. Do they just avoid known bad libraries?

          As for installing Python itself; I think I’d stick with the plain installer from python.org, and afterwards, pip. In case of dependencies that are hard to get through PyPi, I think anaconda might be worth looking at as well: https://www.anaconda.com/download

          I’ve decided on following the exact steps in the wingtk guide, as my attempts to deviate from them resulted in quicker failure, hence installing it through choco.

          It really sounds like PySide would fit your use case better. Check out this website for a great starting point: https://www.pythonguis.com/pyqt6/ – the author also has an entire book on packaging PySide programs for cross-platform distribution.

          While I’m sure Qt may be a better option, this project is a companion app to my PhD thesis to make the algorithms discussed somewhat easily available to a somewhat general audience and is completely unpaid so I really don’t feel like learning a new GUI framework for it. Maybe I’ll make a quick and ugly pysimplegui UI for Windows users.

          Anyway, I’m sorry for ranting. Thank you so much for the suggestions and explanations! It’s really appreciated.

  • santa@sh.itjust.works
    link
    fedilink
    arrow-up
    2
    ·
    edit-2
    1 year ago

    Have you looked into using pygame? Not sure how much your app is dependent on gtk3 vs. doing something graphical that can be generic.

    • crunchpaste@lemmy.dbzer0.comOP
      link
      fedilink
      English
      arrow-up
      4
      ·
      1 year ago

      Yes, a while ago, at the beginning of the project, and eventually decided against it. GTK, despite it’s terrible documentation for python was just a more robust desktop app framework.

      I quite heavily rely on sliders, dropdown lists and a file browser and while it’s possible to do that in pygame, it’s just too clunky.