Closed typemytype closed 4 years ago
there are still some weird things going on with vanilla.Tabs
. Will check on a different OS...
This seems to work:
see how the last addAutoPosSizeRules
is called after opening of the window, otherwise a VanillaTabItem
does not know his bounds to apply those rules.
class TabViewAutoLayout:
def __init__(self):
self.w = Window((250, 296))
self.w.tab = Tabs("auto", ["hello", "world"])
tabRules = [
# Horizontal
"H:|-border-[text]-border-|",
# Vertical
"V:|-border-[text]-border-|"
]
rules = [
# Horizontal
"H:|-border-[tab]-border-|",
# Vertical
"V:|-border-[tab]-border-|"
]
metrics = {
"border" : 10,
}
hello = self.w.tab[0]
hello.text = TextBox("auto", "hello")
#hello.text = TextBox((10, 10, -10, 22), "hello")
hello.addAutoPosSizeRules(tabRules, metrics)
world = self.w.tab[1]
world.text = TextBox("auto", "world")
world.addAutoPosSizeRules(tabRules, metrics)
self.w.open()
self.w.addAutoPosSizeRules(rules, metrics)
TabViewAutoLayout()
this also works well: the second tab view expands the windows
class TabViewAutoLayout:
def __init__(self):
self.w = Window((250, 296))
self.w.tab = Tabs("auto", ["hello", "world"])
tabRules = [
# Horizontal
"H:|-border-[text]-border-|",
# Vertical
"V:|-border-[text]-border-|"
]
rules = [
# Horizontal
"H:|-border-[tab]-border-|",
# Vertical
"V:|-border-[tab]-border-|"
]
metrics = {
"border" : 10,
}
hello = self.w.tab[0]
hello.text = TextBox("auto", "hello")
#hello.text = TextBox((10, 10, -10, 22), "hello")
hello.addAutoPosSizeRules(tabRules, metrics)
tabWorldRules = [
# Horizontal
"H:|-border-[text]-border-|",
"H:|-border-[text2]-border-|",
# Vertical
"V:|-border-[text]-border-[text2]-border-|"
]
world = self.w.tab[1]
world.text = TextBox("auto", "world")
world.text2 = TextBox("auto", "world")
world.addAutoPosSizeRules(tabWorldRules, metrics)
self.w.open()
self.w.addAutoPosSizeRules(rules, metrics)
TabViewAutoLayout()
similar to what happens with a posSize approache: the child view, the _nsobject view, is added to the parent contentview
fixes #120