繁体   English   中英

从自己的类调用 iPyWidgets 不显示

[英]Call iPyWidgets from own class doesn´t show

我尝试通过我自己的类从 iPyWidgets 调用一个按钮,但不幸的是它不会显示小部件。 但是当我直接在控制台(Jupyterhub)中调用小部件代码时,它会显示按钮。 这是我的代码

调用按钮.py

from here.analysis.testUI import TestUI
def call_button():
    test = TestUI()
    go = test.button()
    go

测试界面

from ipywidgets import widgets
from IPython.display import display
from ipywidgets import Button, HBox, VBox, Layout, Button, Text, Textarea

class TestUI():
    def __init__(self):
        print("Just initialized")

    def button(self):
        #Maybe a return is not needed, but it also doesn´t work without a return
        return widgets.Button(description = 'clear', layout=Layout(width='20%', height='100%'))

我在 Python 控制台中调用它,如下所示:

from here.analysis.callButton import call_button
call_button()

那么为什么按钮不显示呢? 我错过了什么吗?

确保使用 call_button.py 中的display(button)显式显示display(button)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM