-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move schemas and related code out of Tasks #1076
Conversation
Schemas are generic, this PR moves the Schema code out of pyface.tasks and into pyface.action, making it available for use outside of tasks. Additionally a version of ActionManagerBuilder is included to provide a Tasks-indpendednt way of assembling the Schemas into action managers. Additionally, the code is slightly modified so that it does not import toolkit code as a side-effect. The old locations are kept so imports should still work. They will be removed at some yet-to-be-determined future point.
Note that while there is a more immediate need of this change, this opens up the possibility of using Schemas in TraitsUI instead of directly creating pyface.action objects. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just a few comments
manager = self._create_action_manager_recurse(schema, additions_map) | ||
manager.controller = self.controller | ||
return manager | ||
|
||
def create_menu_bar_manager(self): | ||
""" Create a menu bar manager from the task's menu bar schema and | ||
additions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: in create_tool_bar_managers
we go through self.task.extra_actions
instead of self.additions
. They are equivalent, but using self.additions
feels more consistent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be changed because if a subclass or other user of the class messes with how the additions
are built then we will get inconsistent results.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thought about this some more, and decided that a lot of this logic for discovering new toolbars really belonged in the base class, so I ended up creating a new get_additional_toolbar_schemas
method that takes the additions and produces new objects.
Otherwise users who wanted to have multiple toolbars would need to replicate this method's behaviour.
Return a dictionary {item_id: list_of_items}, and a list containing | ||
all the ids ordered by their appearance in the `all_items` list. The | ||
ordered IDs are used as a replacement for an ordered dictionary, to | ||
keep compatibility with Python <2.7 . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not relevant to this PR, but doing special things to keep py 2.7 compatibility could be removed / refactored at some point
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes,I noticed this and decided not to mess with it in this PR.
@@ -8,6 +8,7 @@ | |||
# | |||
# Thanks for using Enthought open source! | |||
|
|||
from contextlib import contextmanager | |||
import unittest | |||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
imports from pyface.tasks.action.api below mayb should get updated to use new pyface.actions.schema.api
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep - missed this. There are more places that the imports need to be changed (eg. examples, docs).
Co-authored-by: aaronayres35 <[email protected]>
Co-authored-by: aaronayres35 <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still LGTM, thanks for the updates!
Only thing I notice is that we still have aInstance("pyface.tasks.action.schema_addition.SchemaAddition")
in tasks_application.py
which could instead be Instance("pyface.action.schema.schema_addition.SchemaAddition")
Good catch - my search only looked for imports. Corrected, and I will merge after this. |
Schemas are generic, this PR moves the Schema code out of pyface.tasks and into pyface.action, making it available for use outside of tasks. Additionally a version of
ActionManagerBuilder
is included to provide a Tasks-independent way of assembling the Schemas into action managers, which fixes #658.Additionally, the code is slightly modified so that it does not import toolkit code as a side-effect.
The old locations are kept so imports should still work. They will be removed at some yet-to-be-determined future point.