首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >GoldenLayout(ipygoldenlayout):如何以编程方式更改标签?

GoldenLayout(ipygoldenlayout):如何以编程方式更改标签?
EN

Stack Overflow用户
提问于 2021-07-10 09:02:35
回答 1查看 53关注 0票数 1

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

代码语言:javascript
复制
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)
EN

回答 1

Stack Overflow用户

发布于 2021-07-20 01:11:53

我已经弄明白了,这就是答案。

代码语言:javascript
复制
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的选项卡。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68323922

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档