7 ms·
Toga: A Python native, OS native GUI toolkit
- atanasb 12y agoThis looks promising. It would be better if the documentation was a bit more exhaustive[0] [0]http://toga.readthedocs.org/en/latest/internals/platforms/desktop/cocoa.html http://toga.readthedocs.org/en/latest/internals/platforms/de....
- freakboy3742 12y agoI'll completely agree. This is a project that has been built in the last 6 months of my spare time from all my other projects, and most of that time has been spent getting things to a point where they work. The APIs aren't yet stable enough to warrant me spending a bunch of time formalising them, but I absolutely want to document them as soon as the ground stops moving :-)
- allegory 12y agoVery interesting. They have other tools which are rather useful looking as well: http://pybee.org/ http://pybee.org/ (debugger, test runner, coverage visualiser etc)
- freakboy3742 12y agoThanks for the promotion :-) Of those tools, the test runner (cricket) is the most mature; the debugger isn't much more than a proof of concept. Those tools are also based in Tkinter at the moment; I started Toga because I've started to hit the limits of Tkinter. The intention is to port the other PyBee tools to Toga as soon as they get mature enough.
- deleted 12y ago[deleted]
- davidjhall 12y agoleft_container = toga.OptionContainer() AttributeError: 'module' object has no attribute 'OptionContainer' Frustrating when things that are supposed to work out of the box, don't. Initial search yields no help.
- a_bonobo 12y agoWhat version of toga are you running? I'm on Ubuntu with Python 2.7.6, toga v 0.1.0 and cassowary 0.5 and your oneliner works fine. Edit: In fact, OptionContainer is just 15 days old, so I think you've got an old version: https://github.com/pybee/toga/commit/262efbfc00fae0a96e096664dbdb9b409b31413d https://github.com/pybee/toga/commit/262efbfc00fae0a96e09666...
- Lord_DeathMatch 12y agoeither than or you're on windows, where unfortunately next to nothing is implemented
- freakboy3742 12y agoSounds like you're on Windows. Unfortunately, Windows support is pretty primitive at this point (reflecting my own priorities - OSX, Unix and mobile support is a more pressing concern). I'll update the homepage and docs to better reflect the current project status. Longer term, I definitely want to support Windows to the same level as other platforms; any assistance on this front would be gratefully accepted.
- calpaterson 12y agoThe use of constraints to let the user specify where to put things but still allow enough flexibility to do OS-dependant things is interesting (and possibly novel?): http://toga.readthedocs.org/en/latest/introduction/tutorial-0.html http://toga.readthedocs.org/en/latest/introduction/tutorial-...
- matthewmacleod 12y agoI think that's basically the same as Cocoa's Autolayout, which is also constraint-based. It's a good model, though.
- PuercoPop 12y agoNot really novel[1], just not used enough [1]: https://en.wikipedia.org/wiki/Sketchpad https://en.wikipedia.org/wiki/Sketchpad
- Game_Ender 12y agoIt's similar to the sizer concept in wxWidgets: http://wiki.wxwidgets.org/WxSizer http://wiki.wxwidgets.org/WxSizer
- daurnimator 12y agoCassowary ( http://constraints.cs.washington.edu/cassowary/ http://constraints.cs.washington.edu/cassowary/ ) is used by Apple for this.
- freakboy3742 12y agoFYI, Toga uses Cassowary as well - natively through Apple's implementation on OSX and iOS, and via a Python implementation of the algorithm (http://pybee.org/cassowary/ http://pybee.org/cassowary/) for GTK and Windows.
- james2vegas 12y agoyeah, very novel. https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Tutorial/The_Box_Model https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Tu... http://docs.oracle.com/javase/tutorial/uiswing/layout/howLayoutWorks.html http://docs.oracle.com/javase/tutorial/uiswing/layout/howLay...
- analog31 12y agoAndroid compatible?
- JasonFruit 12y agoThey say it would be nice, but not yet, no.
- freakboy3742 12y agoNot yet. Android support is on the todo list once I've processed all the feedback that has come as a result of the initial release.
- malkia 12y agoAnother toolkit that uses Python, but with Qt (and previously also wxWidgets) is enaml - it has a cassowary solver, a Visual Studio docking system, and very interesting approach to connecting that to visual elements. https://github.com/nucleic/enaml https://github.com/nucleic/enaml http://nucleic.github.io/enaml/docs/ http://nucleic.github.io/enaml/docs/
- drglitch 12y agoHaving developed several advanced apps in enaml over last 2 years, i commend enaml. It encourages MVC and provides clean observer-style bindings (Atom). The framework is used internally by at least one fortune 50 corp for a large app suite.
- freakboy3742 12y agoProject author here; Thanks for the heads up - I haven't come across Enaml before. I'll take a look.
- Camillo 12y agoThe Mac screenshot I see on the home page looks about as non-native as the average Qt app.
- WoodenChair 12y agoThat's a matter of design, not an observation based on technical merits.
- ZenoArrow 12y agoMaybe I'm missing something, but isn't the main 'hook' for this library that it looks native? Looks like it uses GTK+, so from a technical standpoint it would be as "native" as Qt.
- ColinCera 12y agoIt does not use GTK+ on a Mac, it uses Cocoa, so it is fully native. Read the docs.
- icefox 12y agoHmm, they should update their front page than. It is pretty clear in stating "Toga uses the system native python GTK+3 bindings for display purposes."
- ColinCera 12y agoThat sentence you quote is immediately underneath the heading "Problems using virtualenv under Ubuntu" — it applies only to Ubuntu, where they do use GTK. But on Mac, they use Cocoa, as stated in several places in the docs.
- freakboy3742 12y agoProject author here; let me confirm that Toga only uses GTK+ under Ubuntu/Linux. On OS/X, it uses Cocoa. I've just clarified the text in that section of the website. Thanks for the heads up.
- roryokane 12y agoDoes anyone know of any similar GUI toolkits, for languages other than Python? That is, cross-platform GUI toolkits that use true OS-native widgets, and ideally, also abstract away platform-specific details such as the placement of the Quit/Exit menu items and the order of OK/Cancel buttons. Toga is actually the first library with those features that I’ve heard of.
- ANTSANTS 12y agoI think you're looking for phoenix: http://byuu.org/programming/phoenix/ http://byuu.org/programming/phoenix/ An example application using it, with the GTK backend: https://i.imgur.com/pW2Jl9q.png https://i.imgur.com/pW2Jl9q.png and the Qt backend: https://i.imgur.com/z6cC3rM.png https://i.imgur.com/z6cC3rM.png The author (byuu) posts here, he might be able to answer questions.
- scythe 12y agoThe most famous such library is wxWidgets; it supports "Python, Perl, Ruby, and many other languages": http://www.wxwidgets.org http://www.wxwidgets.org
- Shorel 12y agowxWidgets has been doing that for more than a decade. Well, may be some very platform specific guidelines have to be added by hand, but the actual widgets used are native.
- WoodenChair 12y agoThis project appears to be quite early stage (many missing APIs, no stable Windows support, poor documentation, etc) but very promising. If it had integration with a GUI designer and was feature complete, I'd start using it on projects. I've explored the options for Python GUI toolkits quite extensively. They're a real challenge to get running conveniently (by conveniently, I mean a simple PIP install away with no external C/C++ library dependencies) on OS X with native looks, and that is a nice advantage of this one IMHO.
- freakboy3742 12y agoThanks for the kind words. Yes, the project is very early stage - I've been tinkering for 6 months in my spare time (and it's not like I had a whole lot of that to start with). Getting cross platform on 4 platforms has, as you might expect, taken a bit of effort. I started down this path because the existing options didn't satisfy me. When my initial couple of weeks of tinkering proved that it was possible to get widgets without binary dependencies, that gave me the momentum to get to the point that I've publicly announced. There's plenty left to do, but I've got high hopes.
- andreasvc 12y ago"No external C/C++ library dependencies" is simply impossible. Given that the host OS is not implemented in Python, some kind of bridge to its native libraries is necessary for a GUI library. Such libraries can be either compiled during the pip installation, or required as an external dependency installed using the package manager of the OS, Either way it's never going to be hassle free due to all the different OSes and package managers.
- TazeTSchnitzel 12y ago>"No external C/C++ library dependencies" is simply impossible. Given that the host OS is not implemented in Python, some kind of bridge to its native libraries is necessary for a GUI library. Not true. Python provides facilities for dealing with dynamic link libraries from native Python code. These can be used to interface with the OS directly, without necessitating writing a C/C++ wrapper.
- theophrastus 12y agoloutish/lazy Debian/"testing" system here: ~> apt-cache search toga toga2 - computer chess engine, calculates chess moves (hm... wake me when it hits testing)
- freakboy3742 12y agoGiven that the project was announced publicly 1 week ago, I wouldn't expect to see it in Debian (testing or otherwise) for a little while.
- andreasvc 12y agoAs a Python library, the package would be called python-toga.
- rjn945 12y agoI was really confused when I read "the constrain() call takes expressions that define the relationships you want to impose" (emphasis mine) and saw this code: container.constrain(button.TOP == container.TOP + 50) Python doesn't let you pass expressions! Why isn't that just getting evaluated to true or false? Is this not vanilla Python? Is there a pre-processor? I dove into the code and found the answer here[1]. button.TOP and container.TOP are both Toga Attributes, which have their equality operators redefined. Very interesting and clever use of operator overloading. [1] https://github.com/pybee/toga/blob/master/toga/constraint.py https://github.com/pybee/toga/blob/master/toga/constraint.py
- 0x006A 12y agosome ORMs do operator overloading too, i.e. SQLAlchemy http://docs.sqlalchemy.org/en/rel_0_9/core/sqlelement.html http://docs.sqlalchemy.org/en/rel_0_9/core/sqlelement.html
- freakboy3742 12y agoThanks for the compliment. As others have pointed out, this isn't an idea of my own creation - others (e.g., SQLAlchemy) have taken similar approaches in other APIs. I'm just exploiting a pattern that I've seen used to good effect elsewhere.
- abritishguy 12y agoGoogle use operator overloading in their appengine stuff.
- rkangel 12y agoI am very conflicted about that trick. On the one hand it is a neat bit of syntax to express what you want, but it goes completely against your expectations of how Python syntax is parsed. 'Clever use of operator overloading' historically has always meant 'confusing use of operator overloading' - something the C++ community took some time to learn. Python is very good at behaving as you expect it to, despite the fact that you can implement pretty much any magic. This is down to library design more than it is language design.
- rkangel 12y agoFor a project like this where there are many other potential options (wxPython etc.) the first question I'm thinking is 'why do I care about this new one'. I.e. What does this do better/differently/more conveniently. I assume the answer here us the native Python aspect and not needing big compiled libraries. Might be worth selling it a bit more on your homepage and making that advantage clearer? It may be that everyone else picked up on Python native quicker than I did, I'm reading this in bed during a lie in so am a bit sleepy!
- freakboy3742 12y agoThanks for the feedback! I cover some of the "why" in the docs, but I agree the homepage could do a better job of making the case for a new UI toolkit. The short version: * System native widgets, not themes * Installable via "pip install" - no third party or binary dependencies * Not just naïve wrappers around widgets - capture the underlying use case and provide an API wrapper. * Genuinely Python native. This means exploiting language specific features (like generators and context managers)
- _random_ 12y ago"Python native" is an oxymoron, given the language's interpreted nature. "Python-idiomatic" would probably be a more correct choice of words. But that's just me.
- andreasvc 12y agoI think that is typically called "pythonic".
- Shorel 12y agowxPython has system native widgets in every platform. wxWidgets has system native widgets in every platform, and it is the only one I know that provides that. May be you are thinking about some other toolkit that's not wxWidgets.
- ymeshesha 12y agoThis toolkit seems extremely simple and user-friendly, might have to give it a try