format_str in Item() affects subsequent Item()s in UI
hi,
Using the format_str in an Item() definition to format the string
presentation, such as here:
Item( 'string_trait', style = 'text', label = 'Text', format_str =
"%.6s" ),
causes the Item() to have the format applied, but also every subsequent
Str trait is affected by this format_str.
I don't know if that is the intent, but it doesn't seem right.
here's an example (based on texteditor demo):
from enthought.traits.api \
import HasTraits, Str, Int, Password
from enthought.traits.ui.api \
import Item, Group, View
# The main demo class:
class TextEditorDemo ( HasTraits ):
""" Defines the TextEditor demo class.
"""
# Define a trait for each of three TextEditor variants:
string_trait = Str( "sample string" )
another_string_trait = Str( "more than 6 characters" )
# TextEditor display with multi-line capability (for various traits):
text_str_group = Group(
Item( 'string_trait', style = 'simple', label = 'Simple' ),
Item( '_' ),
Item( 'string_trait', style = 'text', label = 'Text',
format_str = "%.6s" ),
Item( '_' ),
Item( 'string_trait', style = 'readonly', label = 'ReadOnly' ),
Item( '_' ),
Item( '_' ),
Item( 'another_string_trait', style = 'simple', label =
'Simple' ),
Item( '_' ),
Item( 'another_string_trait', style = 'text', label = 'Text' ),
Item( '_' ),
Item( 'another_string_trait', style = 'readonly', label =
'ReadOnly' ),
label = 'String'
)
# The view includes one group per data type. These will be displayed
# on separate tabbed panels:
view = View(
text_str_group,
title = 'TextEditor',
buttons = [ 'OK' ]
)
# Create the demo:
demo = TextEditorDemo()
# Run the demo (if invoked from the command line):
if __name__ == "__main__":
demo.configure_traits()
Thanks
--
--
Chris Kennedy
Apex, NC
http://www.quickactiondrumlug.com
http://www.thinkpeak.com