8 ms·
Fbs: Create Linux GUIs with Qt in minutes
- sprt 8y agoThis is really cool as Qt just looks daunting to start with! Is there a way to make it use native widgets? I noticed the app in the screenshots doesn't look like native Ubuntu.
- mherrmann 8y agoThanks! I think Qt never uses "native" widgets. If at all, it just renders them to look that way.
- deleted 8y ago[deleted]
- mehrdadn 8y agowxWidgets is the only framework I can think of that uses native widgets.
- xfer 8y agoUbuntu is gtk-based, so you need a matching Qt-theme for that to work, it will look native on kubuntu/kde-based distros.
- alxlaz 8y agoThere is no such thing as "native Ubuntu" :-). The default widget style of a modern Ubuntu installation is just a GTK theme (which, I think, supports both GTK 3 and GTK 2 -- the two are incompatible, so themes need to implement support for both). You can configure Qt to use the GTK 2 rendering engine, but GTK 2 and GTK 3 look slightly different for reasons that I am entirely unable to convey without an inflammatory post, so Qt (and GTK 2) applications won't look exactly the same as GTK 3 applications.
- empyrical 8y agoI am not sure how this is going (this blog post is the only info I can find on it) but they have plans to make a new UI library for Qt that is backed by the platform's native widgets, like AppKit on macOS: http://blog.qt.io/blog/2017/02/06/native-look-feel/ http://blog.qt.io/blog/2017/02/06/native-look-feel/
- rashkov 8y agoThis strikes a nice balance between open source GPL and commercial licensing and services, and I like how this makes it easy to distribute your application. I keep reading comments here on HN about how nice QT is to work with, and this seems like a great way to jump in.
- airstrike 8y agoWell, this does require copying-and-pasting the entire GUI script, so I wouldn't exactly say this takes less than 5 minutes if you're writing that stuff from scratch
- dextersgenius 8y agoCan you use this to build a Windows app as well, given that both python and Qt are cross-platform?
- mherrmann 8y agoYes, absolutely. You can follow the exact same steps as in the article; Just use Python 3.5 or 3.6 and omit the `buildvm` and `runvm` steps. The only limitations on Windows are that the app is not yet code signed and there are no automatic updates (yet).
- platz 8y agowhat are the advantages of choosing Qt over Gtk for cross-platform purposes?
- joshvm 8y agoQt as an ecosystem is fairly complete for general application development. It includes, among other things, concurrency primitives (QtConcurrent) that are trivial to use*, sockets, database support, serial port drivers and charting (qwt for example). Plus lots of useful tidbits I keep finding like accessing standard system temp directories, making temporary files and adding registry keys (or equivalent). I've never used GTK in anger, but presumably there's some feature overlap. At times I've used Qt without any GUI components because it's so convenient (nicer than Boost for sure). It also leverages native GUI frameworks so most applications will blend in with the platform you're writing for (last time I tried GTK this wasn't the default). It's easy to style with CSS if you need it.
- int_19h 8y agoQt look and feel is much closer to native on Windows. Not 100%, but you need to know what to look for to notice it. I would assume that the same is also the case on macOS.
- zapzupnz 8y ago
- alxlaz 8y agoI think I'm missing something here. What is the operation that this tool is meant to simplify? This takes five minutes because you're copy-pasting a 250-line file. Which otherwise builds the layout manually. Doing that from scratch would easily take, what, an hour? even for an experienced Qt developer. During that hour you can definitely read an introductory tutorial (from Qt's excellent documentation). Assembling that UI with the GUI builder then takes all of five minutes, maybe ten if you've never used it before. And you don't need Docker and a VM for that (!?). Is this meant to showcase how easy it is to package the application? If so, that's definitely cool, but I'm not sure how it relates to the article, which starts with "This article shows how to program a Linux GUI. In five minutes from now, you will have created an app and a downloadable installer. We'll build the following GUI, but you can also create any other" -- and then goes on to show you neither how to program a Linux GUI, nor how to build that application (unless you count copy-pasting code as either of them?) Edit: it's worth pointing out that cross-platform packaging Qt applications, especially written and Python definitely isn't too easy. If this is the point, then this program doesn't look bad at all!
- mherrmann 8y ago> cross-platform packaging Qt applications, especially written and Python definitely isn't too easy. If this is the point, then this program doesn't look bad at all! That's what it is about, yes, sorry. I should have written the article shows how to create a Linux GUI. I let myself be distracted by SEO considerations ("Linux GUI programming").
- alxlaz 8y agoWell, it's not like you're showing anyone how to create a Linux GUI, either (unless, you know, you count the copy-paste part :-) ). If SEO is the goal, perhaps it's worth looking into keywords along some other directions? A lot of folks who get past the "getting started with Qt" part is going to be interested in the problem of packaging Qt applications (especially where Python is involved, which comes with its own set of difficulties). If these are the people such an article is relevant for, I doubt "Linux GUI programming" is the kind of stuff they're googling for. After all, they already know a little about that, the problem is how to let their friends use what they wrote already. Meanwhile, people who are googling things like "how to write gui program Linux" probably need help figuring out things like signals and slots, not how to package an application that they can't even write yet.
- dang 8y agoPlease don't put Show HN on blog posts. This is in the rules: https://news.ycombinator.com/showhn.html https://news.ycombinator.com/showhn.html Writing doesn't count as "something you've made", because then every post would be a Show HN. We make exceptions for books because those are so much more work.
- mherrmann 8y agoInteresting, I didn't know about blog posts and Show HN. It is less of a blog post than an announcement of a new library though. Either way, I'm fine with the removal of the show prefix and will remember it for future posts. Thanks.
- rootlocus 8y agoAm I missing something? It's obvious to me he's showcasing the "fman build system": https://github.com/mherrmann/fbs https://github.com/mherrmann/fbs which is a wonderful project because the only reason I avoided Python + Qt in the past was because I wanted to make a very very simple cross-platform installer for my friends (mac and windows) and I didn't want to spend a lot of time researching how to bundle the python runtime in a cross-platform binary. Personally, this is the most useful "Show HN" project I've seen in the past months.
- tobltobs 8y agoCould be interesting, but is my understanding correct, that, for a commercial project, I would have to buy a fbs, pyqt and a QT licence?
- mherrmann 8y agoYou can use PySide2 instead of PyQt. And you don't need a Qt license when just using it from Python, because Qt is licensed under the LGPL and you are allowed to link to it dynamically. So, if putting your project under the GPL is not an option for you, then the only commercial license you need is fbs. (Caveat: IANAL)
- brian_herman__ 8y agoAnother python GUI that’s not as fancy but easy to use is http://easygui.sourceforge.net http://easygui.sourceforge.net I used it to create a GUI for on of my programs at work took me 10 minutes to program.
- infinite8s 8y agoSo if I wanted to release my app under a BSD/MIT license I'd need to buy a commercial license for fbs?
- AnIdiotOnTheNet 8y agoOk, so others have pointed out that there isn't any GUI creation really going on here, so I'm not going to harp on that. However, since we're on the topic of GUI creation, why isn't there a way for users to compose simple GUIs to meet their workflow needs? Something like HyperCard was? Part of the reason a lot of people love the command line so much is how it allows you to compose solutions to unique problems in a simple way. Why doesn't that exist in the GUI? Where is the UNIX philosophy applied to the GUI? Ok, so there's SmallTalk environments, but they're strange and require you to learn a whole new language and paradigm just to get started. Where's UNIX's answer?
- zedr 8y agoThere's PythonCard. http://pythoncard.sourceforge.net/ http://pythoncard.sourceforge.net/
- AnIdiotOnTheNet 8y agoNot quite what I'm talking about. For one, it is much closer to VB than HyperCard, and while HyperCard was great in the 90s it could be significantly improved upon today. Also, no UNIX philosophy, that is the composability of small tools, to be seen.
- irq-1 8y agoFor devs, Lua bindings with GTK+ (like JavaScript with QT/QML) would be a good solution: easy binding with C libs, and minimal runtime and easy distribution. It needs a VB6 GUI builder with code editor. For users, a "parts" library built with the above and a layout/flow chart for building workflows.
- peatmoss 8y agoSimple cross-platform GUIs are pretty easy in Racket, and there’s even a wealth of beginner-focussed teaching materials / documentation for Racket. Less tutorial material for GUI apps specifically, which should probably be remedied. Still, Racket has a pretty good native GUI and packaging story, and the docs are very consistent.
- qwerty456127 8y agoAlthough I understand value behind this approach, what I specifically dislike about fman is the fact its own instances of CPython, Qt and other libraries get installed together with it although I already have up-to-date versions of all the dependencies properly installed in my system.
- qwerty456127 8y agoAs many else have been I have been click-baited here thinking you are going to teach us how to do PyQt5 GUI development faster and better. Now as I'm developing a PyQt5 GUI app I can say it involves a serious amount of of non-intuitive hand-coding and feels annoyingly hard and slow as compared to WinForms and WPF. It is most probably going to get easier and faster with experience, nevertheless I believe some real articles (going beyond hello-worldish stuff and addressing more complicated issues from a real-life experience perspective) on PyQt5 programming can probably help a lot (unfortunately there are hardly any published to the date).
- 21 8y ago> I can say it involves a serious amount of of non-intuitive hand-coding and feels annoyingly hard and slow as compared to WinForms and WPF. It is most probably going to get easier and faster with experience No, it won't get easier, because the technology is flawed. If you want easy you use HTML. There is a reason all new complex applications are written in Electron.
- qwerty456127 8y agoI'm scared away from HTML/Electron as it seems (perhaps I'm wrong) that means I am going to have to also use Photoshop (which I'm particularly bad at) and design literally every bit of the UI from scratch while what I want is a set of classic widgets to layout on a form quickly (the way I do in VisualStudio and Qt Designer). I have experience of using HTML, CSS and vanilla JS to make classic web pages and I can't even imagine how to html/css-code something that is going to look and work like a reasonably complex desktop application. Also as @mherrmann has once mentioned "Do you know how JavaScript sorts numbers? Alphabetically. ’nuff said.". At least but not at last Electron apps are so slow to start and so hardware-hungry I actually doubt it is going to become a truly mainstream platform for desktop applications. BTW the technology doesn't look flawed any more (arguably it is less flawed) than WinForms is. If only Trolltech would consider developing a WinForms-style (or call it Delphi-style) RAD studio (that would provide click-to-code experience, a visual BackgroundWorker component etc and let you customize everything visually instead of only doing the actual form design job like Qt Designer) a worthy investment PyQt5 apps development could be made a breeze.
- deleted 8y ago[deleted]
- nogbit 8y agoGUI dev, especially rich desktop apps are more enjoyable to build, at least to start with, via a rich layout GUI of it's own. One ends up re-parenting and moving things around so much that it's easier to be agile in a GUI than it is with code.
- dev_dull 8y ago> You need Python 3 and Docker Definitely not portable (not that the author claimed to be). When I’ve taken up building a Qt all idea, it’s usually because I want to build a program for a non-technical user. There really is no easy way to build easily portable or cross platform Qt apps. I had high hopes with Go but even that requires system packages (last time I checked).
- oliwarner 8y agoThe title does not mesh with the content. Writing a PyQt5 app is still as much of a ballache as writing a GUI in anything is. Certainly takes a lot of "minutes". The article just downloads a preprepared application. What TFA is really doing is selling (unless you're GPL) an application that packages this all up. All things you could do for yourself, but that take an amount of effort.
- mherrmann 8y agoI didn't pick the current title - it was set by a mod. And yes, PyQt still takes time. And yes, you could do packaging & deployment yourself. But it will take weeks or months, depending on how many platforms you target. Why reinvent the wheel?