Jump to content

Appmode not supporting input() function?


Recommended Posts

Posted (edited)

After yesterday's SEEQ update, the Appmode button has been changed to Add-on Mode.

 image.png.1c40f741f2b4e6847a7446a1dc7c23ac.png

My script has a line for user input using the native input() function. It is getting the following error:

image.png.63689071ef344c951ecca54f1ddd94b9.png

How do I resolved this issue? The script runs fine in the native window. 

Edited by Wen
  • Seeq Team
Posted (edited)

In more recent versions of Seeq (+R58),  we have changed our Add-on rendering engine to Voila and renamed the functionality to "Add-on Mode" from "AppMode."  The rendered Voila interface is designed for interactivity and is based on widgets. As you've noticed this means that code in a cell may not function the same way in both Jupyter and Voila. This is particularly true around interactions (i.e. inputs).  A way to get an input is to use a widget from ipywidgets and then use the value from the widget in your code. Here is a sample code snippet that uses an input widget and renders the value when a button is clicked. 

import ipywidgets as widgets

#Define the input
user_input = widgets.Text(
    value='Hello World',
    placeholder='Type something',
    description='String:',
    disabled=False
)

#define a button
button = widgets.Button(
    description="Execute",
    button_style='success'
)

#define an Output - someplace to render the button click
output = widgets.Output()

#Do something when button is clicked
def get_input_value(b):
    with output:
        print(user_input.value)

button.on_click(get_input_value)

#display input, button, and output Vertically
widgets.VBox([user_input,button,output])

846488830_Recording2023-01-30at09_33_25.gif

 

Tip
In the new Advanced Mode in Seeq Data Lab you can render your notebook without having to navigate to a separate tab.  You can access the "Add-on Mode Preview" from the  View section in the top menu.  For information about the new Advanced Mode Seeq Data Lab check please check out Advanced Mode for Data Lab.  

Additional Information:
ipywidgets

Edited by John
grammar

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...