Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 [iPyWidgets] Python exec() not showing GUI
#1
Hello my fellow programmers,

I want to include a script from another file that creates a UI with iPyWidgets. The problem is that the code will execute but nothing is shown. I am using Jupyterhub to display the button. When I run the code on itself, the button is showing.

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

widgets.Button(description = 'clear',
layout=Layout(width='20%', height='100%'))
call_button_script.py
import os
def call_script():

    script_dir = os.path.dirname(os.path.abspath(__file__))
    script_fqn = os.path.join(script_dir, 'button_code.py')
    script = open(script_fqn).read()

    exec(script, globals())
The code is executed via the following import:
from call_button_script import call_script
call_script()()
Am I missing something crucial or is there another possible mistake?

Thank you for your time.
Quote

Top Page

Forum Jump:


Users browsing this thread: 1 Guest(s)