robotools / vanilla

A Pythonic wrapper around Cocoa.
MIT License
78 stars 28 forks source link

HorizontalStackGroup – VerticalLine is horizontal #162

Closed RafalBuchner closed 8 months ago

RafalBuchner commented 2 years ago

Maybe I'm doing something wrong, but it seems like the vertical line is behaving weirdly. It is not vertical at all. Here is my code:

from AppKit import NSObject
from PyObjCTools import AppHelper
import vanilla

class StackTest(object):
    def __init__(self):
        self.w = vanilla.Window((300, 300), minSize=(300, 300))
        group = vanilla.Group((0, 0, 10, 10))
        group.l = vanilla.List((0,0,-10,-10), ["a","b","c"])
        group2 = vanilla.Group((0, 0, 10, 10))
        group2.l = vanilla.List((0,0,-10,-10), ["d","e","f"])
        group3 = vanilla.Group((0, 0, 10, 10))
        group3.l = vanilla.List((0,0,-10,-10), ["g","h","i"])

        self.w.stack = vanilla.HorizontalStackGroup((0,0, -0,-0), distribution="fillEqually", alignment='center')
        self.w.stack.appendView(group)
        self.w.stack.appendView(vanilla.VerticalLine((0, 0, 1, -0)), width=10)
        self.w.stack.appendView(group2)
        self.w.stack.appendView(vanilla.VerticalLine((0, 0, 1, -0)), width=10)
        self.w.stack.appendView(group3)
        self.w.open()

if __name__ == "__main__":
    from vanilla.test.testTools import executeVanillaTest
    executeVanillaTest(StackTest)
typesupply commented 8 months ago

HorizontalStackGroup has been replaced by HorizontalStackView. Here's a working version of your test:

import vanilla

class StackTest(object):

    def __init__(self):
        self.w = vanilla.Window((300, 300), minSize=(300, 300))
        self.w.stack = vanilla.HorizontalStackView(
            (0, 0, 0, 0),
            distribution="fillEqually",
            spacing=10,
            views=[
                dict(view=vanilla.Button("auto", "One"), width=150),
                dict(view=vanilla.VerticalLine("auto"), height="fill"),
                dict(view=vanilla.Button("auto", "Two"), width=150),
                dict(view=vanilla.VerticalLine("auto"), height="fill"),
                dict(view=vanilla.Button("auto", "Three"), width=150),
            ]
        )
        self.w.open()

StackTest()