13 ms·
Gtk4 Tutorial
- nupsigga 5y agoIf anybody out there is dismayed by the rise of Electron for UI, crap like this is why that came about.
- hackermeows 5y agoAre these two the only option ?
- j-james 5y agoQt is another very popular toolkit, as long as you're not dead set on working in C.
- MichaEiler 5y agoQt would have been my first choice for a long time. Unfortunately the Qt Company has changed their pricing model a few years ago and charges way too much these days. (3950$ per developer and year for desktop and mobile applications. For embedded systems they don't even list public prices...). That said even the open source version is less interesting since one doesn't get official long term security and bug fix updates without continuously migrating to the newest releases.
- lordofgibbons 5y agoFlutter for desktop also exists, but it's not ready for production use yet. It's buggy and missing features, but usable. My prediction is that we should be able to build prod-ready native desktop apps with it within a year or so
- PaulDavisThe1st 5y agoGTK, Qt, WxWidgets, FLTK are more or less your only choices for generic, long lived, cross-platform desktop GUI toolkits. I apologize for any that I've forgotten, except Tcl/Tk which is not seriously an option at this point in time :) There are some "promising new up and comers", including libUI. If you work in the audio software domain, JUCE is likely your go-to cross-platform toolkit.
- wahern 5y agoI settled for Yue: https://github.com/yue/yue https://github.com/yue/yue It's been around for several years, though definitely doesn't have the developer or user base of other well-known frameworks. The deciding factor for me was that is has well maintained Lua bindings as part of the core project, alongside JavaScript (Node.js) and C++. I didn't have much luck with libui (crashes, missing features, etc), and various immediate mode alternatives just require too many dependencies and other work that made integration painful. Plus, Lua bindings for these were always stale. In fact, Lua binding quality is pretty poor all around, including GTK, Qt, WxWidgets, and FLTK.
- heavyset_go 5y agoNo. wxWidgets is cross-platform with GTK and Qt backends on Linux, and native platform widgets on macOS and Windows. QtQuick with QML is also pleasant, with a reactive programming model written in JavaScript. There's Kivy on Python. There are several IMGUI implementations, too. Some other lightweight Electron-like alternatives also exist.
- PaulDavisThe1st 5y agoThis is a false claim. The "rise" of Electron has occured primarily because it allows people to do desktop development using whatever it that they learned in the context of web-centric development. For some people, that's an excellent turn of events, for others, it is a horror show. Even if I was willing to grant that GTK and Qt etc. are "crap" (which I'm not, but ...), it's notable that there are essentially zero cross-platform alternatives that could be judged any less "crappy". Either you think that nobody smart enough has tried, or this is a much harder problem to solve to your liking than it first appears.
- analognoise 5y agoLazarus/FreePascal makes all of these things look like trash. GTK, QT, and Electron. Native, cross platform, tiny binaries, JS transpiler in the works, Android and iOS support in the works. Destroys this...mess.
- PaulDavisThe1st 5y agoas a RAD-like tool, Lazarus looks pretty good. But I'm the author of a substantial cross-platform creative/media application, and not only do we not use any RAD tools, I don't think we could. So if you "destroy this mess", I'm not sure how we could do what we do. Very few "creative" applications use stock toolkits and RAD tools.
- analognoise 5y agoThe RAD component is optional; you're free to code up your interface if you'd like.
- PaulDavisThe1st 5y agoWhich from what I can tell would buy me essentially nothing over any other cross-platform GUI toolkit. I don't use Qt, but QML and its associated tools look to me at least as good as Lazarus.
- 5y ago
- donio 5y agoI disagree. I am no GTK fanboy but if you actually look through the linked tutorial it's quite straightforward stuff and all you need to know is C. You can't get much simpler than some of the early examples except maybe in Tcl/Tk. If you look through an Electron tutorial it assumes familiarity with a whole bunch of web technologies and it's not any simpler. The reason Electron and the like are popular is because developers can take advantage of their pre-existing knowledge of these web technologies and have the option to reuse code between Electron and web projects.
- smoldesu 5y agoI personally disagree with a lot of the changes GTK4 introduces, but I still think it's my favorite way to build quick little native apps on Linux. If you're well-versed in Rust, I really recommend checking out gtk-rs[0], a fantastic little crate with a surprisingly robust GTK implementation. If you're familiar with 'builder' style tools (particularly Glade), your workflow will feel right at home. Plus, memory safety/type safety/good concurrency and all those other awesome Rust freebies you get are super nice for GUI apps. [0] https://gtk-rs.org/ https://gtk-rs.org/
- deaddabe 5y agoGtk-rs is still pretty bare bone. I tried to do my part by removing boilerplate using macros [1] [2], but it is still complicated to design GTK apps. Even more now, because Glade has been deprecated for GTK4 and no visual editor is available to replace it for now, making developers manually write XML while exploring the sparse documentation. This is a regression for developers' experience. I am really trying to like GTK after using Qt a lot in the past, but there is just too much effort. Things should be as simple as VB6/WinForms. With no visual GUI editor, I find myself to just write CLI tools in Rust instead of going the extra mile and creating GUIs. [1] https://github.com/MicroJoe/gladis https://github.com/MicroJoe/gladis [2] https://github.com/MicroJoe/gtk_liststore_item https://github.com/MicroJoe/gtk_liststore_item
- curioussavage 5y agoI haven’t tried it yet myself but there is https://gitlab.gnome.org/jpu/cambalache https://gitlab.gnome.org/jpu/cambalache which supports both gtk3 and 4
- deaddabe 5y agoI downloaded and tried it just now. When creating a project, I get an empty .ui file with no possibility to add any widget. This project still seems in its infancy, or I am doing something wrong. It also seems to enforce a "framework" instead of just being a graphical .ui file editor. How I am supposed to use this if I am using Rust instead of Python, and Relm instead of their MVC framework? I miss Glade (and it had issues!).
- lvturner 5y agoI still miss Visual Basic + WinForms, as a teenager it was such an easy way to put together a functional UI, I know it has it's detractors, but I can't think of anything I've used since that was quite so fun to use and so quick to get up and running (if anyone knows of something - I'd be very keen to learn of it!)
- conz 5y agoI still miss Visual Basic + WinForms If you don't mind running Linux binaries in Windows, then take a look at GAMBAS, a solid, contemporary Object Basic VB equivalent: http://gambas.sourceforge.net/en/main.html http://gambas.sourceforge.net/en/main.html
- Yuioup 5y agohttps://www.lazarus-ide.org/ https://www.lazarus-ide.org/
- analognoise 5y agoLazarus/FreePascal tech slaps. It will blow your mind.
- KronisLV 5y agoDropping by to second this statement: it really is a good example of RAD (rapid application development) for desktop software, since it supports a variety of platforms, has a UI toolkit that just works across them and doesn't need to depend on many components on the target system either, or a particular version of a particular runtime. The language is also pretty simple and doesn't feel that much worse than Java, whereas the Lazarus IDE just reminds me of NetBeans - it's no JetBrains product, but it's also perfectly passable and has everything you need. The compile times are also excellent, the compiler itself is decently friendly with its error messages and the runtime itself lets you write code that feels safer than C++ in most cases. Oh, and it really comes with "batteries included" - you'll find components for everything from UI elements, to database access, to working with events and such. Here's actually a large list of all sorts of software that has been created in it: https://wiki.freepascal.org/Projects_using_Free_Pascal https://wiki.freepascal.org/Projects_using_Free_Pascal Now, the bad things. It's basically dead. Sure, there are contributors who keep working and they do have a roadmap here: https://wiki.freepascal.org/Roadmap https://wiki.freepascal.org/Roadmap However, there is no hype around Pascal, many people disliked the language for a variety of reasons. No one also seems to care much about its advantages for some odd reason, instead people are talking about Electron, JavaFX/OpenJFX, .NET MAUI/Avalonia or other new technologies that attempt to do what Lazarus did many years ago, with varying degrees of success. Sadly, to me it seems like technologies live or die by how much hype there is around them and how many thousands of man hours people are collectively willing to put into them to create brilliance. And Lazarus doesn't have that anymore. Compare both the IDE, its approach to things, as well as Pascal nowadays with the likes of Rust - the latter gets hundreds of libraries created for it, thousands of tutorials and will have developers that literally grow up to like and use it. The former feels neglected in comparison, you won't be doing web development while utilizing super popular libraries that attempt to cover most concerns like Rocket (https://rocket.rs/ https://rocket.rs/) does. You also won't be interfacing with the likes of GraphQL, or even RabbitMQ, due to a lack of interest in developing libraries for those, as well as many other technologies. It might be a similar story for something like YAML or TOML. Nor will you find many good books and tutorials, maybe apart from this nice piece of writing: https://castle-engine.io/modern_pascal_introduction.html https://castle-engine.io/modern_pascal_introduction.html
- dbcooper 5y agoSeems like GTK4 has some font rendering regressions: https://gitlab.gnome.org/GNOME/gtk/-/issues/3787 https://gitlab.gnome.org/GNOME/gtk/-/issues/3787
- phoneperson 5y agoGTK4 has a LOT of regressions. They decided to remove menus, which is fine, except their replacement is broken https://gitlab.gnome.org/GNOME/gtk/-/issues/3042 https://gitlab.gnome.org/GNOME/gtk/-/issues/3042 As for font rendering, it is kinda broken in gtk3 too. I recently switched to roboto condensed and while qt applications look fine the spacing between letters in gtk3 apps is totally broken.
- ben-schaaf 5y agoNot sure what you're talking about: Menus haven't gone anywhere. The adwaita theme uses some window decorations to add a shadow, doing this required a compositor. If you don't have a compositor don't use adwaita...
- phoneperson 5y ago:/ GtkMenu, GtkMenuBar, and GtkMenuItem are gone so you have to use GtkPopover* instead which has this issue. I would love to not use adwaita except gtk4 has crippled the ability for users to theme their apps, especially when libadwaita is used. Also gtk3 does not have this issue even with adwaita.
- md8z 5y agoLibadwaita hasn't crippled that, it's still very possible to load CSS. You just can't use the gtk-theme-name setting anymore. Maybe it would be better if somebody fixed that thing with the menus. But I think IIRC if you wanted transparency in old X11 without a compositor, the toolkit had to copy the region under the popup, and then blit it to the popup... Yes, this meant that content in the transparent region that changed would be stale until the popup went away. So someone would have to decide if that would be a viable solution, or maybe someone could get away with just using the existing XShape stuff in GDK somehow.
- analognoise 5y agoGTK is so ugly and there are so many problems, I have to ask: why do people persist with it? There are better options aren't there? There must be something amazing about it I don't understand - can somebody enlighten me?
- md8z 5y agoGTK is currently the only realistic choice for a (somewhat) modern desktop toolkit for Linux written in C. There's still a lot of C programs and programmers out there. For me it's also one of the better options for a Linux toolkit with decent Rust bindings. The Rust-native toolkits aren't quite there yet, but I'm watching this page: https://www.areweguiyet.com/ https://www.areweguiyet.com/
- deaddabe 5y agoNote that this page is a little bit outdated. Not updated since August 2021, and for example does not mention [0] Relm4 [1]. [0] https://github.com/areweguiyet/areweguiyet/pull/77 https://github.com/areweguiyet/areweguiyet/pull/77 [1] https://github.com/AaronErhardt/relm4 https://github.com/AaronErhardt/relm4
- 5e92cb50239222b 5y ago> GTK is so ugly Maybe on other operating systems. It looks fine on Linux, I don't care much for anything else.
- craftoman 5y agoGTK is an excellent, innovative tool for those who haven't tried creating GUIs with HTML/CSS (Electron), Android Studio, or SwiftUI. Every time I try creating something with GTK, I always end up cursing programmers who built it.
- foresto 5y agoAfter over a decade of using a Gtk-based desktop, I have finally given up on Gtk. A few of the most memorable things that have driven me away: Client-side window decorations: ugh. I miss being able to see at a glance which window has input focus, even if some of them are partially covered. I miss having consistent grab areas for all windows. I miss being able to click or drag any part of the title bar without having to avoid whatever widgets some clever app developer decided to shove into that space. I miss consistent keyboard and mouse controls for rearranging windows, configurable in one place. I miss small title bars. I miss window frames that draw correctly without a compositor. A theme engine that ensures all themes are broken: Gtk complains whenever the desktop theme contains something that is out of spec, and seems to change the spec with every minor version. The result: Unless you only use the officially blessed and version-matched theme that comes with your version of Gtk, it constantly belches warning messages into ~/.xsession-errors, needlessly increasing wear on the SSD, and making it a pain to wade through all the Gtk spam if you ever have to use that log file to troubleshoot a real problem. Why even have a theming engine if no theme can ever hope to work properly for more than a month or two? System tray icons: These are very useful to me, all day, every day of my life. Gtk is removing them. Various third party libraries have appeared in attempt to restore the missing functionality, but since they're not native parts of the toolkit, I doubt that any of them will ever work quite as well or become a clear choice for app developers. A mess of an API: It looked reasonable enough at first glance, but in my (admittedly limited) experience coding with Gtk, I found that most of my time was spent troubleshooting different interfaces for the same task, having to discover by trial-and-error which ones were broken in which ways, and moving on to the next, until finally settling on one that did the job with the fewest problems. Perhaps some of those were old and deprecated, but I was unable to find documentation to that effect, nor any guidance on which bits were considered current or how to manage their quirks. I felt like the toolkit was constantly fighting me, wasting my time. It seems I'm not the only one who had trouble here: https://www.phoronix.com/scan.php?page=news_item&px=MTU2ODM https://www.phoronix.com/scan.php?page=news_item&px=MTU2ODM None of this is news. Gtk has been inflicting bad design decisions on users for years now, but since changing ecosystems (both as a user and as a developer) is a time-consuming chore, I have been quietly hoping that it would get better. Instead, it has consistently been getting worse. I'll miss my trusty old classic Xfce, but I'm done.
- unwind 5y agoFound the migration guide from 3.x to 4 at [1]. Nice with some serious detail and advice, as usual. I think the GTK project is a huge success and an open source triumph. I have an old app I started back on 1.x in the late 90s, would be great to port from 3 to 4. [1]: https://docs.gtk.org/gtk4/migrating-3to4.html https://docs.gtk.org/gtk4/migrating-3to4.html
- squarefoot 5y agoAm I the only one thinking that in some GTK4 forms, such as for example the file requester dialog, placing action buttons on the title bar, is both unnecessary and logically wrong? I find it really annoying. Having the buttons below allows me to drag the window in a favorable position (good, the title bar is available!), then read the entries by moving my eyes towards the lower part, then when finished I just keep looking down until I reach the controls to either accept or cancel the choice. But no, with the new arrangement I must go down, then back up to confirm. At least give us a way to go back to the old widget placement.
- ohazi 5y agoNo, you're definitely not the only one. GTK is used by a lot of projects that are unrelated to GNOME, but unfortunately GTK still lives under the GNOME umbrella, and the GNOME developers are an unbelievably antagonistic bunch.
- foresto 5y agoAlso known as client-side window decorations, or CSD. You're not the only one. Lots of people view it as a terrible idea, for a variety of reasons.