cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Why doesn't my notebook display widgets when I use 'dbutils' while it is displayed with '%sql CREATE WIDGET'?

daindana
New Contributor III

The widget is not shown when I use dbutils while it works perfect with sql.

For example,

%sql
 
CREATE WIDGET TEXT state DEFAULT "CA"

This one shows me widget.

dbutils.widgets.text("name", "Brickster", "Name")
dbutils.widgets.multiselect("colors", "orange", ["red", "orange", "black", "blue"], "Traffic Sources")

This one shows nothing even though I can see `Command took 0.03 seconds` message.

Also, I can get results from widget even though I cannot see it when I use codes below.

name = dbutils.widgets.get("name")
colors = dbutils.widgets.get("colors").split(",")
 
html = "<div>Hi {}! Select your color preference.</div>".format(name)
for c in colors:
  html += """<label for="{}" style="color:{}"><input type="radio"> {}</label><br>""".format(c, c, c)
 
displayHTML(html)

I attached images.dbutils get info from widgetdbutils widget creation

1 ACCEPTED SOLUTION

Accepted Solutions

daindana
New Contributor III

Hello, Ryan! For some reason, this problem is solved, and now it is working perfectly! I did nothing new, but it is just working now.

Thank you!:)

View solution in original post

4 REPLIES 4

Kaniz_Fatma
Community Manager
Community Manager

Hi @ daindana! My name is Kaniz, and I'm the technical moderator here. Great to meet you, and thanks for your question! Let's see if your peers in the community have an answer to your question first. Or else I will follow up with my team and get back to you soon. Thanks.

Ryan_Chynoweth
Esteemed Contributor

Hi @DAIN KIMโ€‹ , I tried to reproduce your issue but was unable to. Which language of notebook are you using (python,sql)?

And just to be clear, the python dbutils.widget.text does not show up at the top of the notebook?

daindana
New Contributor III

Hello, Ryan! For some reason, this problem is solved, and now it is working perfectly! I did nothing new, but it is just working now.

Thank you!:)

That is great to hear! It seemed like an odd issue but glad it all worked out.

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you wonโ€™t want to miss the chance to attend and share knowledge.

If there isnโ€™t a group near you, start one and help create a community that brings people together.

Request a New Group