repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
tophatmonocle/ims_lti_py
ims_lti_py/tool_config.py
ToolConfig.get_ext_param
def get_ext_param(self, ext_key, param_key): ''' Get specific param in set of provided extension parameters. ''' return self.extensions[ext_key][param_key] if self.extensions[ext_key]\ else None
python
def get_ext_param(self, ext_key, param_key): ''' Get specific param in set of provided extension parameters. ''' return self.extensions[ext_key][param_key] if self.extensions[ext_key]\ else None
[ "def", "get_ext_param", "(", "self", ",", "ext_key", ",", "param_key", ")", ":", "return", "self", ".", "extensions", "[", "ext_key", "]", "[", "param_key", "]", "if", "self", ".", "extensions", "[", "ext_key", "]", "else", "None" ]
Get specific param in set of provided extension parameters.
[ "Get", "specific", "param", "in", "set", "of", "provided", "extension", "parameters", "." ]
train
https://github.com/tophatmonocle/ims_lti_py/blob/979244d83c2e6420d2c1941f58e52f641c56ad12/ims_lti_py/tool_config.py#L98-L103
tophatmonocle/ims_lti_py
ims_lti_py/tool_config.py
ToolConfig.process_xml
def process_xml(self, xml): ''' Parse tool configuration data out of the Common Cartridge LTI link XML. ''' root = objectify.fromstring(xml, parser = etree.XMLParser()) # Parse all children of the root node for child in root.getchildren(): if 'title' in child....
python
def process_xml(self, xml): ''' Parse tool configuration data out of the Common Cartridge LTI link XML. ''' root = objectify.fromstring(xml, parser = etree.XMLParser()) # Parse all children of the root node for child in root.getchildren(): if 'title' in child....
[ "def", "process_xml", "(", "self", ",", "xml", ")", ":", "root", "=", "objectify", ".", "fromstring", "(", "xml", ",", "parser", "=", "etree", ".", "XMLParser", "(", ")", ")", "# Parse all children of the root node", "for", "child", "in", "root", ".", "get...
Parse tool configuration data out of the Common Cartridge LTI link XML.
[ "Parse", "tool", "configuration", "data", "out", "of", "the", "Common", "Cartridge", "LTI", "link", "XML", "." ]
train
https://github.com/tophatmonocle/ims_lti_py/blob/979244d83c2e6420d2c1941f58e52f641c56ad12/ims_lti_py/tool_config.py#L105-L170
tophatmonocle/ims_lti_py
ims_lti_py/tool_config.py
ToolConfig.to_xml
def to_xml(self, opts = defaultdict(lambda: None)): ''' Generate XML from the current settings. ''' if not self.launch_url or not self.secure_launch_url: raise InvalidLTIConfigError('Invalid LTI configuration') root = etree.Element('cartridge_basiclti_link', attrib ...
python
def to_xml(self, opts = defaultdict(lambda: None)): ''' Generate XML from the current settings. ''' if not self.launch_url or not self.secure_launch_url: raise InvalidLTIConfigError('Invalid LTI configuration') root = etree.Element('cartridge_basiclti_link', attrib ...
[ "def", "to_xml", "(", "self", ",", "opts", "=", "defaultdict", "(", "lambda", ":", "None", ")", ")", ":", "if", "not", "self", ".", "launch_url", "or", "not", "self", ".", "secure_launch_url", ":", "raise", "InvalidLTIConfigError", "(", "'Invalid LTI configu...
Generate XML from the current settings.
[ "Generate", "XML", "from", "the", "current", "settings", "." ]
train
https://github.com/tophatmonocle/ims_lti_py/blob/979244d83c2e6420d2c1941f58e52f641c56ad12/ims_lti_py/tool_config.py#L185-L247
codelv/enaml-native
src/enamlnative/android/android_scroll_view.py
AndroidScrollView.create_widget
def create_widget(self): """ Create the underlying widget. """ d = self.declaration if d.orientation == 'vertical': self.widget = ScrollView(self.get_context(), None, d.style) else: self.widget = HorizontalScrollView(self.get_context(), ...
python
def create_widget(self): """ Create the underlying widget. """ d = self.declaration if d.orientation == 'vertical': self.widget = ScrollView(self.get_context(), None, d.style) else: self.widget = HorizontalScrollView(self.get_context(), ...
[ "def", "create_widget", "(", "self", ")", ":", "d", "=", "self", ".", "declaration", "if", "d", ".", "orientation", "==", "'vertical'", ":", "self", ".", "widget", "=", "ScrollView", "(", "self", ".", "get_context", "(", ")", ",", "None", ",", "d", "...
Create the underlying widget.
[ "Create", "the", "underlying", "widget", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_scroll_view.py#L47-L56
codelv/enaml-native
src/enamlnative/android/android_calendar_view.py
AndroidCalendarView.create_widget
def create_widget(self): """ Create the underlying widget. """ d = self.declaration self.widget = CalendarView(self.get_context(), None, d.style or "@attr/calendarViewStyle")
python
def create_widget(self): """ Create the underlying widget. """ d = self.declaration self.widget = CalendarView(self.get_context(), None, d.style or "@attr/calendarViewStyle")
[ "def", "create_widget", "(", "self", ")", ":", "d", "=", "self", ".", "declaration", "self", ".", "widget", "=", "CalendarView", "(", "self", ".", "get_context", "(", ")", ",", "None", ",", "d", ".", "style", "or", "\"@attr/calendarViewStyle\"", ")" ]
Create the underlying widget.
[ "Create", "the", "underlying", "widget", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_calendar_view.py#L47-L53
codelv/enaml-native
src/enamlnative/android/android_calendar_view.py
AndroidCalendarView.init_widget
def init_widget(self): """ Initialize the underlying widget. """ super(AndroidCalendarView, self).init_widget() #: Setup listener w = self.widget w.setOnDateChangeListener(w.getId()) w.onSelectedDayChange.connect(self.on_selected_day_change)
python
def init_widget(self): """ Initialize the underlying widget. """ super(AndroidCalendarView, self).init_widget() #: Setup listener w = self.widget w.setOnDateChangeListener(w.getId()) w.onSelectedDayChange.connect(self.on_selected_day_change)
[ "def", "init_widget", "(", "self", ")", ":", "super", "(", "AndroidCalendarView", ",", "self", ")", ".", "init_widget", "(", ")", "#: Setup listener", "w", "=", "self", ".", "widget", "w", ".", "setOnDateChangeListener", "(", "w", ".", "getId", "(", ")", ...
Initialize the underlying widget.
[ "Initialize", "the", "underlying", "widget", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_calendar_view.py#L55-L64
codelv/enaml-native
src/enamlnative/android/android_fragment.py
AndroidFragment.init_widget
def init_widget(self): """ Initialize the underlying widget. """ super(AndroidFragment, self).init_widget() f = self.fragment f.setFragmentListener(f.getId()) f.onCreateView.connect(self.on_create_view) f.onDestroyView.connect(self.on_destroy_view)
python
def init_widget(self): """ Initialize the underlying widget. """ super(AndroidFragment, self).init_widget() f = self.fragment f.setFragmentListener(f.getId()) f.onCreateView.connect(self.on_create_view) f.onDestroyView.connect(self.on_destroy_view)
[ "def", "init_widget", "(", "self", ")", ":", "super", "(", "AndroidFragment", ",", "self", ")", ".", "init_widget", "(", ")", "f", "=", "self", ".", "fragment", "f", ".", "setFragmentListener", "(", "f", ".", "getId", "(", ")", ")", "f", ".", "onCrea...
Initialize the underlying widget.
[ "Initialize", "the", "underlying", "widget", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_fragment.py#L73-L81
codelv/enaml-native
src/enamlnative/android/android_fragment.py
AndroidFragment.init_layout
def init_layout(self): """ Initialize the layout of the toolkit widget. This method is called during the bottom-up pass. This method should initialize the layout of the widget. The child widgets will be fully initialized and layed out when this is called. """ parent = s...
python
def init_layout(self): """ Initialize the layout of the toolkit widget. This method is called during the bottom-up pass. This method should initialize the layout of the widget. The child widgets will be fully initialized and layed out when this is called. """ parent = s...
[ "def", "init_layout", "(", "self", ")", ":", "parent", "=", "self", ".", "parent", "(", ")", "if", "parent", "is", "not", "None", ":", "self", ".", "adapter", "=", "parent", ".", "adapter", "self", ".", "adapter", ".", "addFragment", "(", "self", "."...
Initialize the layout of the toolkit widget. This method is called during the bottom-up pass. This method should initialize the layout of the widget. The child widgets will be fully initialized and layed out when this is called.
[ "Initialize", "the", "layout", "of", "the", "toolkit", "widget", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_fragment.py#L83-L94
codelv/enaml-native
src/enamlnative/android/android_fragment.py
AndroidFragment.destroy
def destroy(self): """ Custom destructor that deletes the fragment and removes itself from the adapter it was added to. """ #: Destroy fragment fragment = self.fragment if fragment: #: Stop listening fragment.setFragmentListener(None) ...
python
def destroy(self): """ Custom destructor that deletes the fragment and removes itself from the adapter it was added to. """ #: Destroy fragment fragment = self.fragment if fragment: #: Stop listening fragment.setFragmentListener(None) ...
[ "def", "destroy", "(", "self", ")", ":", "#: Destroy fragment", "fragment", "=", "self", ".", "fragment", "if", "fragment", ":", "#: Stop listening", "fragment", ".", "setFragmentListener", "(", "None", ")", "#: Cleanup from fragment", "if", "self", ".", "adapter"...
Custom destructor that deletes the fragment and removes itself from the adapter it was added to.
[ "Custom", "destructor", "that", "deletes", "the", "fragment", "and", "removes", "itself", "from", "the", "adapter", "it", "was", "added", "to", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_fragment.py#L96-L112
codelv/enaml-native
src/enamlnative/android/android_fragment.py
AndroidFragment.on_create_view
def on_create_view(self): """ Trigger the click """ d = self.declaration changed = not d.condition if changed: d.condition = True view = self.get_view() if changed: self.ready.set_result(True) return view
python
def on_create_view(self): """ Trigger the click """ d = self.declaration changed = not d.condition if changed: d.condition = True view = self.get_view() if changed: self.ready.set_result(True) return view
[ "def", "on_create_view", "(", "self", ")", ":", "d", "=", "self", ".", "declaration", "changed", "=", "not", "d", ".", "condition", "if", "changed", ":", "d", ".", "condition", "=", "True", "view", "=", "self", ".", "get_view", "(", ")", "if", "chang...
Trigger the click
[ "Trigger", "the", "click" ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_fragment.py#L117-L131
codelv/enaml-native
src/enamlnative/android/android_fragment.py
AndroidFragment.get_view
def get_view(self): """ Get the page to display. If a view has already been created and is cached, use that otherwise initialize the view and proxy. If defer loading is used, wrap the view in a FrameLayout and defer add view until later. """ d = self.declaratio...
python
def get_view(self): """ Get the page to display. If a view has already been created and is cached, use that otherwise initialize the view and proxy. If defer loading is used, wrap the view in a FrameLayout and defer add view until later. """ d = self.declaratio...
[ "def", "get_view", "(", "self", ")", ":", "d", "=", "self", ".", "declaration", "if", "d", ".", "cached", "and", "self", ".", "widget", ":", "return", "self", ".", "widget", "if", "d", ".", "defer_loading", ":", "self", ".", "widget", "=", "FrameLayo...
Get the page to display. If a view has already been created and is cached, use that otherwise initialize the view and proxy. If defer loading is used, wrap the view in a FrameLayout and defer add view until later.
[ "Get", "the", "page", "to", "display", ".", "If", "a", "view", "has", "already", "been", "created", "and", "is", "cached", "use", "that", "otherwise", "initialize", "the", "view", "and", "proxy", ".", "If", "defer", "loading", "is", "used", "wrap", "the"...
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_fragment.py#L150-L167
codelv/enaml-native
src/enamlnative/android/android_fragment.py
AndroidPagerFragment.init_widget
def init_widget(self): """ Initialize the underlying widget. """ super(AndroidPagerFragment, self).init_widget() d = self.declaration if d.title: self.set_title(d.title) if d.icon: self.set_icon(d.icon)
python
def init_widget(self): """ Initialize the underlying widget. """ super(AndroidPagerFragment, self).init_widget() d = self.declaration if d.title: self.set_title(d.title) if d.icon: self.set_icon(d.icon)
[ "def", "init_widget", "(", "self", ")", ":", "super", "(", "AndroidPagerFragment", ",", "self", ")", ".", "init_widget", "(", ")", "d", "=", "self", ".", "declaration", "if", "d", ".", "title", ":", "self", ".", "set_title", "(", "d", ".", "title", "...
Initialize the underlying widget.
[ "Initialize", "the", "underlying", "widget", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_fragment.py#L189-L198
codelv/enaml-native
src/enamlnative/core/eventloop/gen.py
engine
def engine(func): """Callback-oriented decorator for asynchronous generators. This is an older interface; for new code that does not need to be compatible with versions of Tornado older than 3.0 the `coroutine` decorator is recommended instead. This decorator is similar to `coroutine`, except it d...
python
def engine(func): """Callback-oriented decorator for asynchronous generators. This is an older interface; for new code that does not need to be compatible with versions of Tornado older than 3.0 the `coroutine` decorator is recommended instead. This decorator is similar to `coroutine`, except it d...
[ "def", "engine", "(", "func", ")", ":", "func", "=", "_make_coroutine_wrapper", "(", "func", ",", "replace_callback", "=", "False", ")", "@", "functools", ".", "wraps", "(", "func", ")", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")",...
Callback-oriented decorator for asynchronous generators. This is an older interface; for new code that does not need to be compatible with versions of Tornado older than 3.0 the `coroutine` decorator is recommended instead. This decorator is similar to `coroutine`, except it does not return a `.Fu...
[ "Callback", "-", "oriented", "decorator", "for", "asynchronous", "generators", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/eventloop/gen.py#L174-L206
codelv/enaml-native
src/enamlnative/core/eventloop/gen.py
_make_coroutine_wrapper
def _make_coroutine_wrapper(func, replace_callback): """The inner workings of ``@gen.coroutine`` and ``@gen.engine``. The two decorators differ in their treatment of the ``callback`` argument, so we cannot simply implement ``@engine`` in terms of ``@coroutine``. """ # On Python 3.5, set the cor...
python
def _make_coroutine_wrapper(func, replace_callback): """The inner workings of ``@gen.coroutine`` and ``@gen.engine``. The two decorators differ in their treatment of the ``callback`` argument, so we cannot simply implement ``@engine`` in terms of ``@coroutine``. """ # On Python 3.5, set the cor...
[ "def", "_make_coroutine_wrapper", "(", "func", ",", "replace_callback", ")", ":", "# On Python 3.5, set the coroutine flag on our generator, to allow it", "# to be used with 'await'.", "wrapped", "=", "func", "if", "hasattr", "(", "types", ",", "'coroutine'", ")", ":", "fun...
The inner workings of ``@gen.coroutine`` and ``@gen.engine``. The two decorators differ in their treatment of the ``callback`` argument, so we cannot simply implement ``@engine`` in terms of ``@coroutine``.
[ "The", "inner", "workings", "of", "@gen", ".", "coroutine", "and", "@gen", ".", "engine", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/eventloop/gen.py#L267-L336
codelv/enaml-native
src/enamlnative/core/eventloop/gen.py
Task
def Task(func, *args, **kwargs): """Adapts a callback-based asynchronous function for use in coroutines. Takes a function (and optional additional arguments) and runs it with those arguments plus a ``callback`` keyword argument. The argument passed to the callback is returned as the result of the yiel...
python
def Task(func, *args, **kwargs): """Adapts a callback-based asynchronous function for use in coroutines. Takes a function (and optional additional arguments) and runs it with those arguments plus a ``callback`` keyword argument. The argument passed to the callback is returned as the result of the yiel...
[ "def", "Task", "(", "func", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "future", "=", "Future", "(", ")", "def", "handle_exception", "(", "typ", ",", "value", ",", "tb", ")", ":", "if", "future", ".", "done", "(", ")", ":", "return", ...
Adapts a callback-based asynchronous function for use in coroutines. Takes a function (and optional additional arguments) and runs it with those arguments plus a ``callback`` keyword argument. The argument passed to the callback is returned as the result of the yield expression. .. versionchanged:: 4...
[ "Adapts", "a", "callback", "-", "based", "asynchronous", "function", "for", "use", "in", "coroutines", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/eventloop/gen.py#L608-L634
codelv/enaml-native
src/enamlnative/core/eventloop/gen.py
_contains_yieldpoint
def _contains_yieldpoint(children): """Returns True if ``children`` contains any YieldPoints. ``children`` may be a dict or a list, as used by `MultiYieldPoint` and `multi_future`. """ if isinstance(children, dict): return any(isinstance(i, YieldPoint) for i in children.values()) if isi...
python
def _contains_yieldpoint(children): """Returns True if ``children`` contains any YieldPoints. ``children`` may be a dict or a list, as used by `MultiYieldPoint` and `multi_future`. """ if isinstance(children, dict): return any(isinstance(i, YieldPoint) for i in children.values()) if isi...
[ "def", "_contains_yieldpoint", "(", "children", ")", ":", "if", "isinstance", "(", "children", ",", "dict", ")", ":", "return", "any", "(", "isinstance", "(", "i", ",", "YieldPoint", ")", "for", "i", "in", "children", ".", "values", "(", ")", ")", "if"...
Returns True if ``children`` contains any YieldPoints. ``children`` may be a dict or a list, as used by `MultiYieldPoint` and `multi_future`.
[ "Returns", "True", "if", "children", "contains", "any", "YieldPoints", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/eventloop/gen.py#L678-L688
codelv/enaml-native
src/enamlnative/core/eventloop/gen.py
multi
def multi(children, quiet_exceptions=()): """Runs multiple asynchronous operations in parallel. ``children`` may either be a list or a dict whose values are yieldable objects. ``multi()`` returns a new yieldable object that resolves to a parallel structure containing their results. If ``children`` ...
python
def multi(children, quiet_exceptions=()): """Runs multiple asynchronous operations in parallel. ``children`` may either be a list or a dict whose values are yieldable objects. ``multi()`` returns a new yieldable object that resolves to a parallel structure containing their results. If ``children`` ...
[ "def", "multi", "(", "children", ",", "quiet_exceptions", "=", "(", ")", ")", ":", "if", "_contains_yieldpoint", "(", "children", ")", ":", "return", "MultiYieldPoint", "(", "children", ",", "quiet_exceptions", "=", "quiet_exceptions", ")", "else", ":", "retur...
Runs multiple asynchronous operations in parallel. ``children`` may either be a list or a dict whose values are yieldable objects. ``multi()`` returns a new yieldable object that resolves to a parallel structure containing their results. If ``children`` is a list, the result is a list of results in...
[ "Runs", "multiple", "asynchronous", "operations", "in", "parallel", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/eventloop/gen.py#L691-L740
codelv/enaml-native
src/enamlnative/core/eventloop/gen.py
multi_future
def multi_future(children, quiet_exceptions=()): """Wait for multiple asynchronous futures in parallel. This function is similar to `multi`, but does not support `YieldPoints <YieldPoint>`. .. versionadded:: 4.0 .. versionchanged:: 4.2 If multiple ``Futures`` fail, any exceptions after the...
python
def multi_future(children, quiet_exceptions=()): """Wait for multiple asynchronous futures in parallel. This function is similar to `multi`, but does not support `YieldPoints <YieldPoint>`. .. versionadded:: 4.0 .. versionchanged:: 4.2 If multiple ``Futures`` fail, any exceptions after the...
[ "def", "multi_future", "(", "children", ",", "quiet_exceptions", "=", "(", ")", ")", ":", "if", "isinstance", "(", "children", ",", "dict", ")", ":", "keys", "=", "list", "(", "children", ".", "keys", "(", ")", ")", "children", "=", "children", ".", ...
Wait for multiple asynchronous futures in parallel. This function is similar to `multi`, but does not support `YieldPoints <YieldPoint>`. .. versionadded:: 4.0 .. versionchanged:: 4.2 If multiple ``Futures`` fail, any exceptions after the first (which is raised) will be logged. Added th...
[ "Wait", "for", "multiple", "asynchronous", "futures", "in", "parallel", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/eventloop/gen.py#L818-L872
codelv/enaml-native
src/enamlnative/core/eventloop/gen.py
maybe_future
def maybe_future(x): """Converts ``x`` into a `.Future`. If ``x`` is already a `.Future`, it is simply returned; otherwise it is wrapped in a new `.Future`. This is suitable for use as ``result = yield gen.maybe_future(f())`` when you don't know whether ``f()`` returns a `.Future` or not. .. ...
python
def maybe_future(x): """Converts ``x`` into a `.Future`. If ``x`` is already a `.Future`, it is simply returned; otherwise it is wrapped in a new `.Future`. This is suitable for use as ``result = yield gen.maybe_future(f())`` when you don't know whether ``f()`` returns a `.Future` or not. .. ...
[ "def", "maybe_future", "(", "x", ")", ":", "if", "is_future", "(", "x", ")", ":", "return", "x", "else", ":", "fut", "=", "Future", "(", ")", "fut", ".", "set_result", "(", "x", ")", "return", "fut" ]
Converts ``x`` into a `.Future`. If ``x`` is already a `.Future`, it is simply returned; otherwise it is wrapped in a new `.Future`. This is suitable for use as ``result = yield gen.maybe_future(f())`` when you don't know whether ``f()`` returns a `.Future` or not. .. deprecated:: 4.3 This...
[ "Converts", "x", "into", "a", ".", "Future", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/eventloop/gen.py#L875-L893
codelv/enaml-native
src/enamlnative/core/eventloop/gen.py
with_timeout
def with_timeout(timeout, future, quiet_exceptions=()): """Wraps a `.Future` (or other yieldable object) in a timeout. Raises `tornado.util.TimeoutError` if the input future does not complete before ``timeout``, which may be specified in any form allowed by `.IOLoop.add_timeout` (i.e. a `datetime.timed...
python
def with_timeout(timeout, future, quiet_exceptions=()): """Wraps a `.Future` (or other yieldable object) in a timeout. Raises `tornado.util.TimeoutError` if the input future does not complete before ``timeout``, which may be specified in any form allowed by `.IOLoop.add_timeout` (i.e. a `datetime.timed...
[ "def", "with_timeout", "(", "timeout", ",", "future", ",", "quiet_exceptions", "=", "(", ")", ")", ":", "# TODO: allow YieldPoints in addition to other yieldables?", "# Tricky to do with stack_context semantics.", "#", "# It's tempting to optimize this by cancelling the input future ...
Wraps a `.Future` (or other yieldable object) in a timeout. Raises `tornado.util.TimeoutError` if the input future does not complete before ``timeout``, which may be specified in any form allowed by `.IOLoop.add_timeout` (i.e. a `datetime.timedelta` or an absolute time relative to `.IOLoop.time`) ...
[ "Wraps", "a", ".", "Future", "(", "or", "other", "yieldable", "object", ")", "in", "a", "timeout", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/eventloop/gen.py#L896-L957
codelv/enaml-native
src/enamlnative/core/eventloop/gen.py
sleep
def sleep(duration): """Return a `.Future` that resolves after the given number of seconds. When used with ``yield`` in a coroutine, this is a non-blocking analogue to `time.sleep` (which should not be used in coroutines because it is blocking):: yield gen.sleep(0.5) Note that calling thi...
python
def sleep(duration): """Return a `.Future` that resolves after the given number of seconds. When used with ``yield`` in a coroutine, this is a non-blocking analogue to `time.sleep` (which should not be used in coroutines because it is blocking):: yield gen.sleep(0.5) Note that calling thi...
[ "def", "sleep", "(", "duration", ")", ":", "f", "=", "Future", "(", ")", "IOLoop", ".", "current", "(", ")", ".", "call_later", "(", "duration", ",", "lambda", ":", "f", ".", "set_result", "(", "None", ")", ")", "return", "f" ]
Return a `.Future` that resolves after the given number of seconds. When used with ``yield`` in a coroutine, this is a non-blocking analogue to `time.sleep` (which should not be used in coroutines because it is blocking):: yield gen.sleep(0.5) Note that calling this function on its own does n...
[ "Return", "a", ".", "Future", "that", "resolves", "after", "the", "given", "number", "of", "seconds", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/eventloop/gen.py#L960-L976
codelv/enaml-native
src/enamlnative/core/eventloop/gen.py
_argument_adapter
def _argument_adapter(callback): """Returns a function that when invoked runs ``callback`` with one arg. If the function returned by this function is called with exactly one argument, that argument is passed to ``callback``. Otherwise the args tuple and kwargs dict are wrapped in an `Arguments` object...
python
def _argument_adapter(callback): """Returns a function that when invoked runs ``callback`` with one arg. If the function returned by this function is called with exactly one argument, that argument is passed to ``callback``. Otherwise the args tuple and kwargs dict are wrapped in an `Arguments` object...
[ "def", "_argument_adapter", "(", "callback", ")", ":", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "kwargs", "or", "len", "(", "args", ")", ">", "1", ":", "callback", "(", "Arguments", "(", "args", ",", "kwargs", ")...
Returns a function that when invoked runs ``callback`` with one arg. If the function returned by this function is called with exactly one argument, that argument is passed to ``callback``. Otherwise the args tuple and kwargs dict are wrapped in an `Arguments` object.
[ "Returns", "a", "function", "that", "when", "invoked", "runs", "callback", "with", "one", "arg", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/eventloop/gen.py#L1222-L1236
codelv/enaml-native
src/enamlnative/core/eventloop/gen.py
convert_yielded
def convert_yielded(yielded): """Convert a yielded object into a `.Future`. The default implementation accepts lists, dictionaries, and Futures. If the `~functools.singledispatch` library is available, this function may be extended to support additional types. For example:: @convert_yielded.r...
python
def convert_yielded(yielded): """Convert a yielded object into a `.Future`. The default implementation accepts lists, dictionaries, and Futures. If the `~functools.singledispatch` library is available, this function may be extended to support additional types. For example:: @convert_yielded.r...
[ "def", "convert_yielded", "(", "yielded", ")", ":", "# Lists and dicts containing YieldPoints were handled earlier.", "if", "yielded", "is", "None", ":", "return", "moment", "elif", "isinstance", "(", "yielded", ",", "(", "list", ",", "dict", ")", ")", ":", "retur...
Convert a yielded object into a `.Future`. The default implementation accepts lists, dictionaries, and Futures. If the `~functools.singledispatch` library is available, this function may be extended to support additional types. For example:: @convert_yielded.register(asyncio.Future) def _...
[ "Convert", "a", "yielded", "object", "into", "a", ".", "Future", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/eventloop/gen.py#L1301-L1325
codelv/enaml-native
src/enamlnative/core/eventloop/gen.py
WaitIterator.done
def done(self): """Returns True if this iterator has no more results.""" if self._finished or self._unfinished: return False # Clear the 'current' values when iteration is done. self.current_index = self.current_future = None return True
python
def done(self): """Returns True if this iterator has no more results.""" if self._finished or self._unfinished: return False # Clear the 'current' values when iteration is done. self.current_index = self.current_future = None return True
[ "def", "done", "(", "self", ")", ":", "if", "self", ".", "_finished", "or", "self", ".", "_unfinished", ":", "return", "False", "# Clear the 'current' values when iteration is done.", "self", ".", "current_index", "=", "self", ".", "current_future", "=", "None", ...
Returns True if this iterator has no more results.
[ "Returns", "True", "if", "this", "iterator", "has", "no", "more", "results", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/eventloop/gen.py#L455-L461
codelv/enaml-native
src/enamlnative/core/eventloop/gen.py
WaitIterator.next
def next(self): """Returns a `.Future` that will yield the next available result. Note that this `.Future` will not be the same object as any of the inputs. """ self._running_future = TracebackFuture() if self._finished: self._return_result(self._finished.po...
python
def next(self): """Returns a `.Future` that will yield the next available result. Note that this `.Future` will not be the same object as any of the inputs. """ self._running_future = TracebackFuture() if self._finished: self._return_result(self._finished.po...
[ "def", "next", "(", "self", ")", ":", "self", ".", "_running_future", "=", "TracebackFuture", "(", ")", "if", "self", ".", "_finished", ":", "self", ".", "_return_result", "(", "self", ".", "_finished", ".", "popleft", "(", ")", ")", "return", "self", ...
Returns a `.Future` that will yield the next available result. Note that this `.Future` will not be the same object as any of the inputs.
[ "Returns", "a", ".", "Future", "that", "will", "yield", "the", "next", "available", "result", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/eventloop/gen.py#L463-L474
codelv/enaml-native
src/enamlnative/core/eventloop/gen.py
WaitIterator._return_result
def _return_result(self, done): """Called set the returned future's state that of the future we yielded, and set the current future for the iterator. """ chain_future(done, self._running_future) self.current_future = done self.current_index = self._unfinished.pop(done)
python
def _return_result(self, done): """Called set the returned future's state that of the future we yielded, and set the current future for the iterator. """ chain_future(done, self._running_future) self.current_future = done self.current_index = self._unfinished.pop(done)
[ "def", "_return_result", "(", "self", ",", "done", ")", ":", "chain_future", "(", "done", ",", "self", ".", "_running_future", ")", "self", ".", "current_future", "=", "done", "self", ".", "current_index", "=", "self", ".", "_unfinished", ".", "pop", "(", ...
Called set the returned future's state that of the future we yielded, and set the current future for the iterator.
[ "Called", "set", "the", "returned", "future", "s", "state", "that", "of", "the", "future", "we", "yielded", "and", "set", "the", "current", "future", "for", "the", "iterator", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/eventloop/gen.py#L482-L489
codelv/enaml-native
src/enamlnative/core/eventloop/gen.py
Runner.register_callback
def register_callback(self, key): """Adds ``key`` to the list of callbacks.""" if self.pending_callbacks is None: # Lazily initialize the old-style YieldPoint data structures. self.pending_callbacks = set() self.results = {} if key in self.pending_callbacks: ...
python
def register_callback(self, key): """Adds ``key`` to the list of callbacks.""" if self.pending_callbacks is None: # Lazily initialize the old-style YieldPoint data structures. self.pending_callbacks = set() self.results = {} if key in self.pending_callbacks: ...
[ "def", "register_callback", "(", "self", ",", "key", ")", ":", "if", "self", ".", "pending_callbacks", "is", "None", ":", "# Lazily initialize the old-style YieldPoint data structures.", "self", ".", "pending_callbacks", "=", "set", "(", ")", "self", ".", "results",...
Adds ``key`` to the list of callbacks.
[ "Adds", "key", "to", "the", "list", "of", "callbacks", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/eventloop/gen.py#L1047-L1055
codelv/enaml-native
src/enamlnative/core/eventloop/gen.py
Runner.is_ready
def is_ready(self, key): """Returns true if a result is available for ``key``.""" if self.pending_callbacks is None or key not in self.pending_callbacks: raise UnknownKeyError("key %r is not pending" % (key,)) return key in self.results
python
def is_ready(self, key): """Returns true if a result is available for ``key``.""" if self.pending_callbacks is None or key not in self.pending_callbacks: raise UnknownKeyError("key %r is not pending" % (key,)) return key in self.results
[ "def", "is_ready", "(", "self", ",", "key", ")", ":", "if", "self", ".", "pending_callbacks", "is", "None", "or", "key", "not", "in", "self", ".", "pending_callbacks", ":", "raise", "UnknownKeyError", "(", "\"key %r is not pending\"", "%", "(", "key", ",", ...
Returns true if a result is available for ``key``.
[ "Returns", "true", "if", "a", "result", "is", "available", "for", "key", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/eventloop/gen.py#L1057-L1061
codelv/enaml-native
src/enamlnative/core/eventloop/gen.py
Runner.set_result
def set_result(self, key, result): """Sets the result for ``key`` and attempts to resume the generator.""" self.results[key] = result if self.yield_point is not None and self.yield_point.is_ready(): try: self.future.set_result(self.yield_point.get_result()) ...
python
def set_result(self, key, result): """Sets the result for ``key`` and attempts to resume the generator.""" self.results[key] = result if self.yield_point is not None and self.yield_point.is_ready(): try: self.future.set_result(self.yield_point.get_result()) ...
[ "def", "set_result", "(", "self", ",", "key", ",", "result", ")", ":", "self", ".", "results", "[", "key", "]", "=", "result", "if", "self", ".", "yield_point", "is", "not", "None", "and", "self", ".", "yield_point", ".", "is_ready", "(", ")", ":", ...
Sets the result for ``key`` and attempts to resume the generator.
[ "Sets", "the", "result", "for", "key", "and", "attempts", "to", "resume", "the", "generator", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/eventloop/gen.py#L1063-L1072
codelv/enaml-native
src/enamlnative/core/eventloop/gen.py
Runner.pop_result
def pop_result(self, key): """Returns the result for ``key`` and unregisters it.""" self.pending_callbacks.remove(key) return self.results.pop(key)
python
def pop_result(self, key): """Returns the result for ``key`` and unregisters it.""" self.pending_callbacks.remove(key) return self.results.pop(key)
[ "def", "pop_result", "(", "self", ",", "key", ")", ":", "self", ".", "pending_callbacks", ".", "remove", "(", "key", ")", "return", "self", ".", "results", ".", "pop", "(", "key", ")" ]
Returns the result for ``key`` and unregisters it.
[ "Returns", "the", "result", "for", "key", "and", "unregisters", "it", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/eventloop/gen.py#L1074-L1077
codelv/enaml-native
src/enamlnative/core/eventloop/gen.py
Runner.run
def run(self): """Starts or resumes the generator, running until it reaches a yield point that is not ready. """ if self.running or self.finished: return try: self.running = True while True: future = self.future ...
python
def run(self): """Starts or resumes the generator, running until it reaches a yield point that is not ready. """ if self.running or self.finished: return try: self.running = True while True: future = self.future ...
[ "def", "run", "(", "self", ")", ":", "if", "self", ".", "running", "or", "self", ".", "finished", ":", "return", "try", ":", "self", ".", "running", "=", "True", "while", "True", ":", "future", "=", "self", ".", "future", "if", "not", "future", "."...
Starts or resumes the generator, running until it reaches a yield point that is not ready.
[ "Starts", "or", "resumes", "the", "generator", "running", "until", "it", "reaches", "a", "yield", "point", "that", "is", "not", "ready", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/eventloop/gen.py#L1079-L1144
codelv/enaml-native
src/enamlnative/android/android_radio_button.py
AndroidRadioButton.create_widget
def create_widget(self): """ Create the underlying widget. """ d = self.declaration self.widget = RadioButton(self.get_context(), None, d.style or '@attr/radioButtonStyle')
python
def create_widget(self): """ Create the underlying widget. """ d = self.declaration self.widget = RadioButton(self.get_context(), None, d.style or '@attr/radioButtonStyle')
[ "def", "create_widget", "(", "self", ")", ":", "d", "=", "self", ".", "declaration", "self", ".", "widget", "=", "RadioButton", "(", "self", ".", "get_context", "(", ")", ",", "None", ",", "d", ".", "style", "or", "'@attr/radioButtonStyle'", ")" ]
Create the underlying widget.
[ "Create", "the", "underlying", "widget", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_radio_button.py#L33-L39
codelv/enaml-native
src/enamlnative/core/dev.py
TornadoDevClient.write_message
def write_message(self, data, binary=False): """ Write a message to the client """ self.connection.write_message(data, binary)
python
def write_message(self, data, binary=False): """ Write a message to the client """ self.connection.write_message(data, binary)
[ "def", "write_message", "(", "self", ",", "data", ",", "binary", "=", "False", ")", ":", "self", ".", "connection", ".", "write_message", "(", "data", ",", "binary", ")" ]
Write a message to the client
[ "Write", "a", "message", "to", "the", "client" ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/dev.py#L361-L363
codelv/enaml-native
src/enamlnative/core/dev.py
DevServer.render_files
def render_files(self, root=None): """ Render the file path as accordions """ if root is None: tmp = os.environ.get('TMP') root = sys.path[1 if tmp and tmp in sys.path else 0] items = [] for filename in os.listdir(root): # for subdirname in di...
python
def render_files(self, root=None): """ Render the file path as accordions """ if root is None: tmp = os.environ.get('TMP') root = sys.path[1 if tmp and tmp in sys.path else 0] items = [] for filename in os.listdir(root): # for subdirname in di...
[ "def", "render_files", "(", "self", ",", "root", "=", "None", ")", ":", "if", "root", "is", "None", ":", "tmp", "=", "os", ".", "environ", ".", "get", "(", "'TMP'", ")", "root", "=", "sys", ".", "path", "[", "1", "if", "tmp", "and", "tmp", "in"...
Render the file path as accordions
[ "Render", "the", "file", "path", "as", "accordions" ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/dev.py#L491-L514
codelv/enaml-native
src/enamlnative/core/dev.py
DevServer.render_code
def render_code(self): """ Try to load the previous code (if we had a crash or something) I should allow saving. """ tmp_dir = os.environ.get('TMP','') view_code = os.path.join(tmp_dir,'view.enaml') if os.path.exists(view_code): try: with o...
python
def render_code(self): """ Try to load the previous code (if we had a crash or something) I should allow saving. """ tmp_dir = os.environ.get('TMP','') view_code = os.path.join(tmp_dir,'view.enaml') if os.path.exists(view_code): try: with o...
[ "def", "render_code", "(", "self", ")", ":", "tmp_dir", "=", "os", ".", "environ", ".", "get", "(", "'TMP'", ",", "''", ")", "view_code", "=", "os", ".", "path", ".", "join", "(", "tmp_dir", ",", "'view.enaml'", ")", "if", "os", ".", "path", ".", ...
Try to load the previous code (if we had a crash or something) I should allow saving.
[ "Try", "to", "load", "the", "previous", "code", "(", "if", "we", "had", "a", "crash", "or", "something", ")", "I", "should", "allow", "saving", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/dev.py#L516-L528
codelv/enaml-native
src/enamlnative/core/dev.py
DevServer.render_component
def render_component(self, declaration): """ Render a row of all the attributes """ items = ["""<tr><td>{name}</td><td>{type}</td></tr>""" .format(name=m.name, type=self.render_component_types(declaration, m)) for m in self.get_component_members...
python
def render_component(self, declaration): """ Render a row of all the attributes """ items = ["""<tr><td>{name}</td><td>{type}</td></tr>""" .format(name=m.name, type=self.render_component_types(declaration, m)) for m in self.get_component_members...
[ "def", "render_component", "(", "self", ",", "declaration", ")", ":", "items", "=", "[", "\"\"\"<tr><td>{name}</td><td>{type}</td></tr>\"\"\"", ".", "format", "(", "name", "=", "m", ".", "name", ",", "type", "=", "self", ".", "render_component_types", "(", "decl...
Render a row of all the attributes
[ "Render", "a", "row", "of", "all", "the", "attributes" ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/dev.py#L530-L567
codelv/enaml-native
src/enamlnative/core/dev.py
DevServerSession.start
def start(self): """ Start the dev session. Attempt to use tornado first, then try twisted """ print("Starting debug client cwd: {}".format(os.getcwd())) print("Sys path: {}".format(sys.path)) #: Initialize the hotswapper self.hotswap = Hotswapper(debug...
python
def start(self): """ Start the dev session. Attempt to use tornado first, then try twisted """ print("Starting debug client cwd: {}".format(os.getcwd())) print("Sys path: {}".format(sys.path)) #: Initialize the hotswapper self.hotswap = Hotswapper(debug...
[ "def", "start", "(", "self", ")", ":", "print", "(", "\"Starting debug client cwd: {}\"", ".", "format", "(", "os", ".", "getcwd", "(", ")", ")", ")", "print", "(", "\"Sys path: {}\"", ".", "format", "(", "sys", ".", "path", ")", ")", "#: Initialize the ho...
Start the dev session. Attempt to use tornado first, then try twisted
[ "Start", "the", "dev", "session", ".", "Attempt", "to", "use", "tornado", "first", "then", "try", "twisted" ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/dev.py#L782-L796
codelv/enaml-native
src/enamlnative/core/dev.py
DevServerSession._default_url
def _default_url(self): """ Websocket URL to connect to and listen for reload requests """ host = 'localhost' if self.mode == 'remote' else self.host return 'ws://{}:{}/dev'.format(host, self.port)
python
def _default_url(self): """ Websocket URL to connect to and listen for reload requests """ host = 'localhost' if self.mode == 'remote' else self.host return 'ws://{}:{}/dev'.format(host, self.port)
[ "def", "_default_url", "(", "self", ")", ":", "host", "=", "'localhost'", "if", "self", ".", "mode", "==", "'remote'", "else", "self", ".", "host", "return", "'ws://{}:{}/dev'", ".", "format", "(", "host", ",", "self", ".", "port", ")" ]
Websocket URL to connect to and listen for reload requests
[ "Websocket", "URL", "to", "connect", "to", "and", "listen", "for", "reload", "requests" ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/dev.py#L810-L813
codelv/enaml-native
src/enamlnative/core/dev.py
DevServerSession.write_message
def write_message(self, data, binary=False): """ Write a message to the active client """ self.client.write_message(data, binary=binary)
python
def write_message(self, data, binary=False): """ Write a message to the active client """ self.client.write_message(data, binary=binary)
[ "def", "write_message", "(", "self", ",", "data", ",", "binary", "=", "False", ")", ":", "self", ".", "client", ".", "write_message", "(", "data", ",", "binary", "=", "binary", ")" ]
Write a message to the active client
[ "Write", "a", "message", "to", "the", "active", "client" ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/dev.py#L843-L847
codelv/enaml-native
src/enamlnative/core/dev.py
DevServerSession.handle_message
def handle_message(self, data): """ When we get a message """ msg = json.loads(data) print("Dev server message: {}".format(msg)) handler_name = 'do_{}'.format(msg['type']) if hasattr(self, handler_name): handler = getattr(self, handler_name) result = handl...
python
def handle_message(self, data): """ When we get a message """ msg = json.loads(data) print("Dev server message: {}".format(msg)) handler_name = 'do_{}'.format(msg['type']) if hasattr(self, handler_name): handler = getattr(self, handler_name) result = handl...
[ "def", "handle_message", "(", "self", ",", "data", ")", ":", "msg", "=", "json", ".", "loads", "(", "data", ")", "print", "(", "\"Dev server message: {}\"", ".", "format", "(", "msg", ")", ")", "handler_name", "=", "'do_{}'", ".", "format", "(", "msg", ...
When we get a message
[ "When", "we", "get", "a", "message" ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/dev.py#L849-L861
codelv/enaml-native
src/enamlnative/core/dev.py
DevServerSession.do_reload
def do_reload(self, msg): """ Called when the dev server wants to reload the view. """ #: TODO: This should use the autorelaoder app = self.app #: Show loading screen try: self.app.widget.showLoading("Reloading... Please wait.", now=True) #self.app.widget...
python
def do_reload(self, msg): """ Called when the dev server wants to reload the view. """ #: TODO: This should use the autorelaoder app = self.app #: Show loading screen try: self.app.widget.showLoading("Reloading... Please wait.", now=True) #self.app.widget...
[ "def", "do_reload", "(", "self", ",", "msg", ")", ":", "#: TODO: This should use the autorelaoder", "app", "=", "self", ".", "app", "#: Show loading screen", "try", ":", "self", ".", "app", ".", "widget", ".", "showLoading", "(", "\"Reloading... Please wait.\"", "...
Called when the dev server wants to reload the view.
[ "Called", "when", "the", "dev", "server", "wants", "to", "reload", "the", "view", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/dev.py#L866-L900
codelv/enaml-native
src/enamlnative/core/dev.py
DevServerSession.do_hotswap
def do_hotswap(self, msg): """ Attempt to hotswap the code """ #: Show hotswap tooltip try: self.app.widget.showTooltip("Hot swapping...", now=True) except: pass self.save_changed_files(msg) hotswap = self.hotswap app = self.app tr...
python
def do_hotswap(self, msg): """ Attempt to hotswap the code """ #: Show hotswap tooltip try: self.app.widget.showTooltip("Hot swapping...", now=True) except: pass self.save_changed_files(msg) hotswap = self.hotswap app = self.app tr...
[ "def", "do_hotswap", "(", "self", ",", "msg", ")", ":", "#: Show hotswap tooltip", "try", ":", "self", ".", "app", ".", "widget", ".", "showTooltip", "(", "\"Hot swapping...\"", ",", "now", "=", "True", ")", "except", ":", "pass", "self", ".", "save_change...
Attempt to hotswap the code
[ "Attempt", "to", "hotswap", "the", "code" ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/dev.py#L902-L919
codelv/enaml-native
src/enamlnative/widgets/web_view.py
WebView._update_proxy
def _update_proxy(self, change): """ An observer which sends the state change to the proxy. """ if change['type'] == 'event': name = 'do_'+change['name'] if hasattr(self.proxy, name): handler = getattr(self.proxy, name) handler() e...
python
def _update_proxy(self, change): """ An observer which sends the state change to the proxy. """ if change['type'] == 'event': name = 'do_'+change['name'] if hasattr(self.proxy, name): handler = getattr(self.proxy, name) handler() e...
[ "def", "_update_proxy", "(", "self", ",", "change", ")", ":", "if", "change", "[", "'type'", "]", "==", "'event'", ":", "name", "=", "'do_'", "+", "change", "[", "'name'", "]", "if", "hasattr", "(", "self", ".", "proxy", ",", "name", ")", ":", "han...
An observer which sends the state change to the proxy.
[ "An", "observer", "which", "sends", "the", "state", "change", "to", "the", "proxy", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/widgets/web_view.py#L105-L115
codelv/enaml-native
src/enamlnative/android/android_popup_window.py
AndroidPopupWindow.create_widget
def create_widget(self): """ Create the underlying widget. A dialog is not a subclass of view, hence we don't set name as widget or children will try to use it as their parent. """ d = self.declaration style = d.style or '@style/Widget.DeviceDefault.PopupMenu' s...
python
def create_widget(self): """ Create the underlying widget. A dialog is not a subclass of view, hence we don't set name as widget or children will try to use it as their parent. """ d = self.declaration style = d.style or '@style/Widget.DeviceDefault.PopupMenu' s...
[ "def", "create_widget", "(", "self", ")", ":", "d", "=", "self", ".", "declaration", "style", "=", "d", ".", "style", "or", "'@style/Widget.DeviceDefault.PopupMenu'", "self", ".", "window", "=", "PopupWindow", "(", "self", ".", "get_context", "(", ")", ",", ...
Create the underlying widget. A dialog is not a subclass of view, hence we don't set name as widget or children will try to use it as their parent.
[ "Create", "the", "underlying", "widget", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_popup_window.py#L70-L80
codelv/enaml-native
src/enamlnative/android/android_popup_window.py
AndroidPopupWindow.init_widget
def init_widget(self): """ Set the listeners """ w = self.window d = self.declaration self.set_background_color(d.background_color) self.set_touchable(d.touchable) self.set_outside_touchable(d.outside_touchable) # Listen for events w.setOnDismissL...
python
def init_widget(self): """ Set the listeners """ w = self.window d = self.declaration self.set_background_color(d.background_color) self.set_touchable(d.touchable) self.set_outside_touchable(d.outside_touchable) # Listen for events w.setOnDismissL...
[ "def", "init_widget", "(", "self", ")", ":", "w", "=", "self", ".", "window", "d", "=", "self", ".", "declaration", "self", ".", "set_background_color", "(", "d", ".", "background_color", ")", "self", ".", "set_touchable", "(", "d", ".", "touchable", ")"...
Set the listeners
[ "Set", "the", "listeners" ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_popup_window.py#L82-L94
codelv/enaml-native
src/enamlnative/android/android_popup_window.py
AndroidPopupWindow.init_layout
def init_layout(self): """ If a view is given show it """ super(AndroidPopupWindow, self).init_layout() #: Set the content for view in self.child_widgets(): self.window.setContentView(view) break #: Show it if needed d = self.de...
python
def init_layout(self): """ If a view is given show it """ super(AndroidPopupWindow, self).init_layout() #: Set the content for view in self.child_widgets(): self.window.setContentView(view) break #: Show it if needed d = self.de...
[ "def", "init_layout", "(", "self", ")", ":", "super", "(", "AndroidPopupWindow", ",", "self", ")", ".", "init_layout", "(", ")", "#: Set the content", "for", "view", "in", "self", ".", "child_widgets", "(", ")", ":", "self", ".", "window", ".", "setContent...
If a view is given show it
[ "If", "a", "view", "is", "given", "show", "it" ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_popup_window.py#L96-L110
codelv/enaml-native
src/enamlnative/android/android_popup_window.py
AndroidPopupWindow.child_added
def child_added(self, child): """ Overwrite the content view """ view = child.widget if view is not None: self.window.setContentView(view)
python
def child_added(self, child): """ Overwrite the content view """ view = child.widget if view is not None: self.window.setContentView(view)
[ "def", "child_added", "(", "self", ",", "child", ")", ":", "view", "=", "child", ".", "widget", "if", "view", "is", "not", "None", ":", "self", ".", "window", ".", "setContentView", "(", "view", ")" ]
Overwrite the content view
[ "Overwrite", "the", "content", "view" ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_popup_window.py#L112-L116
codelv/enaml-native
src/enamlnative/android/android_popup_window.py
AndroidPopupWindow.destroy
def destroy(self): """ A reimplemented destructor that cancels the dialog before destroying. """ super(AndroidPopupWindow, self).destroy() window = self.window if window: #: Clear the dismiss listener #: (or we get an error during the ca...
python
def destroy(self): """ A reimplemented destructor that cancels the dialog before destroying. """ super(AndroidPopupWindow, self).destroy() window = self.window if window: #: Clear the dismiss listener #: (or we get an error during the ca...
[ "def", "destroy", "(", "self", ")", ":", "super", "(", "AndroidPopupWindow", ",", "self", ")", ".", "destroy", "(", ")", "window", "=", "self", ".", "window", "if", "window", ":", "#: Clear the dismiss listener", "#: (or we get an error during the callback)", "win...
A reimplemented destructor that cancels the dialog before destroying.
[ "A", "reimplemented", "destructor", "that", "cancels", "the", "dialog", "before", "destroying", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_popup_window.py#L118-L130
codelv/enaml-native
src/enamlnative/android/android_popup_window.py
AndroidPopupWindow.update
def update(self): """ Update the PopupWindow if it is currently showing. This avoids calling update during initialization. """ if not self.showing: return d = self.declaration self.set_show(d.show)
python
def update(self): """ Update the PopupWindow if it is currently showing. This avoids calling update during initialization. """ if not self.showing: return d = self.declaration self.set_show(d.show)
[ "def", "update", "(", "self", ")", ":", "if", "not", "self", ".", "showing", ":", "return", "d", "=", "self", ".", "declaration", "self", ".", "set_show", "(", "d", ".", "show", ")" ]
Update the PopupWindow if it is currently showing. This avoids calling update during initialization.
[ "Update", "the", "PopupWindow", "if", "it", "is", "currently", "showing", ".", "This", "avoids", "calling", "update", "during", "initialization", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_popup_window.py#L144-L151
codelv/enaml-native
src/enamlnative/widgets/fragment.py
Fragment.refresh_items
def refresh_items(self): """ Refresh the items of the pattern. This method destroys the old items and creates and initializes the new items. It is overridden to NOT insert the children to the parent. The Fragment adapter handles this. """ items = [] if s...
python
def refresh_items(self): """ Refresh the items of the pattern. This method destroys the old items and creates and initializes the new items. It is overridden to NOT insert the children to the parent. The Fragment adapter handles this. """ items = [] if s...
[ "def", "refresh_items", "(", "self", ")", ":", "items", "=", "[", "]", "if", "self", ".", "condition", ":", "for", "nodes", ",", "key", ",", "f_locals", "in", "self", ".", "pattern_nodes", ":", "with", "new_scope", "(", "key", ",", "f_locals", ")", "...
Refresh the items of the pattern. This method destroys the old items and creates and initializes the new items. It is overridden to NOT insert the children to the parent. The Fragment adapter handles this.
[ "Refresh", "the", "items", "of", "the", "pattern", ".", "This", "method", "destroys", "the", "old", "items", "and", "creates", "and", "initializes", "the", "new", "items", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/widgets/fragment.py#L49-L76
codelv/enaml-native
src/enamlnative/android/android_swipe_refresh_layout.py
AndroidSwipeRefreshLayout.init_widget
def init_widget(self): """ Initialize the underlying widget. """ super(AndroidSwipeRefreshLayout, self).init_widget() d = self.declaration w = self.widget if not d.enabled: self.set_enabled(d.enabled) if d.indicator_background_color: self....
python
def init_widget(self): """ Initialize the underlying widget. """ super(AndroidSwipeRefreshLayout, self).init_widget() d = self.declaration w = self.widget if not d.enabled: self.set_enabled(d.enabled) if d.indicator_background_color: self....
[ "def", "init_widget", "(", "self", ")", ":", "super", "(", "AndroidSwipeRefreshLayout", ",", "self", ")", ".", "init_widget", "(", ")", "d", "=", "self", ".", "declaration", "w", "=", "self", ".", "widget", "if", "not", "d", ".", "enabled", ":", "self"...
Initialize the underlying widget.
[ "Initialize", "the", "underlying", "widget", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_swipe_refresh_layout.py#L52-L68
codelv/enaml-native
src/enamlnative/core/import_hooks.py
ExtensionImporter.load_module
def load_module(self, mod): """ Load the extension using the load_dynamic method. """ try: return sys.modules[mod] except KeyError: pass lib = ExtensionImporter.extension_modules[mod] m = imp.load_dynamic(mod, lib) sys.modules[mod] = m ret...
python
def load_module(self, mod): """ Load the extension using the load_dynamic method. """ try: return sys.modules[mod] except KeyError: pass lib = ExtensionImporter.extension_modules[mod] m = imp.load_dynamic(mod, lib) sys.modules[mod] = m ret...
[ "def", "load_module", "(", "self", ",", "mod", ")", ":", "try", ":", "return", "sys", ".", "modules", "[", "mod", "]", "except", "KeyError", ":", "pass", "lib", "=", "ExtensionImporter", ".", "extension_modules", "[", "mod", "]", "m", "=", "imp", ".", ...
Load the extension using the load_dynamic method.
[ "Load", "the", "extension", "using", "the", "load_dynamic", "method", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/import_hooks.py#L41-L51
codelv/enaml-native
src/enamlnative/android/android_tab_layout.py
AndroidTabLayout.create_widget
def create_widget(self): """ Create the underlying widget. """ d = self.declaration self.widget = TabLayout(self.get_context(), None, d.style)
python
def create_widget(self): """ Create the underlying widget. """ d = self.declaration self.widget = TabLayout(self.get_context(), None, d.style)
[ "def", "create_widget", "(", "self", ")", ":", "d", "=", "self", ".", "declaration", "self", ".", "widget", "=", "TabLayout", "(", "self", ".", "get_context", "(", ")", ",", "None", ",", "d", ".", "style", ")" ]
Create the underlying widget.
[ "Create", "the", "underlying", "widget", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_tab_layout.py#L83-L88
codelv/enaml-native
src/enamlnative/android/android_tab_layout.py
AndroidTabLayout.init_widget
def init_widget(self): """ Initialize the underlying widget. """ super(AndroidTabLayout, self).init_widget() w = self.widget w.addOnTabSelectedListener(w.getId()) w.onTabSelected.connect(self.on_tab_selected) w.onTabUnselected.connect(self.on_tab_unselected)
python
def init_widget(self): """ Initialize the underlying widget. """ super(AndroidTabLayout, self).init_widget() w = self.widget w.addOnTabSelectedListener(w.getId()) w.onTabSelected.connect(self.on_tab_selected) w.onTabUnselected.connect(self.on_tab_unselected)
[ "def", "init_widget", "(", "self", ")", ":", "super", "(", "AndroidTabLayout", ",", "self", ")", ".", "init_widget", "(", ")", "w", "=", "self", ".", "widget", "w", ".", "addOnTabSelectedListener", "(", "w", ".", "getId", "(", ")", ")", "w", ".", "on...
Initialize the underlying widget.
[ "Initialize", "the", "underlying", "widget", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_tab_layout.py#L90-L98
codelv/enaml-native
src/enamlnative/android/android_tab_layout.py
AndroidTabLayout.destroy
def destroy(self): """ Destroy all tabs when destroyed """ super(AndroidTabLayout, self).destroy() if self.tabs: del self.tabs
python
def destroy(self): """ Destroy all tabs when destroyed """ super(AndroidTabLayout, self).destroy() if self.tabs: del self.tabs
[ "def", "destroy", "(", "self", ")", ":", "super", "(", "AndroidTabLayout", ",", "self", ")", ".", "destroy", "(", ")", "if", "self", ".", "tabs", ":", "del", "self", ".", "tabs" ]
Destroy all tabs when destroyed
[ "Destroy", "all", "tabs", "when", "destroyed" ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_tab_layout.py#L123-L129
codelv/enaml-native
src/enamlnative/core/hotswap/core.py
update_atom_members
def update_atom_members(old, new): """ Update an atom member """ old_keys = old.members().keys() new_keys = new.members().keys() for key in old_keys: old_obj = getattr(old, key) try: new_obj = getattr(new, key) if old_obj == new_obj: continue ...
python
def update_atom_members(old, new): """ Update an atom member """ old_keys = old.members().keys() new_keys = new.members().keys() for key in old_keys: old_obj = getattr(old, key) try: new_obj = getattr(new, key) if old_obj == new_obj: continue ...
[ "def", "update_atom_members", "(", "old", ",", "new", ")", ":", "old_keys", "=", "old", ".", "members", "(", ")", ".", "keys", "(", ")", "new_keys", "=", "new", ".", "members", "(", ")", ".", "keys", "(", ")", "for", "key", "in", "old_keys", ":", ...
Update an atom member
[ "Update", "an", "atom", "member" ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/hotswap/core.py#L44-L76
codelv/enaml-native
src/enamlnative/core/hotswap/core.py
update_class_by_type
def update_class_by_type(old, new): """ Update declarative classes or fallback on default """ autoreload.update_class(old, new) if isinstance2(old, new, AtomMeta): update_atom_members(old, new)
python
def update_class_by_type(old, new): """ Update declarative classes or fallback on default """ autoreload.update_class(old, new) if isinstance2(old, new, AtomMeta): update_atom_members(old, new)
[ "def", "update_class_by_type", "(", "old", ",", "new", ")", ":", "autoreload", ".", "update_class", "(", "old", ",", "new", ")", "if", "isinstance2", "(", "old", ",", "new", ",", "AtomMeta", ")", ":", "update_atom_members", "(", "old", ",", "new", ")" ]
Update declarative classes or fallback on default
[ "Update", "declarative", "classes", "or", "fallback", "on", "default" ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/hotswap/core.py#L79-L83
codelv/enaml-native
src/enamlnative/core/hotswap/core.py
EnamlReloader.check
def check(self, check_all=True, do_reload=True): """Check whether some modules need to be reloaded.""" with enaml.imports(): super(EnamlReloader, self).check(check_all=check_all, do_reload=do_reload)
python
def check(self, check_all=True, do_reload=True): """Check whether some modules need to be reloaded.""" with enaml.imports(): super(EnamlReloader, self).check(check_all=check_all, do_reload=do_reload)
[ "def", "check", "(", "self", ",", "check_all", "=", "True", ",", "do_reload", "=", "True", ")", ":", "with", "enaml", ".", "imports", "(", ")", ":", "super", "(", "EnamlReloader", ",", "self", ")", ".", "check", "(", "check_all", "=", "check_all", ",...
Check whether some modules need to be reloaded.
[ "Check", "whether", "some", "modules", "need", "to", "be", "reloaded", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/hotswap/core.py#L38-L41
codelv/enaml-native
src/enamlnative/core/hotswap/core.py
Hotswapper.update
def update(self, old, new=None): """ Update given view declaration with new declaration Parameters ----------- old: Declarative The existing view instance that needs to be updated new: Declarative or None The new or reloaded view instance to that will be ...
python
def update(self, old, new=None): """ Update given view declaration with new declaration Parameters ----------- old: Declarative The existing view instance that needs to be updated new: Declarative or None The new or reloaded view instance to that will be ...
[ "def", "update", "(", "self", ",", "old", ",", "new", "=", "None", ")", ":", "#: Create and initialize", "if", "not", "new", ":", "new", "=", "type", "(", "old", ")", "(", ")", "if", "not", "new", ".", "is_initialized", ":", "new", ".", "initialize",...
Update given view declaration with new declaration Parameters ----------- old: Declarative The existing view instance that needs to be updated new: Declarative or None The new or reloaded view instance to that will be used to update the existing view....
[ "Update", "given", "view", "declaration", "with", "new", "declaration" ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/hotswap/core.py#L129-L159
codelv/enaml-native
src/enamlnative/core/hotswap/core.py
Hotswapper.find_best_matching_node
def find_best_matching_node(self, new, old_nodes): """ Find the node that best matches the new node given the old nodes. If no good match exists return `None`. """ name = new.__class__.__name__ #: TODO: We should pick the BEST one from this list #: based on some "mat...
python
def find_best_matching_node(self, new, old_nodes): """ Find the node that best matches the new node given the old nodes. If no good match exists return `None`. """ name = new.__class__.__name__ #: TODO: We should pick the BEST one from this list #: based on some "mat...
[ "def", "find_best_matching_node", "(", "self", ",", "new", ",", "old_nodes", ")", ":", "name", "=", "new", ".", "__class__", ".", "__name__", "#: TODO: We should pick the BEST one from this list", "#: based on some \"matching\" criteria (such as matching ref name or params)", "...
Find the node that best matches the new node given the old nodes. If no good match exists return `None`.
[ "Find", "the", "node", "that", "best", "matches", "the", "new", "node", "given", "the", "old", "nodes", ".", "If", "no", "good", "match", "exists", "return", "None", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/hotswap/core.py#L161-L172
codelv/enaml-native
src/enamlnative/core/hotswap/core.py
Hotswapper.update_attrs
def update_attrs(self, old, new): """ Update any `attr` members. Parameters ----------- old: Declarative The existing view instance that needs to be updated new: Declarative The new view instance that should be used for updating ...
python
def update_attrs(self, old, new): """ Update any `attr` members. Parameters ----------- old: Declarative The existing view instance that needs to be updated new: Declarative The new view instance that should be used for updating ...
[ "def", "update_attrs", "(", "self", ",", "old", ",", "new", ")", ":", "#: Copy in storage from new node", "if", "new", ".", "_d_storage", ":", "old", ".", "_d_storage", "=", "new", ".", "_d_storage" ]
Update any `attr` members. Parameters ----------- old: Declarative The existing view instance that needs to be updated new: Declarative The new view instance that should be used for updating
[ "Update", "any", "attr", "members", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/hotswap/core.py#L248-L261
codelv/enaml-native
src/enamlnative/core/hotswap/core.py
Hotswapper.update_bindings
def update_bindings(self, old, new): """ Update any enaml operator bindings. Parameters ----------- old: Declarative The existing view instance that needs to be updated new: Declarative The new view instance that should be used for...
python
def update_bindings(self, old, new): """ Update any enaml operator bindings. Parameters ----------- old: Declarative The existing view instance that needs to be updated new: Declarative The new view instance that should be used for...
[ "def", "update_bindings", "(", "self", ",", "old", ",", "new", ")", ":", "#: Copy the Expression Engine", "if", "new", ".", "_d_engine", ":", "old", ".", "_d_engine", "=", "new", ".", "_d_engine", "engine", "=", "old", ".", "_d_engine", "#: Rerun any read expr...
Update any enaml operator bindings. Parameters ----------- old: Declarative The existing view instance that needs to be updated new: Declarative The new view instance that should be used for updating
[ "Update", "any", "enaml", "operator", "bindings", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/hotswap/core.py#L280-L304
codelv/enaml-native
src/enamlnative/ios/uikit_progress_view.py
UiKitProgressView.init_widget
def init_widget(self): """ Initialize the state of the toolkit widget. This method is called during the top-down pass, just after the 'create_widget()' method is called. This method should init the state of the widget. The child widgets will not yet be created. """ supe...
python
def init_widget(self): """ Initialize the state of the toolkit widget. This method is called during the top-down pass, just after the 'create_widget()' method is called. This method should init the state of the widget. The child widgets will not yet be created. """ supe...
[ "def", "init_widget", "(", "self", ")", ":", "super", "(", "UiKitProgressView", ",", "self", ")", ".", "init_widget", "(", ")", "d", "=", "self", ".", "declaration", "if", "d", ".", "progress", ":", "self", ".", "set_progress", "(", "d", ".", "progress...
Initialize the state of the toolkit widget. This method is called during the top-down pass, just after the 'create_widget()' method is called. This method should init the state of the widget. The child widgets will not yet be created.
[ "Initialize", "the", "state", "of", "the", "toolkit", "widget", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/ios/uikit_progress_view.py#L45-L57
codelv/enaml-native
src/enamlnative/ios/uikit_toolkit_object.py
UiKitToolkitObject.destroy
def destroy(self): """ A reimplemented destructor. This destructor will clear the reference to the toolkit widget and set its parent to None. """ widget = self.widget if widget is not None: del self.widget super(UiKitToolkitObject, self).destroy()
python
def destroy(self): """ A reimplemented destructor. This destructor will clear the reference to the toolkit widget and set its parent to None. """ widget = self.widget if widget is not None: del self.widget super(UiKitToolkitObject, self).destroy()
[ "def", "destroy", "(", "self", ")", ":", "widget", "=", "self", ".", "widget", "if", "widget", "is", "not", "None", ":", "del", "self", ".", "widget", "super", "(", "UiKitToolkitObject", ",", "self", ")", ".", "destroy", "(", ")" ]
A reimplemented destructor. This destructor will clear the reference to the toolkit widget and set its parent to None.
[ "A", "reimplemented", "destructor", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/ios/uikit_toolkit_object.py#L82-L92
codelv/enaml-native
src/enamlnative/android/android_view.py
AndroidView.create_widget
def create_widget(self): """ Create the underlying label widget. """ d = self.declaration self.widget = View(self.get_context(), None, d.style)
python
def create_widget(self): """ Create the underlying label widget. """ d = self.declaration self.widget = View(self.get_context(), None, d.style)
[ "def", "create_widget", "(", "self", ")", ":", "d", "=", "self", ".", "declaration", "self", ".", "widget", "=", "View", "(", "self", ".", "get_context", "(", ")", ",", "None", ",", "d", ".", "style", ")" ]
Create the underlying label widget.
[ "Create", "the", "underlying", "label", "widget", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_view.py#L140-L145
codelv/enaml-native
src/enamlnative/android/android_view.py
AndroidView.init_widget
def init_widget(self): """ Initialize the underlying widget. This reads all items declared in the enamldef block for this node and sets only the values that have been specified. All other values will be left as default. Doing it this way makes atom to only create the ...
python
def init_widget(self): """ Initialize the underlying widget. This reads all items declared in the enamldef block for this node and sets only the values that have been specified. All other values will be left as default. Doing it this way makes atom to only create the ...
[ "def", "init_widget", "(", "self", ")", ":", "super", "(", "AndroidView", ",", "self", ")", ".", "init_widget", "(", ")", "# Initialize the widget by updating only the members that", "# have read expressions declared. This saves a lot of time and", "# simplifies widget initializa...
Initialize the underlying widget. This reads all items declared in the enamldef block for this node and sets only the values that have been specified. All other values will be left as default. Doing it this way makes atom to only create the properties that need to be overridd...
[ "Initialize", "the", "underlying", "widget", ".", "This", "reads", "all", "items", "declared", "in", "the", "enamldef", "block", "for", "this", "node", "and", "sets", "only", "the", "values", "that", "have", "been", "specified", ".", "All", "other", "values"...
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_view.py#L147-L168
codelv/enaml-native
src/enamlnative/android/android_view.py
AndroidView.get_declared_items
def get_declared_items(self): """ Get the members that were set in the enamldef block for this Declaration. Layout keys are grouped together until the end so as to avoid triggering multiple updates. Returns ------- result: List of (k,v) pairs that were defined fo...
python
def get_declared_items(self): """ Get the members that were set in the enamldef block for this Declaration. Layout keys are grouped together until the end so as to avoid triggering multiple updates. Returns ------- result: List of (k,v) pairs that were defined fo...
[ "def", "get_declared_items", "(", "self", ")", ":", "d", "=", "self", ".", "declaration", "engine", "=", "d", ".", "_d_engine", "if", "engine", ":", "layout", "=", "{", "}", "for", "k", ",", "h", "in", "engine", ".", "_handlers", ".", "items", "(", ...
Get the members that were set in the enamldef block for this Declaration. Layout keys are grouped together until the end so as to avoid triggering multiple updates. Returns ------- result: List of (k,v) pairs that were defined for this widget in enaml List of...
[ "Get", "the", "members", "that", "were", "set", "in", "the", "enamldef", "block", "for", "this", "Declaration", ".", "Layout", "keys", "are", "grouped", "together", "until", "the", "end", "so", "as", "to", "avoid", "triggering", "multiple", "updates", ".", ...
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_view.py#L170-L196
codelv/enaml-native
src/enamlnative/android/android_view.py
AndroidView.on_key
def on_key(self, view, key, event): """ Trigger the key event Parameters ---------- view: int The ID of the view that sent this event key: int The code of the key that was pressed data: bytes The msgpack encoded key event """ ...
python
def on_key(self, view, key, event): """ Trigger the key event Parameters ---------- view: int The ID of the view that sent this event key: int The code of the key that was pressed data: bytes The msgpack encoded key event """ ...
[ "def", "on_key", "(", "self", ",", "view", ",", "key", ",", "event", ")", ":", "d", "=", "self", ".", "declaration", "r", "=", "{", "'key'", ":", "key", ",", "'result'", ":", "False", "}", "d", ".", "key_event", "(", "r", ")", "return", "r", "[...
Trigger the key event Parameters ---------- view: int The ID of the view that sent this event key: int The code of the key that was pressed data: bytes The msgpack encoded key event
[ "Trigger", "the", "key", "event" ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_view.py#L221-L237
codelv/enaml-native
src/enamlnative/android/android_view.py
AndroidView.on_touch
def on_touch(self, view, event): """ Trigger the touch event Parameters ---------- view: int The ID of the view that sent this event data: bytes The msgpack encoded key event """ d = self.declaration r = {'event': event, 'result':...
python
def on_touch(self, view, event): """ Trigger the touch event Parameters ---------- view: int The ID of the view that sent this event data: bytes The msgpack encoded key event """ d = self.declaration r = {'event': event, 'result':...
[ "def", "on_touch", "(", "self", ",", "view", ",", "event", ")", ":", "d", "=", "self", ".", "declaration", "r", "=", "{", "'event'", ":", "event", ",", "'result'", ":", "False", "}", "d", ".", "touch_event", "(", "r", ")", "return", "r", "[", "'r...
Trigger the touch event Parameters ---------- view: int The ID of the view that sent this event data: bytes The msgpack encoded key event
[ "Trigger", "the", "touch", "event" ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_view.py#L242-L256
codelv/enaml-native
src/enamlnative/android/android_view.py
AndroidView.set_visible
def set_visible(self, visible): """ Set the visibility of the widget. """ v = View.VISIBILITY_VISIBLE if visible else View.VISIBILITY_GONE self.widget.setVisibility(v)
python
def set_visible(self, visible): """ Set the visibility of the widget. """ v = View.VISIBILITY_VISIBLE if visible else View.VISIBILITY_GONE self.widget.setVisibility(v)
[ "def", "set_visible", "(", "self", ",", "visible", ")", ":", "v", "=", "View", ".", "VISIBILITY_VISIBLE", "if", "visible", "else", "View", ".", "VISIBILITY_GONE", "self", ".", "widget", ".", "setVisibility", "(", "v", ")" ]
Set the visibility of the widget.
[ "Set", "the", "visibility", "of", "the", "widget", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_view.py#L301-L306
codelv/enaml-native
src/enamlnative/android/android_view.py
AndroidView.set_layout
def set_layout(self, layout): """ Sets the LayoutParams of this widget. Since the available properties that may be set for the layout params depends on the parent, actual creation of the params is delegated to the parent Parameters ---------- ...
python
def set_layout(self, layout): """ Sets the LayoutParams of this widget. Since the available properties that may be set for the layout params depends on the parent, actual creation of the params is delegated to the parent Parameters ---------- ...
[ "def", "set_layout", "(", "self", ",", "layout", ")", ":", "# Update the layout with the widget defaults", "update", "=", "self", ".", "layout_params", "is", "not", "None", "params", "=", "self", ".", "default_layout", ".", "copy", "(", ")", "params", ".", "up...
Sets the LayoutParams of this widget. Since the available properties that may be set for the layout params depends on the parent, actual creation of the params is delegated to the parent Parameters ---------- layout: Dict A dict of layo...
[ "Sets", "the", "LayoutParams", "of", "this", "widget", ".", "Since", "the", "available", "properties", "that", "may", "be", "set", "for", "the", "layout", "params", "depends", "on", "the", "parent", "actual", "creation", "of", "the", "params", "is", "delegat...
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_view.py#L330-L359
codelv/enaml-native
src/enamlnative/android/android_view.py
AndroidView.create_layout_params
def create_layout_params(self, child, layout): """ Create the LayoutParams for a child with it's requested layout parameters. Subclasses should override this as needed to handle layout specific needs. Parameters ---------- child: AndroidView A view to...
python
def create_layout_params(self, child, layout): """ Create the LayoutParams for a child with it's requested layout parameters. Subclasses should override this as needed to handle layout specific needs. Parameters ---------- child: AndroidView A view to...
[ "def", "create_layout_params", "(", "self", ",", "child", ",", "layout", ")", ":", "dp", "=", "self", ".", "dp", "w", ",", "h", "=", "(", "coerce_size", "(", "layout", ".", "get", "(", "'width'", ",", "'wrap_content'", ")", ")", ",", "coerce_size", "...
Create the LayoutParams for a child with it's requested layout parameters. Subclasses should override this as needed to handle layout specific needs. Parameters ---------- child: AndroidView A view to create layout params for. layout: Dict ...
[ "Create", "the", "LayoutParams", "for", "a", "child", "with", "it", "s", "requested", "layout", "parameters", ".", "Subclasses", "should", "override", "this", "as", "needed", "to", "handle", "layout", "specific", "needs", ".", "Parameters", "----------", "child"...
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_view.py#L376-L405
codelv/enaml-native
src/enamlnative/android/android_view.py
AndroidView.apply_layout
def apply_layout(self, child, layout): """ Apply a layout to a child. This sets the layout_params of the child which is later used during the `init_layout` pass. Subclasses should override this as needed to handle layout specific needs of the ViewGroup. Parameters ...
python
def apply_layout(self, child, layout): """ Apply a layout to a child. This sets the layout_params of the child which is later used during the `init_layout` pass. Subclasses should override this as needed to handle layout specific needs of the ViewGroup. Parameters ...
[ "def", "apply_layout", "(", "self", ",", "child", ",", "layout", ")", ":", "layout_params", "=", "child", ".", "layout_params", "if", "not", "layout_params", ":", "layout_params", "=", "self", ".", "create_layout_params", "(", "child", ",", "layout", ")", "w...
Apply a layout to a child. This sets the layout_params of the child which is later used during the `init_layout` pass. Subclasses should override this as needed to handle layout specific needs of the ViewGroup. Parameters ---------- child: AndroidView ...
[ "Apply", "a", "layout", "to", "a", "child", ".", "This", "sets", "the", "layout_params", "of", "the", "child", "which", "is", "later", "used", "during", "the", "init_layout", "pass", ".", "Subclasses", "should", "override", "this", "as", "needed", "to", "h...
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_view.py#L407-L458
codelv/enaml-native
src/enamlnative/core/loop.py
EventLoop.default
def default(cls): """ Get the first available event loop implementation based on which packages are installed. """ with enamlnative.imports(): for impl in [ TornadoEventLoop, TwistedEventLoop, BuiltinEventLoop, ...
python
def default(cls): """ Get the first available event loop implementation based on which packages are installed. """ with enamlnative.imports(): for impl in [ TornadoEventLoop, TwistedEventLoop, BuiltinEventLoop, ...
[ "def", "default", "(", "cls", ")", ":", "with", "enamlnative", ".", "imports", "(", ")", ":", "for", "impl", "in", "[", "TornadoEventLoop", ",", "TwistedEventLoop", ",", "BuiltinEventLoop", ",", "]", ":", "if", "impl", ".", "available", "(", ")", ":", ...
Get the first available event loop implementation based on which packages are installed.
[ "Get", "the", "first", "available", "event", "loop", "implementation", "based", "on", "which", "packages", "are", "installed", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/loop.py#L34-L49
codelv/enaml-native
src/enamlnative/core/loop.py
EventLoop.log_error
def log_error(self, callback, error=None): """ Log the error that occurred when running the given callback. """ print("Uncaught error during callback: {}".format(callback)) print("Error: {}".format(error))
python
def log_error(self, callback, error=None): """ Log the error that occurred when running the given callback. """ print("Uncaught error during callback: {}".format(callback)) print("Error: {}".format(error))
[ "def", "log_error", "(", "self", ",", "callback", ",", "error", "=", "None", ")", ":", "print", "(", "\"Uncaught error during callback: {}\"", ".", "format", "(", "callback", ")", ")", "print", "(", "\"Error: {}\"", ".", "format", "(", "error", ")", ")" ]
Log the error that occurred when running the given callback.
[ "Log", "the", "error", "that", "occurred", "when", "running", "the", "given", "callback", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/loop.py#L117-L120
codelv/enaml-native
src/enamlnative/core/loop.py
TwistedEventLoop.deferred_call
def deferred_call(self, callback, *args, **kwargs): """ We have to wake up the reactor after every call because it may calculate a long delay where it can sleep which causes events that happen during this period to seem really slow as they do not get processed until after the reactor ...
python
def deferred_call(self, callback, *args, **kwargs): """ We have to wake up the reactor after every call because it may calculate a long delay where it can sleep which causes events that happen during this period to seem really slow as they do not get processed until after the reactor ...
[ "def", "deferred_call", "(", "self", ",", "callback", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "loop", "=", "self", ".", "loop", "r", "=", "loop", ".", "callLater", "(", "0", ",", "callback", ",", "*", "args", ",", "*", "*", "kwargs",...
We have to wake up the reactor after every call because it may calculate a long delay where it can sleep which causes events that happen during this period to seem really slow as they do not get processed until after the reactor "wakes up"
[ "We", "have", "to", "wake", "up", "the", "reactor", "after", "every", "call", "because", "it", "may", "calculate", "a", "long", "delay", "where", "it", "can", "sleep", "which", "causes", "events", "that", "happen", "during", "this", "period", "to", "seem",...
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/loop.py#L270-L280
codelv/enaml-native
src/enamlnative/core/loop.py
TwistedEventLoop.timed_call
def timed_call(self, ms, callback, *args, **kwargs): """ We have to wake up the reactor after every call because it may calculate a long delay where it can sleep which causes events that happen during this period to seem really slow as they do not get processed until after the reactor ...
python
def timed_call(self, ms, callback, *args, **kwargs): """ We have to wake up the reactor after every call because it may calculate a long delay where it can sleep which causes events that happen during this period to seem really slow as they do not get processed until after the reactor ...
[ "def", "timed_call", "(", "self", ",", "ms", ",", "callback", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "loop", "=", "self", ".", "loop", "r", "=", "loop", ".", "callLater", "(", "ms", "/", "1000.0", ",", "callback", ",", "*", "args", ...
We have to wake up the reactor after every call because it may calculate a long delay where it can sleep which causes events that happen during this period to seem really slow as they do not get processed until after the reactor "wakes up"
[ "We", "have", "to", "wake", "up", "the", "reactor", "after", "every", "call", "because", "it", "may", "calculate", "a", "long", "delay", "where", "it", "can", "sleep", "which", "causes", "events", "that", "happen", "during", "this", "period", "to", "seem",...
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/loop.py#L282-L292
codelv/enaml-native
src/enamlnative/ios/uikit_view.py
UiKitView.init_widget
def init_widget(self): """ Initialize the underlying widget. This reads all items declared in the enamldef block for this node and sets only the values that have been specified. All other values will be left as default. Doing it this way makes atom to only create the properties ...
python
def init_widget(self): """ Initialize the underlying widget. This reads all items declared in the enamldef block for this node and sets only the values that have been specified. All other values will be left as default. Doing it this way makes atom to only create the properties ...
[ "def", "init_widget", "(", "self", ")", ":", "super", "(", "UiKitView", ",", "self", ")", ".", "init_widget", "(", ")", "self", ".", "widget", ".", "yoga", ".", "isEnabled", "=", "True", "# Initialize the widget by updating only the members that", "# have read exp...
Initialize the underlying widget. This reads all items declared in the enamldef block for this node and sets only the values that have been specified. All other values will be left as default. Doing it this way makes atom to only create the properties that need to be overridden from def...
[ "Initialize", "the", "underlying", "widget", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/ios/uikit_view.py#L113-L136
codelv/enaml-native
src/enamlnative/ios/uikit_view.py
UiKitView.init_layout
def init_layout(self): """ Initialize the layout of the toolkit widget. This method is called during the bottom-up pass. This method should initialize the layout of the widget. The child widgets will be fully initialized and layed out when this is called. """ widget...
python
def init_layout(self): """ Initialize the layout of the toolkit widget. This method is called during the bottom-up pass. This method should initialize the layout of the widget. The child widgets will be fully initialized and layed out when this is called. """ widget...
[ "def", "init_layout", "(", "self", ")", ":", "widget", "=", "self", ".", "widget", "for", "child_widget", "in", "self", ".", "child_widgets", "(", ")", ":", "widget", ".", "addSubview", "(", "child_widget", ")" ]
Initialize the layout of the toolkit widget. This method is called during the bottom-up pass. This method should initialize the layout of the widget. The child widgets will be fully initialized and layed out when this is called.
[ "Initialize", "the", "layout", "of", "the", "toolkit", "widget", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/ios/uikit_view.py#L159-L169
codelv/enaml-native
src/enamlnative/ios/uikit_view.py
UiKitView.update_frame
def update_frame(self): """ Define the view frame for this widgets""" d = self.declaration if d.x or d.y or d.width or d.height: self.frame = (d.x, d.y, d.width, d.height)
python
def update_frame(self): """ Define the view frame for this widgets""" d = self.declaration if d.x or d.y or d.width or d.height: self.frame = (d.x, d.y, d.width, d.height)
[ "def", "update_frame", "(", "self", ")", ":", "d", "=", "self", ".", "declaration", "if", "d", ".", "x", "or", "d", ".", "y", "or", "d", ".", "width", "or", "d", ".", "height", ":", "self", ".", "frame", "=", "(", "d", ".", "x", ",", "d", "...
Define the view frame for this widgets
[ "Define", "the", "view", "frame", "for", "this", "widgets" ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/ios/uikit_view.py#L171-L175
codelv/enaml-native
src/enamlnative/ios/uikit_view.py
UiKitView.child_added
def child_added(self, child): """ Handle the child added event from the declaration. This handler will unparent the child toolkit widget. Subclasses which need more control should reimplement this method. """ super(UiKitView, self).child_added(child) widget = self.widg...
python
def child_added(self, child): """ Handle the child added event from the declaration. This handler will unparent the child toolkit widget. Subclasses which need more control should reimplement this method. """ super(UiKitView, self).child_added(child) widget = self.widg...
[ "def", "child_added", "(", "self", ",", "child", ")", ":", "super", "(", "UiKitView", ",", "self", ")", ".", "child_added", "(", "child", ")", "widget", "=", "self", ".", "widget", "#: TODO: Should index be cached?", "for", "i", ",", "child_widget", "in", ...
Handle the child added event from the declaration. This handler will unparent the child toolkit widget. Subclasses which need more control should reimplement this method.
[ "Handle", "the", "child", "added", "event", "from", "the", "declaration", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/ios/uikit_view.py#L188-L201
codelv/enaml-native
src/enamlnative/ios/uikit_view.py
UiKitView.child_moved
def child_moved(self, child): """ Handle the child moved event from the declaration. """ super(UiKitView, self).child_moved(child) #: Remove and re-add in correct spot #: TODO: Should use exchangeSubviewAtIndex self.child_removed(child) self.child_added(child)
python
def child_moved(self, child): """ Handle the child moved event from the declaration. """ super(UiKitView, self).child_moved(child) #: Remove and re-add in correct spot #: TODO: Should use exchangeSubviewAtIndex self.child_removed(child) self.child_added(child)
[ "def", "child_moved", "(", "self", ",", "child", ")", ":", "super", "(", "UiKitView", ",", "self", ")", ".", "child_moved", "(", "child", ")", "#: Remove and re-add in correct spot", "#: TODO: Should use exchangeSubviewAtIndex", "self", ".", "child_removed", "(", "c...
Handle the child moved event from the declaration.
[ "Handle", "the", "child", "moved", "event", "from", "the", "declaration", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/ios/uikit_view.py#L203-L211
codelv/enaml-native
src/enamlnative/ios/uikit_view.py
UiKitView.child_removed
def child_removed(self, child): """ Handle the child removed event from the declaration. This handler will unparent the child toolkit widget. Subclasses which need more control should reimplement this method. """ super(UiKitView, self).child_removed(child) if child.widg...
python
def child_removed(self, child): """ Handle the child removed event from the declaration. This handler will unparent the child toolkit widget. Subclasses which need more control should reimplement this method. """ super(UiKitView, self).child_removed(child) if child.widg...
[ "def", "child_removed", "(", "self", ",", "child", ")", ":", "super", "(", "UiKitView", ",", "self", ")", ".", "child_removed", "(", "child", ")", "if", "child", ".", "widget", "is", "not", "None", ":", "child", ".", "widget", ".", "removeFromSuperview",...
Handle the child removed event from the declaration. This handler will unparent the child toolkit widget. Subclasses which need more control should reimplement this method.
[ "Handle", "the", "child", "removed", "event", "from", "the", "declaration", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/ios/uikit_view.py#L213-L222
codelv/enaml-native
src/enamlnative/ios/uikit_view.py
UiKitView.destroy
def destroy(self): """ A reimplemented destructor. This destructor will remove itself from the superview. """ widget = self.widget if widget is not None: widget.removeFromSuperview() super(UiKitView, self).destroy()
python
def destroy(self): """ A reimplemented destructor. This destructor will remove itself from the superview. """ widget = self.widget if widget is not None: widget.removeFromSuperview() super(UiKitView, self).destroy()
[ "def", "destroy", "(", "self", ")", ":", "widget", "=", "self", ".", "widget", "if", "widget", "is", "not", "None", ":", "widget", ".", "removeFromSuperview", "(", ")", "super", "(", "UiKitView", ",", "self", ")", ".", "destroy", "(", ")" ]
A reimplemented destructor. This destructor will remove itself from the superview.
[ "A", "reimplemented", "destructor", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/ios/uikit_view.py#L224-L233
codelv/enaml-native
src/enamlnative/android/android_surface_view.py
AndroidSurfaceView.init_layout
def init_layout(self): """ Add all child widgets to the view """ super(AndroidSurfaceView, self).init_layout() # Force layout using the default params if not self.layout_params: self.set_layout({})
python
def init_layout(self): """ Add all child widgets to the view """ super(AndroidSurfaceView, self).init_layout() # Force layout using the default params if not self.layout_params: self.set_layout({})
[ "def", "init_layout", "(", "self", ")", ":", "super", "(", "AndroidSurfaceView", ",", "self", ")", ".", "init_layout", "(", ")", "# Force layout using the default params", "if", "not", "self", ".", "layout_params", ":", "self", ".", "set_layout", "(", "{", "}"...
Add all child widgets to the view
[ "Add", "all", "child", "widgets", "to", "the", "view" ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_surface_view.py#L72-L79
codelv/enaml-native
examples/playground/main.py
main
def main(): """ Called by PyBridge.start() """ #: If we set the TMP env variable the dev reloader will save file #: and load changes in this directory instead of overwriting the #: ones installed with the app. os.environ['TMP'] = os.path.join(sys.path[0], '../tmp') from enamlnative.android...
python
def main(): """ Called by PyBridge.start() """ #: If we set the TMP env variable the dev reloader will save file #: and load changes in this directory instead of overwriting the #: ones installed with the app. os.environ['TMP'] = os.path.join(sys.path[0], '../tmp') from enamlnative.android...
[ "def", "main", "(", ")", ":", "#: If we set the TMP env variable the dev reloader will save file", "#: and load changes in this directory instead of overwriting the", "#: ones installed with the app.", "os", ".", "environ", "[", "'TMP'", "]", "=", "os", ".", "path", ".", "join"...
Called by PyBridge.start()
[ "Called", "by", "PyBridge", ".", "start", "()" ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/examples/playground/main.py#L25-L41
codelv/enaml-native
src/enamlnative/android/android_view_switcher.py
AndroidViewAnimator.init_widget
def init_widget(self): """ Initialize the underlying widget. """ super(AndroidViewAnimator, self).init_widget() d = self.declaration if d.animate_first_view: self.set_animate_first_view(d.animate_first_view) if d.displayed_child: self.set_displaye...
python
def init_widget(self): """ Initialize the underlying widget. """ super(AndroidViewAnimator, self).init_widget() d = self.declaration if d.animate_first_view: self.set_animate_first_view(d.animate_first_view) if d.displayed_child: self.set_displaye...
[ "def", "init_widget", "(", "self", ")", ":", "super", "(", "AndroidViewAnimator", ",", "self", ")", ".", "init_widget", "(", ")", "d", "=", "self", ".", "declaration", "if", "d", ".", "animate_first_view", ":", "self", ".", "set_animate_first_view", "(", "...
Initialize the underlying widget.
[ "Initialize", "the", "underlying", "widget", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_view_switcher.py#L37-L46
codelv/enaml-native
src/enamlnative/android/android_view_pager.py
AndroidViewPager.create_widget
def create_widget(self): """ Create the underlying widget. """ self.widget = ViewPager(self.get_context()) self.adapter = BridgedFragmentStatePagerAdapter()
python
def create_widget(self): """ Create the underlying widget. """ self.widget = ViewPager(self.get_context()) self.adapter = BridgedFragmentStatePagerAdapter()
[ "def", "create_widget", "(", "self", ")", ":", "self", ".", "widget", "=", "ViewPager", "(", "self", ".", "get_context", "(", ")", ")", "self", ".", "adapter", "=", "BridgedFragmentStatePagerAdapter", "(", ")" ]
Create the underlying widget.
[ "Create", "the", "underlying", "widget", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_view_pager.py#L143-L148
codelv/enaml-native
src/enamlnative/android/android_view_pager.py
AndroidViewPager.child_added
def child_added(self, child): """ When a child is added, schedule a data changed notification """ super(AndroidViewPager, self).child_added(child) self._notify_count += 1 self.get_context().timed_call( self._notify_delay, self._notify_change)
python
def child_added(self, child): """ When a child is added, schedule a data changed notification """ super(AndroidViewPager, self).child_added(child) self._notify_count += 1 self.get_context().timed_call( self._notify_delay, self._notify_change)
[ "def", "child_added", "(", "self", ",", "child", ")", ":", "super", "(", "AndroidViewPager", ",", "self", ")", ".", "child_added", "(", "child", ")", "self", ".", "_notify_count", "+=", "1", "self", ".", "get_context", "(", ")", ".", "timed_call", "(", ...
When a child is added, schedule a data changed notification
[ "When", "a", "child", "is", "added", "schedule", "a", "data", "changed", "notification" ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_view_pager.py#L163-L168
codelv/enaml-native
src/enamlnative/android/android_view_pager.py
AndroidViewPager._notify_change
def _notify_change(self): """ After all changes have settled, tell Java it changed """ d = self.declaration self._notify_count -= 1 if self._notify_count == 0: #: Tell the UI we made changes self.adapter.notifyDataSetChanged(now=True) self.get_context(...
python
def _notify_change(self): """ After all changes have settled, tell Java it changed """ d = self.declaration self._notify_count -= 1 if self._notify_count == 0: #: Tell the UI we made changes self.adapter.notifyDataSetChanged(now=True) self.get_context(...
[ "def", "_notify_change", "(", "self", ")", ":", "d", "=", "self", ".", "declaration", "self", ".", "_notify_count", "-=", "1", "if", "self", ".", "_notify_count", "==", "0", ":", "#: Tell the UI we made changes", "self", ".", "adapter", ".", "notifyDataSetChan...
After all changes have settled, tell Java it changed
[ "After", "all", "changes", "have", "settled", "tell", "Java", "it", "changed" ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_view_pager.py#L177-L185
codelv/enaml-native
src/enamlnative/android/android_view_pager.py
AndroidViewPager.set_current_index
def set_current_index(self, index): """ We can only set the index once the page has been created. otherwise we get `FragmentManager is already executing transactions` errors in Java. To avoid this, we only call this once has been loaded. """ # d = self.declaration ...
python
def set_current_index(self, index): """ We can only set the index once the page has been created. otherwise we get `FragmentManager is already executing transactions` errors in Java. To avoid this, we only call this once has been loaded. """ # d = self.declaration ...
[ "def", "set_current_index", "(", "self", ",", "index", ")", ":", "# d = self.declaration", "# #: We have to wait for the current_index to be ready before we can", "# #: change pages", "if", "self", ".", "_notify_count", ">", "0", ":", "self", ".", "_pending_calls", ".", "...
We can only set the index once the page has been created. otherwise we get `FragmentManager is already executing transactions` errors in Java. To avoid this, we only call this once has been loaded.
[ "We", "can", "only", "set", "the", "index", "once", "the", "page", "has", "been", "created", ".", "otherwise", "we", "get", "FragmentManager", "is", "already", "executing", "transactions", "errors", "in", "Java", ".", "To", "avoid", "this", "we", "only", "...
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_view_pager.py#L228-L241
codelv/enaml-native
src/enamlnative/android/android_view_pager.py
AndroidViewPager.create_layout_params
def create_layout_params(self, child, layout): """ Override as there is no (width, height) constructor. """ from .android_fragment import AndroidFragment if isinstance(child, AndroidFragment): return super(AndroidViewPager, self).create_layout_params(child, ...
python
def create_layout_params(self, child, layout): """ Override as there is no (width, height) constructor. """ from .android_fragment import AndroidFragment if isinstance(child, AndroidFragment): return super(AndroidViewPager, self).create_layout_params(child, ...
[ "def", "create_layout_params", "(", "self", ",", "child", ",", "layout", ")", ":", "from", ".", "android_fragment", "import", "AndroidFragment", "if", "isinstance", "(", "child", ",", "AndroidFragment", ")", ":", "return", "super", "(", "AndroidViewPager", ",", ...
Override as there is no (width, height) constructor.
[ "Override", "as", "there", "is", "no", "(", "width", "height", ")", "constructor", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_view_pager.py#L256-L275
codelv/enaml-native
src/enamlnative/android/android_card_view.py
AndroidCardView.create_widget
def create_widget(self): """ Create the underlying widget. """ d = self.declaration self.widget = CardView(self.get_context(), None, d.style)
python
def create_widget(self): """ Create the underlying widget. """ d = self.declaration self.widget = CardView(self.get_context(), None, d.style)
[ "def", "create_widget", "(", "self", ")", ":", "d", "=", "self", ".", "declaration", "self", ".", "widget", "=", "CardView", "(", "self", ".", "get_context", "(", ")", ",", "None", ",", "d", ".", "style", ")" ]
Create the underlying widget.
[ "Create", "the", "underlying", "widget", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_card_view.py#L45-L50
codelv/enaml-native
src/enamlnative/android/android_text_clock.py
AndroidTextClock.create_widget
def create_widget(self): """ Create the underlying widget. """ d = self.declaration self.widget = TextClock(self.get_context(), None, d.style)
python
def create_widget(self): """ Create the underlying widget. """ d = self.declaration self.widget = TextClock(self.get_context(), None, d.style)
[ "def", "create_widget", "(", "self", ")", ":", "d", "=", "self", ".", "declaration", "self", ".", "widget", "=", "TextClock", "(", "self", ".", "get_context", "(", ")", ",", "None", ",", "d", ".", "style", ")" ]
Create the underlying widget.
[ "Create", "the", "underlying", "widget", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_text_clock.py#L37-L42
codelv/enaml-native
src/enamlnative/android/android_text_clock.py
AndroidTextClock.init_widget
def init_widget(self): """ Initialize the underlying widget. """ super(AndroidTextClock, self).init_widget() d = self.declaration if d.format_12_hour: self.set_format_12_hour(d.format_12_hour) if d.format_24_hour: self.set_format_24_hour(d.format_...
python
def init_widget(self): """ Initialize the underlying widget. """ super(AndroidTextClock, self).init_widget() d = self.declaration if d.format_12_hour: self.set_format_12_hour(d.format_12_hour) if d.format_24_hour: self.set_format_24_hour(d.format_...
[ "def", "init_widget", "(", "self", ")", ":", "super", "(", "AndroidTextClock", ",", "self", ")", ".", "init_widget", "(", ")", "d", "=", "self", ".", "declaration", "if", "d", ".", "format_12_hour", ":", "self", ".", "set_format_12_hour", "(", "d", ".", ...
Initialize the underlying widget.
[ "Initialize", "the", "underlying", "widget", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_text_clock.py#L44-L55
codelv/enaml-native
src/enamlnative/android/android_progress_bar.py
AndroidProgressBar.create_widget
def create_widget(self): """ Create the underlying widget. """ d = self.declaration if self.indeterminate: #: Note: Style will only exist on activity indicators! style = ProgressBar.STYLES[d.size] else: style = ProgressBar.STYLE_HORIZONTAL ...
python
def create_widget(self): """ Create the underlying widget. """ d = self.declaration if self.indeterminate: #: Note: Style will only exist on activity indicators! style = ProgressBar.STYLES[d.size] else: style = ProgressBar.STYLE_HORIZONTAL ...
[ "def", "create_widget", "(", "self", ")", ":", "d", "=", "self", ".", "declaration", "if", "self", ".", "indeterminate", ":", "#: Note: Style will only exist on activity indicators!", "style", "=", "ProgressBar", ".", "STYLES", "[", "d", ".", "size", "]", "else"...
Create the underlying widget.
[ "Create", "the", "underlying", "widget", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_progress_bar.py#L58-L69
codelv/enaml-native
src/enamlnative/android/android_progress_bar.py
AndroidProgressBar.init_widget
def init_widget(self): """ Initialize the underlying widget. """ super(AndroidProgressBar, self).init_widget() d = self.declaration self.set_indeterminate(self.indeterminate) if not self.indeterminate: if d.max: self.set_max(d.max) ...
python
def init_widget(self): """ Initialize the underlying widget. """ super(AndroidProgressBar, self).init_widget() d = self.declaration self.set_indeterminate(self.indeterminate) if not self.indeterminate: if d.max: self.set_max(d.max) ...
[ "def", "init_widget", "(", "self", ")", ":", "super", "(", "AndroidProgressBar", ",", "self", ")", ".", "init_widget", "(", ")", "d", "=", "self", ".", "declaration", "self", ".", "set_indeterminate", "(", "self", ".", "indeterminate", ")", "if", "not", ...
Initialize the underlying widget.
[ "Initialize", "the", "underlying", "widget", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_progress_bar.py#L71-L88
codelv/enaml-native
src/enamlnative/android/android_flexbox.py
AndroidFlexbox.create_widget
def create_widget(self): """ Create the underlying widget. """ d = self.declaration self.widget = Flexbox(self.get_context(), None, d.style)
python
def create_widget(self): """ Create the underlying widget. """ d = self.declaration self.widget = Flexbox(self.get_context(), None, d.style)
[ "def", "create_widget", "(", "self", ")", ":", "d", "=", "self", ".", "declaration", "self", ".", "widget", "=", "Flexbox", "(", "self", ".", "get_context", "(", ")", ",", "None", ",", "d", ".", "style", ")" ]
Create the underlying widget.
[ "Create", "the", "underlying", "widget", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_flexbox.py#L126-L131
codelv/enaml-native
src/enamlnative/android/android_flexbox.py
AndroidFlexbox.apply_layout
def apply_layout(self, child, layout): """ Apply the flexbox specific layout. """ params = self.create_layout_params(child, layout) w = child.widget if w: # padding if layout.get('padding'): dp = self.dp l, t, r, b ...
python
def apply_layout(self, child, layout): """ Apply the flexbox specific layout. """ params = self.create_layout_params(child, layout) w = child.widget if w: # padding if layout.get('padding'): dp = self.dp l, t, r, b ...
[ "def", "apply_layout", "(", "self", ",", "child", ",", "layout", ")", ":", "params", "=", "self", ".", "create_layout_params", "(", "child", ",", "layout", ")", "w", "=", "child", ".", "widget", "if", "w", ":", "# padding", "if", "layout", ".", "get", ...
Apply the flexbox specific layout.
[ "Apply", "the", "flexbox", "specific", "layout", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_flexbox.py#L174-L187
codelv/enaml-native
src/enamlnative/android/android_utils.py
InputMethodManager.toggle_keyboard
def toggle_keyboard(cls, flag=HIDE_IMPLICIT_ONLY): """ Toggle the keyboard on and off Parameters ---------- flag: int Flag to send to toggleSoftInput Returns -------- result: future Resolves when the togg...
python
def toggle_keyboard(cls, flag=HIDE_IMPLICIT_ONLY): """ Toggle the keyboard on and off Parameters ---------- flag: int Flag to send to toggleSoftInput Returns -------- result: future Resolves when the togg...
[ "def", "toggle_keyboard", "(", "cls", ",", "flag", "=", "HIDE_IMPLICIT_ONLY", ")", ":", "app", "=", "AndroidApplication", ".", "instance", "(", ")", "f", "=", "app", ".", "create_future", "(", ")", "def", "on_ready", "(", "ims", ")", ":", "ims", ".", "...
Toggle the keyboard on and off Parameters ---------- flag: int Flag to send to toggleSoftInput Returns -------- result: future Resolves when the toggle is complete
[ "Toggle", "the", "keyboard", "on", "and", "off", "Parameters", "----------", "flag", ":", "int", "Flag", "to", "send", "to", "toggleSoftInput", "Returns", "--------", "result", ":", "future", "Resolves", "when", "the", "toggle", "is", "complete" ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_utils.py#L56-L78