Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When loading from a file the .observe and .on_click functions don't work on a rerun of the cell #3959

Open
FishingBehindTheNet opened this issue Oct 22, 2024 · 0 comments

Comments

@FishingBehindTheNet
Copy link

Im using Ipywidgets in a jupytor notbook in VScode. When making a interface i use a .py file to code an load this into the notbook. This looks like the following

import Moduals.TestFile as File

display(File.button)

where the testfile looks as follows

import ipywidgets as widgets

button = widgets.Button(description="Click me")

def F_button(PlacHolder = None):
    print("Press")

button.on_click(F_button)

This works fine until I need to reload the cell in the notebook. After doing this, the .observe or .on_click don't register any input. After the kernel is reloaded, the functions work again until you reload the cell without reloading the kernel.

I expected the .observe to work the second time, but even after resetting all global variables, the problem still persists. I suspect that the button might be renamed because the same occurs when using the code from the test file in a notebook and display(button) is in a second cell. If the first cell is reloaded, the button is not recognized until I rerun the second cell. But then I don't understand why this is not resolved by resetting the global variables.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant