4 ms·
Back in the early nineties I worked on a couple of projects that used wxWidgets (it was still called wxWindows then) to target MS Windows and Motif on Unix. I'm
by andyjohnson0 11y ago
Back in the early nineties I worked on a couple of projects that used wxWidgets (it was still called wxWindows then) to target MS Windows and Motif on Unix. I'm amazed to learn that it is still around and being used.
I remember it as being quite a nice library with a decent API for its time. There are probably some useful lessons to be learned from its longevity.
- kelvin0 11y agoI've used it in production code for the last 10 years. Used in both C++ and Python flavors of the lib ... works great!
- tonyedgecombe 11y agoI have too but I don't like it and feel I would have been better off with qt.
- dekhn 11y agoYup. WxWidgets was probably the least useful graphical development environment I have used. In particular, many of the GUI elements don't expose their inner widgets. For example, when I used it, I wanted to change the font of a label in a tabbed window. The tabbed window widget provided no access to the font object at the C++ level- I suppose you could subclass, but that wouldn't propagate tot he Python generated classes. You're better off just using qt: they put a lot more work into making it a useful environment, it runs a lot more places.
- chrisseaton 11y ago> In particular, many of the GUI elements don't expose their inner widgets But you know why, right? It's because it's supposed to be both cross-platform and native, so a particular platform may not use a nested label widget in a tabbed window, so it can't give you such an object.
- dekhn 11y agoall the native platforms that qt supports support nested label widgets. the wx class has that member variable, it's just private with no accessor.
- chrisseaton 11y agoMaybe my information is out of date, but I didn't think Qt supports any platforms natively at all. So Qt can give you a label widget, because it's creating the controls itself. They aren't really native controls. If you look at the Windows implementation for the wxNotebook (which I guess is the class you mean), you can see it doesn't use a nested widget for the tab label. The field may exist, but this implementation doesn't use it and instead it uses standard Windows API calls like TabCtrl_SetItem, which doesn't allow you to set a font. It only allows you to pass in a char* string. https://github.com/wxWidgets/wxWidgets/blob/master/src/msw/notebook.cpp#L389-L413 https://github.com/wxWidgets/wxWidgets/blob/master/src/msw/n... https://msdn.microsoft.com/en-us/library/windows/desktop/bb760554(v=vs.85).aspx https://msdn.microsoft.com/en-us/library/windows/desktop/bb7... So on Windows what do you expect it to give you if you ask for the label widget if there isn't one? Pretend there is one and give you some kind of facade object? What should happen if you try to set the font? Since the API they're using just doesn't support it. I think the Windows API may allow you to subclass a tab to draw it yourself and use fonts, but that's asking a lot. And there still isn't really any label widget for them to return even if they did that!
- dekhn 11y agoYes,you are correct: Qt uses themes and styles to configure its internally rendered widgets so they appear native. http://doc.qt.io/qt-4.8/style-reference.html http://doc.qt.io/qt-4.8/style-reference.html In the case of windows, you can either use the char * methods, or you have an owner-controlled widget which is a rendering area. That's what Qt does. Combined with Qt's windows style, you get somethign that looks native by default, but is customizable. This seems to me to be a far more productive approach that trying to come up with an API that supports only the common subset of features shared between Apple's UI toolkit, Windows UI toolkit, and Linux. Note that qt also supports embedded devices with raw frame buffers; you can make a UI that looks nearly pixel identical to Windows on that platform.
- mwcampbell 11y agoWhy would you actually want to change the font of a label on a tab? Wouldn't that make your application inconsistent with the host platform?
- dekhn 11y agoIn my case, I wanted to bold the font when an activity occurred there, so a user would know to navigate to that tab. I don't particularly care about the host platform; I write software that runs on all 3 major platforms, and having it behave mostly-consistently across the platforms is more important than being consistent with the host platform.
- eco 11y agoYour example kind of reflects that you aren't using wx for what it's made for. You can usually call GetHandle() and switch to platform specific stuff if you need to do something weird like that. I wouldn't really recommend that though. The point of wxWidgets isn't to be the most flexible GUI framework. It's to be as consistent and native as it can be across many platforms. If you need to do weird things in a non-native way then wx probably isn't for you. If you want to write software that looks and feels like a native application (because it is) then wx is your best bet. Qt is great but I've never used Qt application that felt like a native application. Also, Qt is rather expensive for commercial projects (about $4k per year per developer).
- tonyedgecombe 11y agoQt is published under LGPL, you don't need to spend £4k for a commercial application.
- dbcurtis 11y agoFor someone trying to decide which to use, can explain why?
- zura 11y agoSame here, although with C++ only. And still continuing using it.
- epx 11y agoWas a surprise for me as well. wx* makes me remember of Tk, PyTk
- api 11y agoIts longevity is due to a couple factors I think: (1) It's stable. No "let's rewrite everything every two years!" It's a bit ugly but once you learn it you know it. (2) It targets a reasonably stable set of platforms. (3) It's not over-ambitious. It doesn't try to be its own rendering engine or implement pseudo-style-sheets (I'm looking at you Qt) or do other crazy things. It just wraps a minimum common denominator of desktop UI functionality sufficient to ship a good working application that's not too ugly and is usable. As such it's great for long lived C++ code bases that need UI functionality across platforms.
- dbcurtis 11y agoWell, yes, but hasn't the same led to bit rot? Admitedly, I haven't looked at wx in a looong time. But when I was, I was looking at WxPython, and IIRC at the time there was an issue with wx being 32-bit only with no visible progress towards 64 bit. That scratched wxPython off my list for that project. (I admit my data is stale here, so, if you can refresh my cache, please do.)
- camperman 11y ago32 and 64-bit versions are available for the big three platforms and work well. I have custom desktop apps that I need to deploy to 32-bit Windows, 32 and 64-bit Linux and 64-bit OSX and wx has been a sane way of getting a GUI for all of them.