Update filter.py for wrapped text and keyworded string input

Updated filter.py to used the new TextFieldWrapped class; added keywords for defining TextFieldWrapped line, width, and default value attributes to replace strValSize, strVal, and strSize optionTypes.

String input fields can now defined with:

("optionName", "string")
OR
("optionName", ("string", "lines=", "width=", "value="))
Conflicts:
	editortools/filter.py
This commit is contained in:
KaboPC 2012-10-23 18:59:00 -03:00 committed by David Vierra
parent cdea40b4b3
commit 8bf1695154

View File

@ -13,7 +13,7 @@ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.""" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE."""
import os import os
import traceback import traceback
from albow import FloatField, IntField, AttrRef, Row, Label, Widget, TabPanel, TextField, CheckBox, Column, Button from albow import FloatField, IntField, AttrRef, Row, Label, Widget, TabPanel, CheckBox, Column, Button, TextFieldWrapped
from editortools.blockview import BlockButton from editortools.blockview import BlockButton
from editortools.editortool import EditorTool from editortools.editortool import EditorTool
from glbackground import Panel from glbackground import Panel
@ -113,32 +113,48 @@ class FilterModuleOptions(Widget):
if isinstance(optionType[0], (str, unicode)): if isinstance(optionType[0], (str, unicode)):
isChoiceButton = False isChoiceButton = False
if len(optionType) == 3:
a,b,c = optionType
if a == "strValSize":
field = TextField(value=b, width=c)
page.optionDict[optionName] = AttrRef(field, 'value')
row = Row((Label(optionName), field)) if optionType[0] == "string":
rows.append(row) kwds = []
wid = None
lin = None
val = None
for keyword in optionType:
if isinstance(keyword, (str, unicode)) and keyword != "string":
kwds.append(keyword)
for keyword in kwds:
splitWord = keyword.split('=')
if len(splitWord) > 1:
v = None
key = None
try:
v = int(splitWord[1])
except:
pass
key = splitWord[0]
if v is not None:
if key == "lines":
lin = v
elif key == "width":
wid = v
else: else:
isChoiceButton = True if key == "value":
elif len(optionType) == 2: val = splitWord[1]
a,b = optionType
if a == "strVal": if lin is None:
field = TextField(value=b, width=200) lin = 1
if val is None:
val = "Input String Here"
if wid is None:
wid = 200
field = TextFieldWrapped(value=val, width=wid,lines=lin)
page.optionDict[optionName] = AttrRef(field, 'value') page.optionDict[optionName] = AttrRef(field, 'value')
row = Row((Label(optionName), field)) row = Row((Label(optionName), field))
rows.append(row) rows.append(row)
elif a == "strSize":
field = TextField(value="Input String Here", width=b)
page.optionDict[optionName] = AttrRef(field, 'value')
row = Row((Label(optionName), field))
rows.append(row)
else:
isChoiceButton = True
else: else:
isChoiceButton = True isChoiceButton = True
@ -171,7 +187,7 @@ class FilterModuleOptions(Widget):
rows.append(wrapped_label(optionName, 50)) rows.append(wrapped_label(optionName, 50))
elif optionType == "string": elif optionType == "string":
field = TextField(value="Input String Here", width=200) field = TextFieldWrapped(value="Input String Here", width=200, lines=1)
page.optionDict[optionName] = AttrRef(field, 'value') page.optionDict[optionName] = AttrRef(field, 'value')
row = Row((Label(optionName), field)) row = Row((Label(optionName), field))