Skip to content

Commit

Permalink
#6676 Creating checkbox or text area with initial values does not wor…
Browse files Browse the repository at this point in the history
…k in expected way (Python Easy Form) (#6677)
  • Loading branch information
rbidas authored and scottdraves committed Jan 19, 2018
1 parent 7987165 commit 99802c3
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 13 deletions.
3 changes: 3 additions & 0 deletions beakerx/beakerx/easyform/easyform.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ def addTextArea(self, *args, **kwargs):
description=self.getDescription(args, kwargs))
textarea.cols = getValue(kwargs, 'width', -1)
textarea.rows = getValue(kwargs, 'height', -1)
textarea.value = getValue(kwargs, 'value', "")
textarea.placeholder = getValue(kwargs, 'placeholder', "")
self.children += (textarea,)
self.components[textarea.description] = textarea
return textarea
Expand Down Expand Up @@ -101,6 +103,7 @@ def addComboBox(self, *args, **kwargs):

def addCheckBox(self, *args, **kwargs):
checkbox = BeakerxCheckbox(description=self.getDescription(args, kwargs))
checkbox.value = getValue(kwargs, 'value', False)
self.children += (checkbox,)
self.components[checkbox.description] = checkbox
return checkbox
Expand Down
52 changes: 39 additions & 13 deletions doc/python/EasyForm.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"from beakerx import *"
Expand Down Expand Up @@ -58,9 +56,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"f['first'] = 'Beaker'\n",
Expand Down Expand Up @@ -109,9 +105,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"f['last'] = \"new Value\""
Expand All @@ -120,9 +114,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"f['first'] = \"new Value2\""
Expand Down Expand Up @@ -246,6 +238,40 @@
"button.actionPerformed = lambda: operator.setitem(f1, 'last', 'action done')\n",
"f1"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Default Values and placeholder"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"f3c = EasyForm(\"form3\")\n",
"f3c = EasyForm(\"form3\")\n",
"f3c.addTextArea(\"Default Value\", value = \"Initial value\")\n",
"f3c.addTextArea(\"Place Holder\", placeholder = \"Put here some text\")\n",
"f3c.addCheckBox(\"Default Checked\", value = True)\n",
"f3c"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"result = dict()\n",
"for child in f3c:\n",
" result[child] = f3c[child]\n",
"\n",
"result"
]
}
],
"metadata": {
Expand All @@ -265,7 +291,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.4"
"version": "3.6.4"
}
},
"nbformat": 4,
Expand Down

0 comments on commit 99802c3

Please sign in to comment.