[iPyWidgets] Python exec() not showing GUI - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: GUI (https://python-forum.io/forum-10.html) +--- Thread: [iPyWidgets] Python exec() not showing GUI (/thread-23795.html) |
[iPyWidgets] Python exec() not showing GUI - Euniroo - Jan-17-2020 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. |