Ejemplo n.º 1
0
 def default_traits_view(self):
     traits_view = View(
         VGroup(
             Bound(
                 TextField(id='input_units'),
                 'valid << object.input_units_valid',
                 'value := object.input_units',
                 label=u'Input units:',
             ),
             Bound(
                 HBoxLayout(
                     CheckBox(id='check'),
                     EditableComboBox(id='combo'),
                 ),
                 'combo.lineEdit.valid << object.output_units_valid',
                 'combo.values << handler.output_units_recommendations',
                 'combo.enabled << object.convert_units',
                 'check.checked := object.convert_units',
                 'combo.value >> object.output_units',
                 label=u'Convert units:',
             ),
         ),
         buttons=['OK'],
     )
     return traits_view
Ejemplo n.º 2
0
 def default_traits_view(self):
     traits_view = View(
         Bound(
             FormLayout(
                 (u'Integer:',
                  HBoxLayout(IntSlider(id='int_slider', range=(-100, 100)),
                             Label(id='int_text', minimumWidth=50))),
                 (u'Float:',
                  HBoxLayout(
                      FloatSlider(id='float_slider', range=(-10.0, 10.0)),
                      Label(id='float_text', minimumWidth=50))),
                 (u'Log:',
                  HBoxLayout(LogSlider(id='log_slider', range=(0.5, 2.0)),
                             Label(id='log_text', minimumWidth=50))),
                 fieldGrowthPolicy=QtGui.QFormLayout.ExpandingFieldsGrow,
             ),
             'int_slider.value := object.int_value',
             'int_text.text << str(object.int_value)',
             'float_slider.value := object.float_value',
             'float_text.text << u"{:0.2f}".format(object.float_value)',
             'log_slider.value := object.log_value',
             'log_text.text << u"{:0.4f}".format(object.log_value)',
         ),
         resizable=True,
         title=u'Sliders',
     )
     return traits_view
Ejemplo n.º 3
0
 def default_traits_view(self):
     traits_view = View(
         Bound(
             FormLayout(
                 (u'Integer:',
                  RangeSlider(id='int_slider', range=(-100, 100))),
                 (u'Float:',
                  RangeSlider(id='float_slider',
                              slider=FloatSlider(),
                              range=(-10.0, 10.0),
                              field_format_func=u'{0:.2f}'.format)),
                 (u'Log:',
                  RangeSlider(id='log_slider',
                              slider=LogSlider(),
                              range=(0.5, 2.0),
                              field_format_func=u'{0:.6f}'.format)),
                 fieldGrowthPolicy=QtGui.QFormLayout.ExpandingFieldsGrow,
             ),
             'int_slider.value := object.int_value',
             'float_slider.value := object.float_value',
             'log_slider.value := object.log_value',
             # Make the labels align nicely by fixing their widths using
             # stylesheets.
             stylesheet=(u'*[binder_class="RangeSlider"] > .QLabel '
                         u'{min-width: 40px; max-width: 40px;}'),
         ),
         resizable=True,
         title=u'Range Sliders',
     )
     return traits_view
Ejemplo n.º 4
0
 def default_traits_view(self):
     traits_view = View(
         Bound(
             EnumDropDown(values=[('auto',
                                   u'Automatic'), ('enter', u'On Enter')]),
             'value := object.mode',
             label=u'Mode:',
         ),
         Item('value', style='readonly'),
         Bound(
             TextField(),
             'mode := object.mode',
             'value := object.value',
             label=u'Text:',
         ),
     )
     return traits_view
Ejemplo n.º 5
0
 def default_traits_view(self):
     traits_view = View(
         Bound(
             VBoxLayout(
                 GroupBox(
                     BasicGridLayout(
                         [u'Always On:', None,
                          LineEdit()],
                         [
                             u'Enableable:',
                             CheckBox(id='field_checkbox'),
                             LineEdit(id='field')
                         ],
                         [
                             u'Left:',
                             CheckBox(id='left_checkbox'),
                             (LineEdit(id='left'), Qt.AlignLeft)
                         ],
                         [
                             u'Right:',
                             CheckBox(id='right_checkbox'),
                             (LineEdit(id='right'), Qt.AlignRight)
                         ],
                     ),
                     title=u'Basic Grid Layout',
                 ),
                 GroupBox(
                     SpanGridLayout(
                         (PushButton(text=u'(0, 0)'), 0, 0),
                         (PushButton(text=u'(0, 1) - (0, 2)'), 0, 1, 1, 2),
                         (PushButton(text=u'(1, 0) - (1, 1)'), 1, 0, 1, 2),
                         (PushButton(
                             text=u'(1, 2)\N{RIGHTWARDS ARROW TO BAR}'), 1,
                          2, Qt.AlignRight),
                         (PushButton(text=u'(2, 0)'), 2, 0),
                         (PushButton(text=u'(2, 2)'), 2, 2),
                     ),
                     title=u'Span Grid Layout',
                 ),
             ),
             'field.enabled << field_checkbox.checked',
             'left.enabled << left_checkbox.checked',
             'right.enabled << right_checkbox.checked',
         ),
         resizable=True,
         title=u'Grid Layouts',
     )
     return traits_view
Ejemplo n.º 6
0
 def default_traits_view(self):
     traits_view = View(
         Bound(
             FormLayout(
                 (u'Low:', RangeSlider(id='low', range=(0, 40))),
                 (u'High:', RangeSlider(id='high', range=(60, 100))),
                 (u'RangeEditor:', TraitsUI(Item('x'))),
                 fieldGrowthPolicy=QtGui.QFormLayout.ExpandingFieldsGrow,
             ),
             'low.value := object.low_bound',
             'high.value := object.high_bound',
             # Make the labels align nicely by fixing their widths using
             # stylesheets.
             stylesheet=(u'*[binder_class="RangeSlider"] > .QLabel '
                         u'{min-width: 30px; max-width: 30px;}'),
         ),
         resizable=True,
         title=u'Traits UI Editor',
     )
     return traits_view
Ejemplo n.º 7
0
 def default_traits_view(self):
     traits_view = View(
         Bound(
             FormLayout(
                 (u'Text:', TextField(id='field')),
                 (u'Kind:',
                  EnumDropDown(id='combo',
                               values=[
                                   (int, u'Integer'),
                                   (float, u'Float'),
                               ])),
                 (u'Value:', Label(id='value')),
                 (u'Text:', Label(id='text')),
             ),
             'field.value := object.text',
             'combo.value := object.evaluator_func',
             'field.validator << PythonEvalidator(object.evaluator_func)',
             'value.text << repr(object.value)',
             'text.text << object.text',
             extra_context=dict(PythonEvalidator=PythonEvalidator),
         ),
         resizable=True,
     )
     return traits_view
Ejemplo n.º 8
0
 def default_traits_view(self):
     traits_view = View(
         Bound(
             VBoxLayout(
                 GroupBox(
                     VBoxLayout(
                         PushButton(text=u'Push A', id='push_a'),
                         PushButton(text=u'Push B', id='push_b'),
                         PushButton(text=u'Push C', id='push_c'),
                     ),
                     title=u'Push Buttons',
                 ),
                 GroupBox(
                     VBoxLayout(
                         RadioButton(text=u'Radio A',
                                     id='radio_a',
                                     checked=True),
                         RadioButton(text=u'Radio B', id='radio_b'),
                         RadioButton(text=u'Radio C', id='radio_c'),
                     ),
                     title=u'Radio Buttons',
                 ),
                 GroupBox(
                     FormLayout(
                         (u'Clicked:', Label(id='clicked')),
                         (u'Pressed:', Label(id='pressed')),
                         (u'Released:', Label(id='released')),
                     ),
                     title=u'Events',
                 ),
             ),
             ('push_buttons.buttonClicked_QAbstractButton >> '
              'object.last_clicked_button'),
             ('push_buttons.buttonPressed_QAbstractButton >> '
              'object.last_pressed_button'),
             ('push_buttons.buttonReleased_QAbstractButton >> '
              'object.last_released_button'),
             ('radio_buttons.buttonClicked_QAbstractButton >> '
              'object.last_clicked_button'),
             ('radio_buttons.buttonPressed_QAbstractButton >> '
              'object.last_pressed_button'),
             ('radio_buttons.buttonReleased_QAbstractButton >> '
              'object.last_released_button'),
             ('clicked.text << (object.last_clicked_button).text() '
              'if object.last_clicked_button else u""'),
             ('pressed.text << (object.last_pressed_button).text() '
              'if object.last_pressed_button else u""'),
             ('released.text << (object.last_released_button).text() '
              'if object.last_released_button else u""'),
             button_groups=dict(
                 push_buttons=ButtonGroup('push_a', 'push_b', 'push_c'),
                 radio_buttons=ButtonGroup('radio_a',
                                           'radio_b',
                                           'radio_c',
                                           exclusive=True),
             ),
         ),
         resizable=True,
         width=200,
         title=u'Button Groups',
     )
     return traits_view