Issue
I am trying to create dropdown menu using the following code on Python.
pqrs = ['Segment1', 'Segment2', 'Segment3']
#Segment Criteria
Segment_selected = widgets.Text()
# print('=' * term_size.columns)
# print('\n' +"\033[1m" + 'Select a Segment criteria for Selecting HCP Universe' + "\033[0m")
# python code to run in jupyter notebook
from ipywidgets import interact, interactive, Layout
def lx(Segmentation):
Segment_selected.value = str(Segmentation)
int_widget = interactive(lx, Segmentation=pqrs,)
int_widget.children[0].layout = Layout(width='400px',height = '40px')
display(int_widget)
This is generating the following output: Code Output
Now, the problem is I want to show the complete text on the left side of the dropdown. It appears as "Segmentati..." in my case which I want it to be "Segmentation" in my case. But I am unable to do so.
Can you please help me?
Solution
Initially comments widths are fixed. You can set a style to make it bigger - this will reduce the overall other sizes of your widget:
pqrs = ['Segment1', 'Segment2', 'Segment3']
int_widget = interactive(lx, Segmentation=pqrs, )
int_widget.children[0].layout = Layout(width='auto',height = '40px')
int_widget.children[0].style = {'description_width': '200px'} # increase size
display(int_widget)
to get:
The essential documentation for this is here: Widget Styling#Description
Try "auto" or "initial"
for auto-fitting the description_width
.
Answered By - Patrick Artner
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.