Sorry for the somewhat noob question, but how do you pick a library for making a GUI for your apps? My background is in physics, so most of my programming is perfectly find with a CLI that outputs a graph as a ps file or some csv. I am looking to learn about making some neat little GUIs. I was thinking it would be a good idea to try and build my GUI out of the browser so that my app can be as portable as possible, but does this mean it has to be in Javascript or can the backend be done in anything else?

I am not really sure what I am asking, but wanted to get a feel for how people approach front ends.

Thanks :)

  • tiddy@sh.itjust.works
    link
    fedilink
    English
    arrow-up
    0
    ·
    1 month ago

    Honestly reading through your comments, I couldnt reccomend Godot more - I’ll just toss some bullet points below.

    • GUI tools with lots of tutorials
    • Basic 2D and 3D rigid body simulations
    • Very extendable if you know C++ or rust
    • In house python like compiled language deeply engrained into the engine, which is surprisingly fast
    • Cross compileable to most devices, but honestly the engine itself runs on all devices I use so something like syncthing makes dev incredibly portable
    • Ecosystem is only growing by the day, most tutorials are game dev related reasonably but still cover most topics one could need
    • Basic GPU compute support if that’s your thing

    Theres some things its not yet perfect at, like the web export could be better - and in depth things like minimising copies between CPU and GPU might not be as fine grained as hardcore devs would like, but if youre coming from mathematics and python it’ll fit like a glove.

    Just for an anecdote I wrote a basic particle simulation in gdscript that was HORRENDOUS for performance, 200 particles all calculated the per frame force of attraction to every other particle then summed it; whole thing ran at 80 fps even on my phone

  • Troy@lemmy.ca
    link
    fedilink
    arrow-up
    0
    ·
    2 months ago

    Making a web app is a mistake 9 times out of 10, particularly when dealing with larger datasets. Because you’re in physics, you probably want to skills you’re learning to be transferable into physics and data science in general.

    I recommend starting with python (if you know it already, awesome), then checking out pyqtgraph – there’s a bunch of demo apps that come with the package and you can use those as launch points. This will be your gateway into pyqt/pyside and legit desktop application development. Later, if you learn C++, you can transition into Qt (and still use all the power of the toolkit and the skills are transferable), or into raw C++ which is amazing for numerical computing.

    • obbeel@lemmy.eco.br
      link
      fedilink
      arrow-up
      0
      ·
      1 month ago

      This. But it needs to be pointed out that your app may suffer from segmentation faults if you use C++. Rust is hard to work with as of right now. You should go with PyQt or Electron.

  • shameless@lemmy.world
    link
    fedilink
    arrow-up
    0
    ·
    2 months ago

    Time, experience and a lot of mistakes. Everyone who has been programming/scripting has made their fair share of mistakes along their journey.

    Sometimes you just have to pick one, start it and see how it goes.

  • mox@lemmy.sdf.org
    link
    fedilink
    arrow-up
    0
    ·
    2 months ago

    be as portable as possible

    This is important to me, which narrows down my options quite a bit.

    Electron is portable across desktop OS, but unacceptably bloated (I don’t want my users to have to deal with that) and buggy (I don’t want to deal with that).

    wxWidgets and various similar wrapper libraries exist, but on Linux most of them wrap Gtk, which in recent years has become very opinionated in UI directions that I find intolerable.

    A few new cross-platform GUI toolkits have been appearing recently, but I’ve found all of them suffer from poor text handling, anemic widget sets, or very out-of-place look and feel (especially keyboard navigation) relative to native applications.

    That leaves Qt as my only reasonable choice, at least for now. This is mostly okay, as it does a wonderful job all around. My main complaint is that using the full power of its widgets and libraries means I’m restricted to a handful of languages: C++, Python, and maybe one or two minor ones like D. Its declarative API (Qt Quick) seems to be getting more language bindings, though, so simpler apps might be able to take advantage of that.

    Note that the landscape is different for mobile apps. I don’t have a recommendation for those.

    • RayJW@sh.itjust.works
      link
      fedilink
      arrow-up
      0
      ·
      1 month ago

      What about Tauri? I don’t know what exactly your app is but since you mentioned Electron as an option I guess Tauri could run it. Offers more choice for frontend frameworks hence less „language lock-in“ than Qt.

  • AnotherWorld@lemmy.world
    link
    fedilink
    arrow-up
    0
    ·
    2 months ago

    JS is optional, it’s unpleasant, as well as use a bunch of fat frameworks. But now there is HTMX, which makes any GUI without JS, pure HTML combined with some Bootstrap 5 is enough. I write in Go, it has a great built-in template, and it’s enough for any level of GUI

  • d3m0nr4v3r@discuss.tchncs.de
    link
    fedilink
    arrow-up
    0
    ·
    edit-2
    2 months ago

    I am on my way to bed so I can only give a brief and simplistic overview:

    In principle a basic web application runs in the browser, so it is executed locally on your device. The scripting language the browser understands is JavaScript. With JS and JS libraries you can do pretty much anything you would expect and probably more. In general, you use JS to do whatever you need to do to your data and then use it to manipulate the HTML document in order to display your data. You can also have a Backend, running somewhere else (on a server) and using whatever language you like as long as it can then communicate with you frontend JS application using the appropriate web protocols. You dont necessarily need a Backend, a lot of stuff can be done using JS that is executed on your device. This depends on the use case (e.g. for fetching data from a database on your server you could write a Java/Python/whatever app that runs on your server, fetches the data and sends it to the client where it is received, processed and displayed via a JS app).

    Now to write a JS app, most people nowadays use some sort of framework (react, vue, nextjs etc). This is quite a different process than writing a vanilla JS app, might take some getting used to depending on where you are coming from but is worth it in the end. If you want an easy start I would recommend vue3+pinia store.

    There are also GUI libraries as well as styling/CSS libraries which can be combined with this approach (or not). Take a look at NaiveUI and Tailwind as examples.

    Thats all I can offer, best of luck and good night!

  • expr@programming.dev
    link
    fedilink
    arrow-up
    0
    ·
    2 months ago

    If you do want to go the web route, I’d highly recommend avoiding SPAs and going with https://htmx.org/ instead. Much simpler, less code, entirely driven by your backend, while still giving you the ability to make nice interactive applications.

    As a bonus, since you presumably have been working with Python anyway, the author of htm has a whole book online walking you through building an app using htmx and Flask, a web framework for Python: https://hypermedia.systems/book/contents/

  • Kissaki@programming.dev
    link
    fedilink
    English
    arrow-up
    0
    ·
    edit-2
    1 month ago

    Blazor is incredibly versatile in terms of where and how you run it. The UI is in HTML and CSS, the generated runtime bindings in JavaScript, but you can code the backend as well as frontend logic in C# / .NET / Razor template files.

    It can render on the server or client, even work offline with WebAssembly and Service Worker, and dynamically switch between or combine them.

    You can also integrate it into Windows Forms, WPF, or multi-platform .NET MAUI with Webview2, which will render “as a website” while still binding and integrating into other platform UI and code.


    Your goals of “neat little GUI” and “as portable as possible” may very well be opposing each other.

    Main questions are what do you have (technologies); what are you constraints, and what do you need. Different tech has different UI tech. Overall, most GUI programming is a hassle or mess.

    If you want to dip your toes, use the tech you like, and look for simple GUI techs first. Don’t try to do everything/all platforms at once first.

  • FizzyOrange@programming.dev
    link
    fedilink
    arrow-up
    0
    ·
    1 month ago

    What language are your apps written in? Generally the best options are:

    1. Qt (C++) or PyQt (Python wrapper if you hate yourself). Old school desktop GUI. Works extremely well though.
    2. Web based, then you can pick from a gazillion frameworks, most popular is React. You generally have a Typescript based frontend and a backend in whatever language you want. The downside is you have to deal with the frontend/backend communication which can be a pain.

    There’s also Flutter which is pretty nice, but again you have to use Dart for the GUI so if the rest of your app is in another language you’ll have some friction.

    But yeah, I would say the language you want to write your “business logic” in is the biggest factor to choosing. Also if you care about exposing your app over the web.

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

        For rust I use iced, as it meets all my needs and is a delight to work in. I don’t think it’s good for making graphs though. For graphs I heard that people like matplotlib (in python), which you can also use inside PyQt apps. I’ve tried using matplotlib and did not enjoy the experience at all, but I don’t know of any alternatives.

  • traches@sh.itjust.works
    link
    fedilink
    English
    arrow-up
    0
    ·
    1 month ago

    I’m a web dev with a wife who is a researcher, and on the side I’ve built a few tools for her work. Web apps are great because cross-platform distribution and compatibility are non-issues. If you don’t need a database or server-side logic, a client-side only application is basically free to host given that it’s ultimately just a pile of static files. You can use localstorage for persistence, and because there’s no server logic you have a lot fewer security implications to worry about.

    JavaScript gets a bad rap, but if you pair it with typescript and decent tooling it’s really not bad. HTML and CSS are an incredibly powerful engine for building UI, which is only getting better.

  • 31337@sh.itjust.works
    link
    fedilink
    arrow-up
    0
    ·
    edit-2
    1 month ago

    I (probably unreasonably) despise using web front-ends for desktop applications.

    GTK is OK. QT is very feature rich, but that adds complexity. Both can be cross-compiled to most systems and shipped with all the required libraries pretty easily.

    I haven’t used it in a long while, but I remember liking Java Swing for some reason. Java should be “write once, run anywhere.” But, cross-compiling isn’t usually too hard, so not sure how much that matters. There’s more modern frameworks for JVM-based languages now, but I haven’t tried them.

    I’ve noticed Gradio is popular in the ML community (web-tech based, and mostly used for quick demos/prototypes).

    Edit: For web applications, I prefer Angular’s more traditional architecture over React’s hook architecture.

  • schnurrito@discuss.tchncs.de
    link
    fedilink
    arrow-up
    0
    ·
    1 month ago

    The UI platform with the largest install base of all is the web. Nearly all computer users can use your GUI if you develop it for the web, it’s almost the definition of the universal open standard for GUIs.

    Browsers can only execute JavaScript or WebAssembly, so you need to write it in JavaScript or in something that compiles to these things, e.g. TypeScript (but there are also ways to compile other languages to JS or WASM).

  • Akt0@reddthat.com
    link
    fedilink
    arrow-up
    0
    ·
    2 months ago

    You may be interested in MatPlotLib for Python and maybe something like mpld3 to get it to the browser. I’ve been trying a few frameworks out recently, so I’ve seen a few Python options that use the browser as their main window. NiceGUI has a browser front end and graphing that may be able to do what you want as well, but there are others you can find. You might look for tutorials on YouTube if you’re having trouble deciding, to see how difficult it is to learn and work with. If you know any c++, there’s a long but descriptive list of frameworks available on GitHub, sorted into categories, that could help narrow those options down. It probably depends a lot on what you already know, but there are more options than JavaScript. You have a lot of good keywords to narrow down a search. <Your language> GUI or graphing framework browser frontend open source (no license)

  • GissaMittJobb@lemmy.ml
    link
    fedilink
    arrow-up
    0
    ·
    2 months ago

    Understand what tradeoffs different solutions make, then inform your decision on that. A fairly general principle for example is that the more cross-platform compatible a solution is, the less well-suited it will be for any given platform in terms of looks/behavior/performance. This may or may not matter for what you’re building.

    There are inherent qualities to some solutions (for example, a particular library may make for good solutions on a certain platform), and some qualities will be situational (a particular library is good for you because you happen to know the language/patterns/framework/whatever).

    I personally like to build things in Kotlin and Jetpack Compose, but that’s because I primarily build mobile apps for Android and I like the reactive UI paradigm that underpins this library along with the language that it’s written in. I would perhaps reconsider if I were building a desktop app (not as well supported), and definitely reconsider if I were building a web app (definitely a poor fit).

    So yeah, start with what you’re building and what its requirements are. Then think about what you already know, and finally put those together when evaluating a UI solution.

    • InternetCitizen2@lemmy.worldOP
      link
      fedilink
      arrow-up
      0
      ·
      1 month ago

      So yeah, start with what you’re building and what its requirements are.

      It would be desktop. I mostly want to add front end to some stuff I would CLI to round out my skills. I’ve not seen much about Rust and GUI framework. I’ve got some Java experience, but read that its native Java FX is deprecated now. I’ve done a lot in Python, but also want to start learning a language that might be more suited to enterprise work. I honesty am not sure were I’m at. But thanks for your answer