Skip to content

Create a new UI toolkit for kmb (do not alter enaml's toolkit) #2

@matthewryanscott

Description

@matthewryanscott

kmb.components currently alters the base enaml toolkit.

Add a function to create a kmb-specific toolkit instead, and use that in kmb.scripts.browser and in enaml files.

From @sccolbert via enthought-dev list:

enaml-run looks for one of two things when running an .enaml file:


   1. An enamldef specified by the --component flag. This defaults to
   "Main". Said component is instantiated with 0 arguments followed by a call
   to .show()
   2. If no component is found in step #1, the module is searched for a
   symbol named "main". If found, it is expected to be a callable which takes
   0 arguments and does whatever you want.


Given #2, you can do things like this:

enamldef Whatever(Window):
    ...

def main():
   <assemble my_toolkit>
   with my_toolkit:
       view = Whatever()
   view.show()

This method will allow you to assemble whatever toolkit you want as a
custom thing. We generally consider it bad-form to modify the default
toolkits. The whole purpose behind making toolkits simply dict subclasses
with context methods, was that its easy to create and customize them. In
your case, enaml-run doesn't know anything about custom toolkits, so you
would have to use the approach of #2 to get the behavior you desire.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions