Python Forum
[iPyWidgets] Python exec() not showing GUI
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[iPyWidgets] Python exec() not showing GUI
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.
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%'))
import os
def call_script():

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

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

Thank you for your time.

Forum Jump:

User Panel Messages

Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020