question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Alignment of description and widgets

See original GitHub issue

Hello Team, I want to align boxes and description in my code. Please let me know if there is a work around. screen shot 2017-11-30 at 10 28 51 am

Code snippet:

def helper(a,b,c):
            print (a)
TextField1= Text(value='', placeholder='Type client table name',description='Client List Name:',disabled=False)
TextField2= Text(value='', placeholder='Type flagged column name',description='Flagged column name:',disabled=False)
TextField3= Text(value='', placeholder='Type columns name',description='Columns name:',disabled=False)
x=interactive(helper,a=TextField1,b=TextField2,c=TextField3)
display(x)

I tried to reference another stack page and tried a code that worked for one of the users which was as below screen shot 2017-11-30 at 10 31 16 am

The same did not work for me as can be seen below

screen shot 2017-11-30 at 9 48 04 am

Code snippet below:

align_kw = dict(
    _css = (('.widget-label', 'min-width', '20ex'),),
    margin = '0px 0px 5px 12px'
)
platform_ui = widgets.Dropdown(description = 'platform',options=['iPhone','iPad','Android'], **align_kw)
event_type_ui = widgets.Text(value='open', description='Test Event', **align_kw)
os_version_ui = widgets.Text(value='iOS9', description='Operating System', **align_kw)
refresh_ui = widgets.Checkbox(description='Force Refresh', **align_kw)

display(platform_ui,event_type_ui,os_version_ui,refresh_ui)

This snippet is a just a snap of a much bigger UI which I did not share because of confidentiality. Any workaround is much appreciated.

The same issue has been logged in stack overflow @ https://stackoverflow.com/questions/47577096/python-ipywidget-align-description-and-boxes

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
jasongroutcommented, Dec 4, 2017

Thanks for giving both the images and the code snippet so it was easy to modify your example!

Try this (in ipywidgets 7):

from ipywidgets import *

style = {'description_width': '150px'}

def helper(a,b,c):
            print (a)
TextField1= Text(value='', placeholder='Type client table name',description='Client List Name:',disabled=False, style=style)
TextField2= Text(value='', placeholder='Type flagged column name',description='Flagged column name:',disabled=False, style=style)
TextField3= Text(value='', placeholder='Type columns name',description='Columns name:',disabled=False, style=style)
x=interactive(helper,a=TextField1,b=TextField2,c=TextField3)
display(x)
0reactions
mrgloomcommented, Mar 1, 2018

I fixed it, but maybe in some awkward way:

2

table_style = {'description_width': 'initial'}
table_layout = {'width':'150px', 'min_width':'150px', 'height':'28px', 'min_height':'28px'}
row_layout = {'width':'200px', 'min_width':'200px'}

table_header_0_widget = Button(
    description='',
    disabled=True,
    button_style='',
    tooltip='',
    icon='',
    layout=row_layout,
    style=table_style
)

table_header_1_widget = Button( description='header 1',
                                disabled=True,
                                button_style='',
                                tooltip='',
                                icon='',
                                #layout=header_layout,
                                #style=table_style
                                layout=table_layout
                               )
table_header_2_widget = Button( description='header 2',
                                disabled=True,
                                button_style='',
                                tooltip='',
                                icon='',
                                #layout=header_layout,
                                #style=table_style
                                layout=table_layout
                               ) 
table_header_3_widget = Button( description='header 3',
                                disabled=True,
                                button_style='',
                                tooltip='',
                                icon='',
                                #layout=header_layout,
                                #style=table_style
                                layout=table_layout
                               )
							   
row_1_0_widget = Button(
    description='row2 looooooooooooong:',
    disabled=True,
    button_style='',
    tooltip='',
    icon='',
    layout=row_layout,
    style=table_style
)
row_1_1_widget = BoundedFloatText(
                                    value=70.0,
                                    min=30.0,
                                    max=300.0,
                                    step=1.0,
                                    layout=table_layout,
                                    style=table_style,
                                 )
row_1_2_widget = BoundedFloatText(
                                    value=80.0,
                                    min=30.0,
                                    max=300.0,
                                    step=1.0,
                                    description='',
                                    layout=table_layout,
                                    style=table_style
                                 )
row_1_3_widget = BoundedFloatText(
                                    value=90.0,
                                    min=30.0,
                                    max=300.0,
                                    step=1.0,
                                    description='',
                                    layout=table_layout,
                                    style=table_style
                                 )
row_2_0_widget = Button(
    description='row3:',
    disabled=True,
    button_style='',
    tooltip='',
    icon='',
    layout=row_layout,
    style=table_style
)
row_2_1_widget = BoundedFloatText(
                                    value=20.0,
                                    min=1.0,
                                    max=100.0,
                                    step=1.0,
                                    layout=table_layout,
                                    style=table_style
                                 )
row_2_2_widget = BoundedFloatText(
                                    value=30.0,
                                    min=1.0,
                                    max=100.0,
                                    step=1.0,
                                    description='',
                                    layout=table_layout,
                                    style=table_style
                                 )
row_2_3_widget = BoundedFloatText(
                                    value=40.0,
                                    min=1.0,
                                    max=100.0,
                                    step=1.0,
                                    description='',
                                    layout=table_layout,
                                    style=table_style
                                 )

hbox1 = HBox([table_header_0_widget, table_header_1_widget, table_header_2_widget, table_header_3_widget])
hbox2 = HBox([row_1_0_widget, row_1_1_widget, row_1_2_widget, row_1_3_widget])
hbox3 = HBox([row_2_0_widget, row_2_1_widget, row_2_2_widget, row_2_3_widget])
ui = VBox([hbox1, hbox2, hbox3])

def func(p1,p2,p3,p4,p5,p6):
    print(p1,p2,p3,p4,p5,p6)
    
w = interactive_output(func,
                       { 
                         "p1":row_1_1_widget,
                         "p2":row_1_2_widget,
                         "p3":row_1_3_widget,
                         "p4":row_2_1_widget,
                         "p5":row_2_2_widget,
                         "p6":row_2_3_widget,
                       })

display(ui, w)
Read more comments on GitHub >

github_iconTop Results From Across the Web

Align class - widgets library - Flutter - Dart API docs
The alignment property describes a point in the child 's coordinate system and a different point in the coordinate system of this widget....
Read more >
How to align single widgets in Flutter? - Stack Overflow
How to align widgets. To align a child widget within its parent you use the Align widget. If you know how to use...
Read more >
Align Widget in Flutter - GeeksforGeeks
Align Widget is the widget that is used to align its child within itself and optionally sizes itself based on the child's size....
Read more >
Flutter - Using Align Widget Examples - Woolha
This tutorial shows you how to set the alignment of a widget using Align widget in Flutter. It's quite common to align a...
Read more >
Widget Alignment - Jupyter Notebooks Gallery
Alignment · Most widgets have a description attribute, which allows a label for the widget to be defined. · If a label is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found