我正在尝试找到一种在ipyGoldenLayout中以编程方式更改选项卡的方法。我有没有办法做这件事?

import ipyvuetify as v
from traitlets import Unicode
from ipygoldenlayout import GoldenLayout
gl = GoldenLayout()
class TestGL(v.VuetifyTemplate):
template = Unicode("""
<golden-layout style="height: 200px">
<gl-row>
<gl-component title="component1">
<h1>Component 1</h1>
</gl-component>
<gl-stack>
<gl-component title="component2">
<h1>Component 2</h1>
</gl-component>
<gl-component title="component3">
<h1>Component 3</h1>
</gl-component>
</gl-stack>
</gl-row>
</golden-layout>
""").tag(sync=True)发布于 2021-07-20 01:11:53
我已经弄明白了,这就是答案。
import ipyvuetify as v
from traitlets import Unicode
from ipygoldenlayout import GoldenLayout
gl = GoldenLayout()
class TestGL(v.VuetifyTemplate):
tabs = Any("1").tag(sync=True)
template = Unicode("""
<golden-layout style="height: 200px">
<gl-row>
<gl-component title="component1">
<h1>Component 1</h1>
</gl-component>
<gl-stack v-model="tabs">
<gl-component title="component2" tab-id="1">
<h1>Component 2</h1>
</gl-component>
<gl-component title="component3" tab-id="2">
<h1>Component 3</h1>
</gl-component>
</gl-stack>
</gl-row>
</golden-layout>
""").tag(sync=True)
obj = TestGL()我可以调用obj.tabs = "2"以编程方式切换到component 3的选项卡。
https://stackoverflow.com/questions/68323922
复制相似问题