Live data from Hacker News

Toga: A Python native, OS native GUI toolkit

pybee.org

31–40 of 72 posts

Re: Toga: A Python native, OS native GUI toolkit

#31

Earlier quoted context omitted.

It's using native Cocoa controls, so I'm not sure why you don't think it looks native.

Because the layout that's presented is not native. Actual mac apps don't have tabs and toolbars pushed together like that, and the margins are different. wxWidgets can use the platform native controls, but the apps rarely look native because the layouts and behaviors are non-native. Mac/GNOME/Windows all have different ideal metrics for spacings, control placement and labeling (OK/Cancel vs Cancel/"Do Thing") -- bein…

Fair point. The spacing and margins are totally wrong, for sure. But that's just spacing & margins, and I assume that's easily adjusted (and they should do that, so their demo doesn't look ugly). But nonetheless, the widgets are native Cocoa widgets, so they not only look native, they feel and behave native, something you can't say about Qt (at least not to the same degree — although I develop with Qt, love Qt, and have zero issues with the way Qt applications look and feel on Mac).

Re: Toga: A Python native, OS native GUI toolkit

#32

left_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.

What 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/262efbfc00fae0a96e09666...

Re: Toga: A Python native, OS native GUI toolkit

#33

left_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.

What 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/262efbfc00fae0a96e09666...

either than or you're on windows, where unfortunately next to nothing is implemented

Re: Toga: A Python native, OS native GUI toolkit

#34
I 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

Re: Toga: A Python native, OS native GUI toolkit

#36
post #34

I 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]. butto…

some ORMs do operator overloading too, i.e. SQLAlchemy http://docs.sqlalchemy.org/en/rel_0_9/core/sqlelement.html

Re: Toga: A Python native, OS native GUI toolkit

#37
post #34

I 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]. butto…

Thanks 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.

Re: Toga: A Python native, OS native GUI toolkit

#38

Earlier quoted context omitted.

Because the layout that's presented is not native. Actual mac apps don't have tabs and toolbars pushed together like that, and the margins are different. wxWidgets can use the platform native controls, but the apps rarely look native because the layouts and behaviors are non-native. Mac/GNOME/Windows all have different ideal metrics for spacings, control placement and labeling (OK/Cancel vs Cancel/"Do Thing") -- bein…

Fair point. The spacing and margins are totally wrong, for sure. But that's just spacing & margins, and I assume that's easily adjusted (and they should do that, so their demo doesn't look ugly). But nonetheless, the widgets are native Cocoa widgets, so they not only look native, they feel and behave native, something you can't say about Qt (at least not to the same degree — although I develop with Qt, love Qt, and h…

The spacing and margins are all manually specified (or, in the case of the example, aren't specified at all, so they default to 0). If you cared to do so, this spacing could be manually adjusted.

Under the hood, it's 100% native widgets (i.e., on OSX, the code is actually instantiating an NSButton, adding it to an NSView, set as content on an NSWindow; on Ubuntu, it uses Gtk.Button etc), so the look and feel of the widgets themselves are exactly as the platform dictates.

Re: Toga: A Python native, OS native GUI toolkit

#39

Earlier quoted context omitted.

That's a matter of design, not an observation based on technical merits.

Maybe 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.

Project 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.

Re: Toga: A Python native, OS native GUI toolkit

#40
post #2

This looks promising. It would be better if the documentation was a bit more exhaustive[0] [0] http://toga.readthedocs.org/en/latest/internals/platforms/de... .

I'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 :-)
Post reply on HN