Renamed widgets...

TextWidget, TextareaWidget, CheckboxWidget, and SelectWidget
This commit is contained in:
Jonathan Frederic 2014-01-28 12:51:24 -08:00
parent 5ed3a0ebc5
commit 75b148d40b
19 changed files with 56 additions and 73 deletions

View File

@ -16,7 +16,7 @@
define(["notebook/js/widgets/widget"], function(WidgetManager){ define(["notebook/js/widgets/widget"], function(WidgetManager){
var CheckBoxView = IPython.DOMWidgetView.extend({ var CheckboxView = IPython.DOMWidgetView.extend({
render : function(){ render : function(){
// Called when view is rendered. // Called when view is rendered.
this.$el this.$el
@ -63,11 +63,11 @@ define(["notebook/js/widgets/widget"], function(WidgetManager){
this.$label.show(); this.$label.show();
} }
} }
return CheckBoxView.__super__.update.apply(this); return CheckboxView.__super__.update.apply(this);
}, },
}); });
WidgetManager.register_widget_view('CheckBoxView', CheckBoxView); WidgetManager.register_widget_view('CheckboxView', CheckboxView);
var ToggleButtonView = IPython.DOMWidgetView.extend({ var ToggleButtonView = IPython.DOMWidgetView.extend({

View File

@ -292,7 +292,7 @@ define(["notebook/js/widgets/widget"], function(WidgetManager){
WidgetManager.register_widget_view('ToggleButtonsView', ToggleButtonsView); WidgetManager.register_widget_view('ToggleButtonsView', ToggleButtonsView);
var ListBoxView = IPython.DOMWidgetView.extend({ var SelectView = IPython.DOMWidgetView.extend({
render : function(){ render : function(){
// Called when view is rendered. // Called when view is rendered.
this.$el this.$el
@ -360,7 +360,7 @@ define(["notebook/js/widgets/widget"], function(WidgetManager){
this.$label.show(); this.$label.show();
} }
} }
return ListBoxView.__super__.update.apply(this); return SelectView.__super__.update.apply(this);
}, },
handle_click: function (e) { handle_click: function (e) {
@ -372,5 +372,5 @@ define(["notebook/js/widgets/widget"], function(WidgetManager){
this.touch(); this.touch();
}, },
}); });
WidgetManager.register_widget_view('ListBoxView', ListBoxView); WidgetManager.register_widget_view('SelectView', SelectView);
}); });

View File

@ -54,7 +54,7 @@ define(["notebook/js/widgets/widget"], function(WidgetManager){
WidgetManager.register_widget_view('LatexView', LatexView); WidgetManager.register_widget_view('LatexView', LatexView);
var TextAreaView = IPython.DOMWidgetView.extend({ var TextareaView = IPython.DOMWidgetView.extend({
render: function(){ render: function(){
// Called when view is rendered. // Called when view is rendered.
this.$el this.$el
@ -104,7 +104,7 @@ define(["notebook/js/widgets/widget"], function(WidgetManager){
this.$label.show(); this.$label.show();
} }
} }
return TextAreaView.__super__.update.apply(this); return TextareaView.__super__.update.apply(this);
}, },
events: { events: {
@ -123,10 +123,10 @@ define(["notebook/js/widgets/widget"], function(WidgetManager){
this.touch(); this.touch();
}, },
}); });
WidgetManager.register_widget_view('TextAreaView', TextAreaView); WidgetManager.register_widget_view('TextareaView', TextareaView);
var TextBoxView = IPython.DOMWidgetView.extend({ var TextView = IPython.DOMWidgetView.extend({
render: function(){ render: function(){
// Called when view is rendered. // Called when view is rendered.
this.$el this.$el
@ -164,7 +164,7 @@ define(["notebook/js/widgets/widget"], function(WidgetManager){
this.$label.show(); this.$label.show();
} }
} }
return TextBoxView.__super__.update.apply(this); return TextView.__super__.update.apply(this);
}, },
events: { events: {
@ -218,5 +218,5 @@ define(["notebook/js/widgets/widget"], function(WidgetManager){
} }
}, },
}); });
WidgetManager.register_widget_view('TextBoxView', TextBoxView); WidgetManager.register_widget_view('TextView', TextView);
}); });

View File

@ -27,7 +27,7 @@ casper.notebook_test(function () {
throttle_index = this.append_cell( throttle_index = this.append_cell(
'import time\n' + 'import time\n' +
'textbox = widgets.TextBoxWidget()\n' + 'textbox = widgets.TextWidget()\n' +
'display(textbox)\n'+ 'display(textbox)\n'+
'textbox.add_class("my-throttle-textbox")\n' + 'textbox.add_class("my-throttle-textbox")\n' +
'def handle_change(name, old, new):\n' + 'def handle_change(name, old, new):\n' +

View File

@ -7,7 +7,7 @@ casper.notebook_test(function () {
this.execute_cell_then(index); this.execute_cell_then(index);
var bool_index = this.append_cell( var bool_index = this.append_cell(
'bool_widgets = [widgets.CheckBoxWidget(description="Title", value=True),\n' + 'bool_widgets = [widgets.CheckboxWidget(description="Title", value=True),\n' +
' widgets.ToggleButtonWidget(description="Title", value=True)]\n' + ' widgets.ToggleButtonWidget(description="Title", value=True)]\n' +
'display(bool_widgets[0])\n' + 'display(bool_widgets[0])\n' +
'display(bool_widgets[1])\n' + 'display(bool_widgets[1])\n' +

View File

@ -10,9 +10,9 @@ casper.notebook_test(function () {
var multicontainer1_query = '.widget-area .widget-subarea div div.nav-tabs'; var multicontainer1_query = '.widget-area .widget-subarea div div.nav-tabs';
var multicontainer1_index = this.append_cell( var multicontainer1_index = this.append_cell(
'multicontainer = widgets.TabWidget()\n' + 'multicontainer = widgets.TabWidget()\n' +
'page1 = widgets.TextBoxWidget()\n' + 'page1 = widgets.TextWidget()\n' +
'page2 = widgets.TextBoxWidget()\n' + 'page2 = widgets.TextWidget()\n' +
'page3 = widgets.TextBoxWidget()\n' + 'page3 = widgets.TextWidget()\n' +
'multicontainer.children = [page1, page2, page3]\n' + 'multicontainer.children = [page1, page2, page3]\n' +
'display(multicontainer)\n' + 'display(multicontainer)\n' +
'multicontainer.selected_index = 0\n' + 'multicontainer.selected_index = 0\n' +

View File

@ -47,7 +47,7 @@ casper.notebook_test(function () {
'selection = [widgets.DropdownWidget(values=values),\n' + 'selection = [widgets.DropdownWidget(values=values),\n' +
' widgets.ToggleButtonsWidget(values=values),\n' + ' widgets.ToggleButtonsWidget(values=values),\n' +
' widgets.RadioButtonsWidget(values=values),\n' + ' widgets.RadioButtonsWidget(values=values),\n' +
' widgets.ListBoxWidget(values=values)]\n' + ' widgets.SelectWidget(values=values)]\n' +
'[display(selection[i]) for i in range(4)]\n' + '[display(selection[i]) for i in range(4)]\n' +
'for widget in selection:\n' + 'for widget in selection:\n' +
' def handle_change(name,old,new):\n' + ' def handle_change(name,old,new):\n' +

View File

@ -7,8 +7,8 @@ casper.notebook_test(function () {
this.execute_cell_then(index); this.execute_cell_then(index);
var string_index = this.append_cell( var string_index = this.append_cell(
'string_widget = [widgets.TextBoxWidget(value = "xyz"),\n' + 'string_widget = [widgets.TextWidget(value = "xyz"),\n' +
' widgets.TextAreaWidget(value = "xyz"),\n' + ' widgets.TextareaWidget(value = "xyz"),\n' +
' widgets.HTMLWidget(value = "xyz"),\n' + ' widgets.HTMLWidget(value = "xyz"),\n' +
' widgets.LatexWidget(value = "$\\\\LaTeX{}$")]\n' + ' widgets.LatexWidget(value = "$\\\\LaTeX{}$")]\n' +
'[display(widget) for widget in string_widget]\n'+ '[display(widget) for widget in string_widget]\n'+

View File

@ -1,11 +1,11 @@
from .widget import Widget, DOMWidget, CallbackDispatcher from .widget import Widget, DOMWidget, CallbackDispatcher
from .widget_bool import CheckBoxWidget, ToggleButtonWidget from .widget_bool import CheckboxWidget, ToggleButtonWidget
from .widget_button import ButtonWidget from .widget_button import ButtonWidget
from .widget_container import ContainerWidget, PopupWidget from .widget_container import ContainerWidget, PopupWidget
from .widget_float import FloatTextWidget, BoundedFloatTextWidget, FloatSliderWidget, FloatProgressWidget from .widget_float import FloatTextWidget, BoundedFloatTextWidget, FloatSliderWidget, FloatProgressWidget
from .widget_image import ImageWidget from .widget_image import ImageWidget
from .widget_int import IntTextWidget, BoundedIntTextWidget, IntSliderWidget, IntProgressWidget from .widget_int import IntTextWidget, BoundedIntTextWidget, IntSliderWidget, IntProgressWidget
from .widget_selection import RadioButtonsWidget, ToggleButtonsWidget, DropdownWidget, ListBoxWidget from .widget_selection import RadioButtonsWidget, ToggleButtonsWidget, DropdownWidget, SelectWidget
from .widget_selectioncontainer import TabWidget, AccordionWidget from .widget_selectioncontainer import TabWidget, AccordionWidget
from .widget_string import HTMLWidget, LatexWidget, TextBoxWidget, TextAreaWidget from .widget_string import HTMLWidget, LatexWidget, TextWidget, TextareaWidget

View File

@ -25,8 +25,8 @@ class _BoolWidget(DOMWidget):
disabled = Bool(False, help="Enable or disable user changes.", sync=True) disabled = Bool(False, help="Enable or disable user changes.", sync=True)
class CheckBoxWidget(_BoolWidget): class CheckboxWidget(_BoolWidget):
_view_name = Unicode('CheckBoxView', sync=True) _view_name = Unicode('CheckboxView', sync=True)
class ToggleButtonWidget(_BoolWidget): class ToggleButtonWidget(_BoolWidget):

View File

@ -91,5 +91,5 @@ class RadioButtonsWidget(_SelectionWidget):
_view_name = Unicode('RadioButtonsView', sync=True) _view_name = Unicode('RadioButtonsView', sync=True)
class ListBoxWidget(_SelectionWidget): class SelectWidget(_SelectionWidget):
_view_name = Unicode('ListBoxView', sync=True) _view_name = Unicode('SelectView', sync=True)

View File

@ -33,18 +33,18 @@ class LatexWidget(_StringWidget):
_view_name = Unicode('LatexView', sync=True) _view_name = Unicode('LatexView', sync=True)
class TextAreaWidget(_StringWidget): class TextareaWidget(_StringWidget):
_view_name = Unicode('TextAreaView', sync=True) _view_name = Unicode('TextareaView', sync=True)
def scroll_to_bottom(self): def scroll_to_bottom(self):
self.send({"method": "scroll_to_bottom"}) self.send({"method": "scroll_to_bottom"})
class TextBoxWidget(_StringWidget): class TextWidget(_StringWidget):
_view_name = Unicode('TextBoxView', sync=True) _view_name = Unicode('TextView', sync=True)
def __init__(self, **kwargs): def __init__(self, **kwargs):
super(TextBoxWidget, self).__init__(**kwargs) super(TextWidget, self).__init__(**kwargs)
self._submission_callbacks = CallbackDispatcher() self._submission_callbacks = CallbackDispatcher()
self.on_msg(self._handle_string_msg) self.on_msg(self._handle_string_msg)

View File

@ -30,14 +30,14 @@
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
"source": [ "source": [
"Create a textbox Widget without displaying it. The widget will be used to store the notebook's name which is otherwise only available in the front-end." "Create a text Widget without displaying it. The widget will be used to store the notebook's name which is otherwise only available in the front-end."
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"collapsed": false, "collapsed": false,
"input": [ "input": [
"notebook_name = widgets.TextBoxWidget()" "notebook_name = widgets.TextWidget()"
], ],
"language": "python", "language": "python",
"metadata": {}, "metadata": {},

View File

@ -179,7 +179,7 @@
"metadata": {}, "metadata": {},
"output_type": "display_data", "output_type": "display_data",
"text": [ "text": [
"<IPython.core.display.Javascript at 0x22870d0>" "<IPython.core.display.Javascript at 0x36df2d0>"
] ]
} }
], ],

View File

@ -136,11 +136,11 @@
" 'width': '800px',\n", " 'width': '800px',\n",
"}\n", "}\n",
"\n", "\n",
"output_box = widgets.TextAreaWidget()\n", "output_box = widgets.TextareaWidget()\n",
"output_box.set_css(console_style)\n", "output_box.set_css(console_style)\n",
"output_box.set_css('height', '400px')\n", "output_box.set_css('height', '400px')\n",
"\n", "\n",
"input_box = widgets.TextBoxWidget()\n", "input_box = widgets.TextWidget()\n",
"input_box.set_css(console_style)\n", "input_box.set_css(console_style)\n",
"\n", "\n",
"console_container.children = [output_box, input_box]" "console_container.children = [output_box, input_box]"
@ -203,7 +203,7 @@
"collapsed": false, "collapsed": false,
"input": [ "input": [
"toggle_button = widgets.ButtonWidget(description=\"Start Console\")\n", "toggle_button = widgets.ButtonWidget(description=\"Start Console\")\n",
"def toggle_console():\n", "def toggle_console(sender):\n",
" console_container.visible = not console_container.visible\n", " console_container.visible = not console_container.visible\n",
" if console_container.visible:\n", " if console_container.visible:\n",
" toggle_button.description=\"Stop Console\"\n", " toggle_button.description=\"Stop Console\"\n",

View File

@ -48,7 +48,7 @@
"source": [ "source": [
"IPython comes with basic widgets that represent common interactive controls. These widgets are\n", "IPython comes with basic widgets that represent common interactive controls. These widgets are\n",
"\n", "\n",
"- CheckBoxWidget\n", "- CheckboxWidget\n",
"- ToggleButtonWidget\n", "- ToggleButtonWidget\n",
"- FloatSliderWidget\n", "- FloatSliderWidget\n",
"- BoundedFloatTextWidget\n", "- BoundedFloatTextWidget\n",
@ -62,11 +62,11 @@
"- ToggleButtonsWidget\n", "- ToggleButtonsWidget\n",
"- RadioButtonsWidget\n", "- RadioButtonsWidget\n",
"- DropdownWidget\n", "- DropdownWidget\n",
"- ListBoxWidget\n", "- SelectWidget\n",
"- HTMLWidget\n", "- HTMLWidget\n",
"- LatexWidget\n", "- LatexWidget\n",
"- TextAreaWidget\n", "- TextareaWidget\n",
"- TextBoxWidget\n", "- TextWidget\n",
"- ButtonWidget\n", "- ButtonWidget\n",
"\n", "\n",
"A few special widgets are also included, that can be used to capture events and change how other widgets are displayed. These widgets are\n", "A few special widgets are also included, that can be used to capture events and change how other widgets are displayed. These widgets are\n",
@ -97,7 +97,7 @@
" 'BoundedFloatTextWidget',\n", " 'BoundedFloatTextWidget',\n",
" 'BoundedIntTextWidget',\n", " 'BoundedIntTextWidget',\n",
" 'ButtonWidget',\n", " 'ButtonWidget',\n",
" 'CheckBoxWidget',\n", " 'CheckboxWidget',\n",
" 'ContainerWidget',\n", " 'ContainerWidget',\n",
" 'DOMWidget',\n", " 'DOMWidget',\n",
" 'DropdownWidget',\n", " 'DropdownWidget',\n",
@ -110,12 +110,12 @@
" 'IntSliderWidget',\n", " 'IntSliderWidget',\n",
" 'IntTextWidget',\n", " 'IntTextWidget',\n",
" 'LatexWidget',\n", " 'LatexWidget',\n",
" 'ListBoxWidget',\n",
" 'PopupWidget',\n", " 'PopupWidget',\n",
" 'RadioButtonsWidget',\n", " 'RadioButtonsWidget',\n",
" 'SelectWidget',\n",
" 'TabWidget',\n", " 'TabWidget',\n",
" 'TextAreaWidget',\n", " 'TextWidget',\n",
" 'TextBoxWidget',\n", " 'TextareaWidget',\n",
" 'ToggleButtonWidget',\n", " 'ToggleButtonWidget',\n",
" 'ToggleButtonsWidget',\n", " 'ToggleButtonsWidget',\n",
" 'Widget']" " 'Widget']"

View File

@ -119,29 +119,7 @@
], ],
"language": "python", "language": "python",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [],
{
"output_type": "stream",
"stream": "stdout",
"text": [
"1\n"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
"2\n"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
"3\n"
]
}
],
"prompt_number": 3 "prompt_number": 3
}, },
{ {
@ -223,6 +201,13 @@
"Button clicked.\n" "Button clicked.\n"
] ]
}, },
{
"output_type": "stream",
"stream": "stdout",
"text": [
"Button clicked.\n"
]
},
{ {
"output_type": "stream", "output_type": "stream",
"stream": "stdout", "stream": "stdout",

View File

@ -965,8 +965,8 @@
"collapsed": false, "collapsed": false,
"input": [ "input": [
"# Add some additional widgets for aesthetic purpose\n", "# Add some additional widgets for aesthetic purpose\n",
"display(widgets.TextBoxWidget(description=\"First:\"))\n", "display(widgets.TextWidget(description=\"First:\"))\n",
"display(widgets.TextBoxWidget(description=\"Last:\"))\n", "display(widgets.TextWidget(description=\"Last:\"))\n",
"\n", "\n",
"my_widget = DateWidget()\n", "my_widget = DateWidget()\n",
"display(my_widget)\n", "display(my_widget)\n",

View File

@ -54,11 +54,9 @@
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
"source": [ "source": [
"- [Widget Tester](Widget Tester.ipynb) \n",
"- [Variable Inspector](Variable Inspector.ipynb) \n", "- [Variable Inspector](Variable Inspector.ipynb) \n",
"- [Export As (nbconvert)](Export As (nbconvert%29.ipynb) \n", "- [Export As (nbconvert)](Export As (nbconvert%29.ipynb) \n",
"- [Nonblocking Console](Nonblocking Console.ipynb) \n", "- [Nonblocking Console](Nonblocking Console.ipynb) \n",
"- [D3](D3.ipynb) \n",
"- [File Upload Widget](File Upload Widget.ipynb) " "- [File Upload Widget](File Upload Widget.ipynb) "
] ]
} }