Permalink
Browse files

Merge pull request #92 from enthought/enaml-0.8-migration

Enaml 0.8 migration
  • Loading branch information...
2 parents 8d896ff + 258519a commit 94c56d39a2a54792cdb3589e7895e1c4d6681455 Pietro Berkes committed Nov 25, 2013
View
@@ -0,0 +1,5 @@
+unittest2
+https://github.com/nucleic/enaml/archive/0.8.8.tar.gz#egg=enaml
+-e git+http://github.com/enthought/traits.git#egg=traits
+-e git+http://github.com/enthought/traitsui.git#egg=traitsui
+-e git+http://github.com/enthought/traits_enaml.git#egg=traits_enaml
@@ -1,5 +1,5 @@
#------------------------------------------------------------------------------
-# Copyright (c) 2011, Enthought, Inc.
+# Copyright (c) 2013, Enthought, Inc.
# All rights reserved.
#------------------------------------------------------------------------------
import datetime
@@ -1,8 +1,10 @@
#------------------------------------------------------------------------------
-# Copyright (c) 2011, Enthought, Inc.
+# Copyright (c) 2013, Enthought, Inc.
# All rights reserved.
#------------------------------------------------------------------------------
-from phone_converter import PhoneNumberConverter
+from enaml.layout.api import align, vbox
+from enaml.widgets.api import CheckBox, Container, DateSelector, Field, Form, \
+ GroupBox, Label
enamldef EmployeeForm(Form):
@@ -11,20 +13,14 @@ enamldef EmployeeForm(Form):
Label:
text = "First name:"
Field:
- value := employee.first_name
+ text := employee.first_name
Label:
text = "Last name:"
Field:
- value := employee.last_name
- Label:
- text = "Home phone:"
- Field:
- value := employee.phone
- converter = PhoneNumberConverter()
- bgcolor << 'error' if error else 'none'
+ text := employee.last_name
Label:
text = 'Date of Birth:'
- DateEdit:
+ DateSelector:
date := employee.dob
Label:
text = 'Age:'
@@ -33,15 +29,14 @@ enamldef EmployeeForm(Form):
Label:
text = 'Password'
Field:
- password_mode << 'password' if not pw_cb.checked else 'normal'
- value :: print 'Password:', value
+ echo_mode << 'password' if not pw_cb.checked else 'normal'
+ text :: print 'Password:', text
Label:
text = 'Show Password:'
- CheckBox:
- id: pw_cb
+ CheckBox: pw_cb:
checked = False
Label:
- text = 'Show Employer Details:'
+ text = 'Edit Employer Details:'
CheckBox:
checked := show_employer
@@ -51,43 +46,30 @@ enamldef EmployerForm(Form):
Label:
text = "Company:"
Field:
- value << employer.company_name
- enabled << en_cb.checked
+ text << employer.company_name
Label:
text = "Reporting Manager:"
Field:
- value << "%s %s" % (employer.first_name, employer.last_name)
- enabled << en_cb.checked
- Label:
- text = "Allow Editing:"
- CheckBox:
- id: en_cb
- checked = True
+ text << "%s %s" % (employer.first_name, employer.last_name)
-enamldef EmployeeView(Container):
- id: main
+enamldef EmployeeView(Container): main:
attr employee
constraints = [
vbox(top_box, bottom_box),
align('midline', top_form, bottom_form),
]
- GroupBox:
- id: top_box
+ GroupBox: top_box:
title = "Personal Details"
- EmployeeForm:
- id: top_form
+ EmployeeForm: top_form:
# We access the employee object through the identifier
# 'main' here, because the EmployeeForm also has an
# 'employee' attribute declared, and that would be
# found first.
employee = main.employee
- GroupBox:
- id: bottom_box
+ GroupBox: bottom_box:
title = "Employer Details"
- visible << top_form.show_employer
- EmployerForm:
- id: bottom_form
+ EmployerForm: bottom_form:
+ enabled << top_form.show_employer
employer << employee.boss
-
@@ -1,10 +1,10 @@
#------------------------------------------------------------------------------
-# Copyright (c) 2011, Enthought, Inc.
+# Copyright (c) 2013, Enthought, Inc.
# All rights reserved.
#------------------------------------------------------------------------------
+from enaml.widgets.api import Field, Form, Label
-
-enamldef DockPane(Form):
+enamldef EmptyForm(Form):
Label:
text = "First name:"
Field:
@@ -1,29 +1,21 @@
+#------------------------------------------------------------------------------
+# Copyright (c) 2013, Enthought, Inc.
+# All rights reserved.
+#------------------------------------------------------------------------------
+
# Enthought library imports.
-from pyface.tasks.enaml_dock_pane import EnamlDockPane
-from pyface.tasks.enaml_task_pane import EnamlTaskPane
+from pyface.tasks.api import EnamlDockPane, EnamlTaskPane
+import traits_enaml
-import enaml
class DummyDockPane(EnamlDockPane):
id = 'example.dummy_dock_pane'
name = 'Dummy Dock'
-
- def create_component(self):
- with enaml.imports():
- from dock_pane import DockPane
- view = DockPane()
- return view
def create_component(self):
- with enaml.imports():
- from employee_view import EmployeeView
- from employee import Employer, Employee
-
- boss_john = Employer(first_name='John', last_name='Paw', company_name="Packrat's Cats")
- employee_mary = Employee(first_name='Mary', last_name='Sue', boss=boss_john)
-
- view = EmployeeView(employee=employee_mary)
- return view
+ with traits_enaml.imports():
+ from empty_form import EmptyForm
+ return EmptyForm()
class DummyTaskPane(EnamlTaskPane):
@@ -38,19 +30,14 @@ class DummyTaskPane(EnamlTaskPane):
###########################################################################
def create_component(self):
- with enaml.imports():
+ with traits_enaml.imports():
from employee_view import EmployeeView
from employee import Employer, Employee
- boss_john = Employer(first_name='John', last_name='Paw', company_name="Packrat's Cats")
- employee_mary = Employee(first_name='Mary', last_name='Sue', boss=boss_john)
+ boss_john = Employer(first_name='John', last_name='Paw',
+ company_name="Packrat's Cats")
+ employee_mary = Employee(first_name='Mary', last_name='Sue',
+ boss=boss_john)
view = EmployeeView(employee=employee_mary)
return view
-
-
- def create_component(self):
- with enaml.imports():
- from dock_pane import DockPane
- view = DockPane()
- return view
@@ -1,3 +1,8 @@
+#------------------------------------------------------------------------------
+# Copyright (c) 2013, Enthought, Inc.
+# All rights reserved.
+#------------------------------------------------------------------------------
+
# Enthought library imports.
from pyface.tasks.api import Task, TaskLayout, PaneItem
@@ -6,7 +11,7 @@
class EnamlTask(Task):
- """ A simple task for demonstraiting the use of Enaml in Tasks.
+ """ A simple task for demonstrating the use of Enaml in Tasks.
"""
#### Task interface #######################################################
@@ -1,40 +0,0 @@
-#------------------------------------------------------------------------------
-# Copyright (c) 2011, Enthought, Inc.
-# All rights reserved.
-#------------------------------------------------------------------------------
-import re
-
-from enaml.converters import Converter
-
-
-class PhoneNumberConverter(Converter):
- """ A really dumb phone number converter.
-
- """
- all_digits = re.compile(r'[0-9]{10}$')
-
- dashes = re.compile(r'([0-9]{3})\-([0-9]{3})\-([0-9]{4})$')
-
- proper = re.compile(r'\(([0-9]{3})\)\ ([0-9]{3})\-([0-9]{4})$')
-
- def to_component(self, value):
- area, prefix, suffix = value
- return '(%s) %s-%s' % (area, prefix, suffix)
-
- def from_component(self, value):
- match = self.proper.match(value)
- if not match:
- match = self.dashes.match(value)
- if match:
- area = match.group(1)
- prefix = match.group(2)
- suffix = match.group(3)
- return (int(area), int(prefix), int(suffix))
- match = self.all_digits.match(value)
- if match:
- area = value[:3]
- prefix = value[3:6]
- suffix = value[6:10]
- return (int(area), int(prefix), int(suffix))
- raise ValueError('Unable to convert to valid phone number')
-
@@ -1,3 +1,8 @@
+#------------------------------------------------------------------------------
+# Copyright (c) 2013, Enthought, Inc.
+# All rights reserved.
+#------------------------------------------------------------------------------
+
# Enthought library imports.
from pyface.api import GUI
from pyface.tasks.api import TaskWindow
@@ -10,6 +15,12 @@ def main(argv):
""" A simple example of using Tasks.
"""
# Create the GUI (this does NOT start the GUI event loop).
+ from traits.etsconfig.api import ETSConfig
+ ETSConfig.toolkit = 'qt4'
+
+ from enaml.qt.qt_application import QtApplication
+ app = QtApplication()
+
gui = GUI()
# Create a Task and add it to a TaskWindow.
View
@@ -1,19 +1,22 @@
# Local imports.
-from advanced_editor_area_pane import AdvancedEditorAreaPane
-from split_editor_area_pane import SplitEditorAreaPane
-from dock_pane import DockPane
-from editor import Editor
-from editor_area_pane import EditorAreaPane
-from i_dock_pane import IDockPane
-from i_editor import IEditor
-from i_editor_area_pane import IEditorAreaPane
-from i_task_pane import ITaskPane
-from task import Task
-from task_layout import TaskLayout, PaneItem, Tabbed, Splitter, HSplitter, \
+from .advanced_editor_area_pane import AdvancedEditorAreaPane
+from .split_editor_area_pane import SplitEditorAreaPane
+from .dock_pane import DockPane
+from .editor import Editor
+from .editor_area_pane import EditorAreaPane
+from .enaml_dock_pane import EnamlDockPane
+from .enaml_editor import EnamlEditor
+from .enaml_task_pane import EnamlTaskPane
+from .i_dock_pane import IDockPane
+from .i_editor import IEditor
+from .i_editor_area_pane import IEditorAreaPane
+from .i_task_pane import ITaskPane
+from .task import Task
+from .task_layout import TaskLayout, PaneItem, Tabbed, Splitter, HSplitter, \
VSplitter
-from task_pane import TaskPane
-from task_window import TaskWindow
-from task_window_layout import TaskWindowLayout
-from traits_dock_pane import TraitsDockPane
-from traits_editor import TraitsEditor
-from traits_task_pane import TraitsTaskPane
+from .task_pane import TaskPane
+from .task_window import TaskWindow
+from .task_window_layout import TaskWindowLayout
+from .traits_dock_pane import TraitsDockPane
+from .traits_editor import TraitsEditor
+from .traits_task_pane import TraitsTaskPane
Oops, something went wrong.

0 comments on commit 94c56d3

Please sign in to comment.