Hi all,

Perhaps a stupid question. Some time ago, I received a rpi zeroW as a gift, but as I did not have any use for ii I passed it to somebody else in our electronics-group. Now, that person has had a +30 year carreer as self-taught programmer -starting out with BASIC on DOS machines- so he showed of some of his old BASIC applications in dosbox on the pi.

So far so good, but he had an interesting question: Years ago, I wrote a library in BASIC for screen / window applications in DOS. (you know, pop-up text-windows and so on). How do I do that on linux (in C)?

As I myself only do ‘backend’ coding (so no UI), I have to admit I did not have any answer to that.

So, question, For somebody who has mostly coded in BASIC (first DOS and later Visual Basic) and now switched to C and python, what is the best / most easy tool to write a basic UI application with window-function on linux/unix. I know there exist things like QT and ncurses, but I never used these, so I have no idea.

Any advice?

Kr.

  • INeedMana@lemmy.world
    link
    fedilink
    arrow-up
    16
    ·
    1 month ago

    wrote a library in BASIC for screen / window applications in DOS. (you know, pop-up text-windows and so on). How do I do that on linux (in C)?
    (…)
    I know there exist things like QT and ncurses

    So it’s graphical interface we are after or text based?

    For text, I agree with others, ncurses

    For graphical

    • pyGTK
      basically everything you need, some learnig curve as it’s big and versatile. But to be honest, when trying to achieve something I’d suggest to start from GTK reference to me it somehow conveys the logic better than the PyGTK reference
    • Kivy
      haven’t used it, but might be fun to use
    • wxWidgets
      very cross-platform. Not only you can use it to write UI that will require minor fixes to have the same code for Windows and Linux at the same time, you can also tell it whether the toolkit used under the hood on Linux should be QT or GTK
    • Tk
      old, simple (more fancy things need some gymnastics) but simple (easy to use) and supported in Python out of the box (you don’t even need to install anything)
    • QT
      I’m putting it here just for fairness. I don’t like it, don’t like its signal-slot design, I think it’s hogging up too much resources. But last time I used it was ~10 years ago and in the end, it does in fact work
    • kristoff@infosec.pubOP
      link
      fedilink
      arrow-up
      5
      ·
      1 month ago

      Wauw! So many answers in such a short time. Thanks all! 👍 (I will not spam the channel by sending a thank you to all but this is really greatly apriciated)

      Concerning ncurses. I did hear of it but never looked at it myself. What is not completely clear for me. I know you can use it for ‘low-level’ things, but does it also include ‘high-level’ concepts like windows, input fields and so?

      The blog mentioned in one of the other posts only shows low-level things.

      • MyNameIsRichard@lemmy.ml
        link
        fedilink
        arrow-up
        2
        ·
        1 month ago

        but does it also include ‘high-level’ concepts like windows, input fields and so

        Yes, it allows you build full on TUIs.

      • INeedMana@lemmy.world
        link
        fedilink
        arrow-up
        1
        ·
        1 month ago

        does it also include ‘high-level’ concepts like windows, input fields and so?

        AFAIK MC uses ncurses for GUI. So I while I don’t know if it has the concept of non-modal dialog, for example, for sure it has dialogs, fields, radios, boxes, etc

  • Max-P@lemmy.max-p.me
    link
    fedilink
    arrow-up
    7
    ·
    edit-2
    1 month ago

    Both GTK and Qt have good Python bindings.

    GTK example: https://github.com/Taiko2k/GTK4PythonTutorial

    There’s also PyQt but it looks more complicated and I couldn’t find as nice and straightforward of an example as GTK but I found this: https://realpython.com/qt-designer-python/

    If you want to go to C, GTK works about the same way. If you want C++, Qt is pretty good there.

    Otherwise you can go SDL and just put whatever pixels you want on the screen on your own.

  • Matúš Maštena@lemmy.ml
    link
    fedilink
    English
    arrow-up
    5
    ·
    1 month ago

    I’d recommend egui, though you have to use Rust for it. (learning it should be easy, considering the fact that you have background in C).

  • Destide@feddit.uk
    link
    fedilink
    English
    arrow-up
    3
    ·
    edit-2
    1 month ago

    FOr me the quickest and basic way would be python and tkinter or pyqt. Failing that, push it to a web app with something like Flask or React

  • FQQD@lemmy.ohaa.xyz
    link
    fedilink
    English
    arrow-up
    2
    ·
    1 month ago

    I’m not that deep into the topic, but I experimented with GTK and tkinter as a kid

  • ffhein@lemmy.world
    link
    fedilink
    arrow-up
    2
    ·
    1 month ago

    Easiest GUI toolkit I’ve used was NiceGUI. The end result is a web app but the python code you write is extremely simple, and it felt very logical to me.

  • Gambas is like VB6 but on the Linux desktop. For a simple tool, it’s easily my go-to.

    Linux GUI programming can be a bit of a pain. There are tons of frameworks and not very many expanded tutorials or books, at least compared to most GUIs.

    If I had to write a GUI today, I’d pick something like Flutter so that I get the benefits of mobile app developer tools (that are generally better IMO). I’m looking into Slint in my free time, but I don’t think that’s something that’d fit you.

  • Eheran@lemmy.world
    link
    fedilink
    arrow-up
    2
    arrow-down
    9
    ·
    1 month ago

    ChatGPT will easily make you a basic GUI in Python using tkinter in my case. Can only recommend. It can also explain how those things work etc.

    • kristoff@infosec.pubOP
      link
      fedilink
      arrow-up
      6
      arrow-down
      1
      ·
      1 month ago

      Hmmm … 🤔 The best way not to make friends with somebody with over 30 years of coding experience: suggest him to use ChatGPT to write a computerprogram 🤣🤣

      • Eheran@lemmy.world
        link
        fedilink
        arrow-up
        3
        arrow-down
        4
        ·
        1 month ago

        It is far more efficient to ask specific questions instead of reading the whole documentation. Asking those with relevant knowledge of the field is usually not an option. Asking GPT is an option we now have. Why would you not like it? It is like having Excel instead of a calculator and paper.

        • TimeSquirrel@kbin.melroy.org
          link
          fedilink
          arrow-up
          1
          ·
          1 month ago

          You don’t learn as well when you have someone/something else do the thinking for you. It’s nice to NOT have to keep going back to an LLM for answers.

          • Eheran@lemmy.world
            link
            fedilink
            arrow-up
            1
            ·
            edit-2
            1 month ago

            I learn even less if the effort required is far too high to even try. GPT reduces this a whole lot, enabling me (and presumably many others) to do things they were unable to do previously.

            I really do not understand how this community is so toxic regarding this.

            • TimeSquirrel@kbin.melroy.org
              link
              fedilink
              arrow-up
              1
              ·
              1 month ago

              I really do not understand how this community is so toxic regarding this.

              I’m guessing it’s because you’re surrounded by people who DID spend the extra effort to learn something on their own without having their hand held, and now just see people trying to take the easy way out.

              You’re not unique. We were all in your position once.

      • INeedMana@lemmy.world
        link
        fedilink
        arrow-up
        2
        arrow-down
        4
        ·
        1 month ago

        ~20 years ago:
        “Reading documentation is for wimps! Real programmers read the source code directly”

        LLMs are just a tool. And meanwhile our needs and expectations from the simplest pieces of code have risen

        • kristoff@infosec.pubOP
          link
          fedilink
          English
          arrow-up
          1
          ·
          1 month ago

          As a sidenote. This reminds me of a discussion I haver every so often on “tools that make things to easy”.

          There is something I call "the arduino effect:. People who write code for things, based on example-code they find left and right, and all kind of libraries they mix together. It all works … for as long as it works. The problem is what happens if things do not work.

          I once helped out somebody who had an issue with a simple project: he: “I don’t understand it. I have this sensor, and this library… and it works. Then I have this 433 MHz radio-module with that library and that also works. But when I use them together. It doesn’t work”| me: what have you tried? he: well, looked at the libraries. They all are all. Reinstalled all the software. It’s that neither me: could it be that these two boards use the same hardware interrupt or the same timer he: the what ???

          I see simular issues with other platforms. GNU Radio is a another nice example. People mix blocks without knowing what exactly they do.

          As said, this is all very nice, as long as it works

          I wonder if programming-code generated by LLMs will not result in the same kind of problems. people who do not have the background knowledge needed to troubleshoot issues once problems become more complex.

          (Just a thought / question … not an assumpion)

        • kristoff@infosec.pubOP
          link
          fedilink
          English
          arrow-up
          1
          ·
          1 month ago

          To be honest, I have no personal experience with LLM (kind of boring, if you ask me). I know do have two collegues at work who tried them. One -who has very basic coding skills (dixit himself) - is very happy. The other -who has much more coding experience- says that his test show they are only good at very basic problems. Once things become more complex, they fail very quickly.

          I just fear that, the result could be that -if LLMs can be used to provide same code of any project- open-source project will spend even less time writing documentation (“the boring work”)

      • Eheran@lemmy.world
        link
        fedilink
        arrow-up
        1
        arrow-down
        3
        ·
        1 month ago

        Hence GPT to help. I build a fairly big GUI that way, far bigger than GPTs context window (about 3’500 lines), but as always we can break things into smaller pieces that are easy to manage.