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

Multi-line TextInput box? #2828

Closed
jbednar opened this Issue Sep 9, 2015 · 7 comments

Comments

Projects
None yet
5 participants
@jbednar
Contributor

jbednar commented Sep 9, 2015

In general I've found it very difficult to find information on Bokeh widgets in the documentation, so maybe this is already possible, but is there a way to specify a paragraph-sized TextInput box? I'm using one for the user to be able to edit some code in a domain-specific language, which is awkward to do in a single-line box.

If multiple lines are not possible, is there at least a way to change the size of the box?

@jbednar

This comment has been minimized.

Contributor

jbednar commented Sep 9, 2015

Right now, the TextInput box accepts multi-line strings, but the newlines just show up as spaces, with everything still on one line.

@jbednar

This comment has been minimized.

Contributor

jbednar commented Sep 9, 2015

It looks like the TextInput box maps to an HTML input object, and I'd need an HTML textarea object in this case.

One complication is that the input object triggers a re-render based on pressing enter, but textarea would need to use enter internally. But there may be no problem with this, since both of them appear to trigger an update when the widget loses focus.

Another complication is that a textarea would need some sizing parameters to determine how large to make it. That might be a good reason to make a new type of Bokeh widget for multi-line input, rather than just adding a multiline=True option to TextInput.

@jbednar

This comment has been minimized.

Contributor

jbednar commented Sep 9, 2015

Actually, needing to press return is an issue. I tested it out by hacking the textinput template to use textarea:

diff --git a/bokehjs/src/coffee/widget/text_input_template.eco b/bokehjs/src/coffee/widget/text_input_template.eco
index 48d790c..8d75812 100644
--- a/bokehjs/src/coffee/widget/text_input_template.eco
+++ b/bokehjs/src/coffee/widget/text_input_template.eco
@@ -1,2 +1,2 @@
 <label for="<%= @id %>"> <%= @title %> </label>
-<input class="bk-widget-form-input" type="text" id="<%=@id %>" name="<%= @name %>" value="<%= @value %>"/>
+<textarea class="bk-widget-form-input" rows="10" cols="50" id="<%=@id %>" name="<%= @name %>"> <%= @value %> </textarea>

This works in terms of displaying the multi-line text and editing it, but I've defined a CustomJS callback for the textinput widget, and it apparently never gets called now, presumably because enter is now taken literally as a carriage return.

@mattpap

This comment has been minimized.

Contributor

mattpap commented Sep 10, 2015

This has to be implemented as a separate widget, so that we don't mix concerns. I may actually do it as part of custom models work, because this touches some interesting issues.

@jbednar

This comment has been minimized.

Contributor

jbednar commented Sep 10, 2015

Interesting sounds scary! :-) I'd wished for easy and boring.

@ghost

This comment has been minimized.

ghost commented Jun 1, 2018

a shame mas-dse-pjmulroo's PR did not work. Is there any plans to make a widget like this in the future?

@bryevdv bryevdv modified the milestone: short-term Sep 11, 2018

@EliYk

This comment has been minimized.

EliYk commented Oct 9, 2018

What would be a simple way of adding a multiline text input to a bokeh app?

(If it's of relevance - it's supposed to accept an SQL query, and display results in a DataTable widget)

Thanks,
Eli

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment