sentence1 stringlengths 52 3.87M | sentence2 stringlengths 1 47.2k | label stringclasses 1
value |
|---|---|---|
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... | 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. | entailment |
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) | Define the view frame for this widgets | entailment |
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... | 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. | entailment |
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) | Handle the child moved event from the declaration. | entailment |
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... | 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. | entailment |
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() | A reimplemented destructor.
This destructor will remove itself from the superview. | entailment |
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({}) | Add all child widgets to the view | entailment |
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... | Called by PyBridge.start() | entailment |
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... | Initialize the underlying widget. | entailment |
def create_widget(self):
""" Create the underlying widget.
"""
self.widget = ViewPager(self.get_context())
self.adapter = BridgedFragmentStatePagerAdapter() | Create the underlying widget. | entailment |
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) | When a child is added, schedule a data changed notification | entailment |
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(... | After all changes have settled, tell Java it changed | entailment |
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
... | 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. | entailment |
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,
... | Override as there is no (width, height) constructor. | entailment |
def create_widget(self):
""" Create the underlying widget.
"""
d = self.declaration
self.widget = CardView(self.get_context(), None, d.style) | Create the underlying widget. | entailment |
def create_widget(self):
""" Create the underlying widget.
"""
d = self.declaration
self.widget = TextClock(self.get_context(), None, d.style) | Create the underlying widget. | entailment |
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_... | Initialize the underlying widget. | entailment |
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
... | Create the underlying widget. | entailment |
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)
... | Initialize the underlying widget. | entailment |
def create_widget(self):
""" Create the underlying widget.
"""
d = self.declaration
self.widget = Flexbox(self.get_context(), None, d.style) | Create the underlying widget. | entailment |
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 ... | Apply the flexbox specific layout. | entailment |
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... | Toggle the keyboard on and off
Parameters
----------
flag: int
Flag to send to toggleSoftInput
Returns
--------
result: future
Resolves when the toggle is complete | entailment |
def hide_keyboard(cls):
""" Hide keyboard if it's open
Returns
--------
result: future
Resolves when the hide is complete
"""
app = AndroidApplication.instance()
f = app.create_future()
def on_ready(ims):
... | Hide keyboard if it's open
Returns
--------
result: future
Resolves when the hide is complete | entailment |
def get(cls):
""" Acquires the NotificationManager service async. """
app = AndroidApplication.instance()
f = app.create_future()
if cls._instance:
f.set_result(cls._instance)
return f
def on_service(obj_id):
#: Create the manager
... | Acquires the NotificationManager service async. | entailment |
def create_channel(cls, channel_id, name, importance=IMPORTANCE_DEFAULT,
description=""):
""" Before you can deliver the notification on Android 8.0 and higher,
you must register your app's notification channel with the system by
passing an instance of NotificationChanne... | Before you can deliver the notification on Android 8.0 and higher,
you must register your app's notification channel with the system by
passing an instance of NotificationChannel
to createNotificationChannel().
Parameters
----------
channel_id: String-
... | entailment |
def show_notification(cls, channel_id, *args, **kwargs):
""" Create and show a Notification. See `Notification.Builder.update`
for a list of accepted parameters.
"""
app = AndroidApplication.instance()
builder = Notification.Builder(app, channel_id)
builder.updat... | Create and show a Notification. See `Notification.Builder.update`
for a list of accepted parameters. | entailment |
def cancel_notification(cls, notification_or_id, tag=None):
""" Cancel the notification.
Parameters
----------
notification_or_id: Notification.Builder or int
The notification or id of a notification to clear
tag: String
The tag of the notificati... | Cancel the notification.
Parameters
----------
notification_or_id: Notification.Builder or int
The notification or id of a notification to clear
tag: String
The tag of the notification to clear | entailment |
def init_layout(self):
""" Create the notification in the top down pass if show = True
"""
d = self.declaration
self.create_notification()
if d.show:
self.set_show(d.show) | Create the notification in the top down pass if show = True | entailment |
def destroy(self):
""" A reimplemented destructor that cancels
the notification before destroying.
"""
builder = self.builder
NotificationManager.cancel_notification(builder)
del self.builder
super(AndroidNotification, self).destroy() | A reimplemented destructor that cancels
the notification before destroying. | entailment |
def create_notification(self):
""" Instead of the typical create_widget we use `create_notification`
because after it's closed it needs created again.
"""
d = self.declaration
builder = self.builder = Notification.Builder(self.get_context(),
... | Instead of the typical create_widget we use `create_notification`
because after it's closed it needs created again. | entailment |
def create_widget(self):
""" Create the toolkit widget for the proxy object.
"""
d = self.declaration
button_type = UIButton.UIButtonTypeSystem if d.flat else UIButton.UIButtonTypeRoundedRect
self.widget = UIButton(buttonWithType=button_type) | Create the toolkit widget for the proxy object. | entailment |
def initialize(self):
""" A reimplemented initializer.
This method will add the include objects to the parent of the
include and ensure that they are initialized.
"""
super(Block, self).initialize()
block = self.block
if block: #: This block is setting the con... | A reimplemented initializer.
This method will add the include objects to the parent of the
include and ensure that they are initialized. | entailment |
def _observe_block(self, change):
""" A change handler for the 'objects' list of the Include.
If the object is initialized objects which are removed will be
unparented and objects which are added will be reparented. Old
objects will be destroyed if the 'destroy_old' flag is True.
... | A change handler for the 'objects' list of the Include.
If the object is initialized objects which are removed will be
unparented and objects which are added will be reparented. Old
objects will be destroyed if the 'destroy_old' flag is True. | entailment |
def init_text(self):
""" Init text properties for this widget """
d = self.declaration
if d.text:
self.set_text(d.text)
if d.text_color:
self.set_text_color(d.text_color)
if d.text_alignment:
self.set_text_alignment(d.text_alignment)
if... | Init text properties for this widget | entailment |
def init_layout(self):
""" Add all child widgets to the view
"""
super(AndroidViewGroup, self).init_layout()
widget = self.widget
i = 0
for child in self.children():
child_widget = child.widget
if child_widget:
if child.layout_param... | Add all child widgets to the view | entailment |
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(AndroidViewGroup, self).child_added(child)
widget = se... | 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. | entailment |
def child_moved(self, child):
""" Handle the child moved event from the declaration.
"""
super(AndroidViewGroup, self).child_moved(child)
#: Remove and re-add in correct spot
self.child_removed(child)
self.child_added(child) | Handle the child moved event from the declaration. | entailment |
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(AndroidViewGroup, self).child_removed(child)
if chi... | 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. | entailment |
def create_widget(self):
""" Create the underlying widget.
"""
d = self.declaration
self.widget = TimePicker(self.get_context(), None,
d.style or '@attr/timePickerStyle') | Create the underlying widget. | entailment |
def init_widget(self):
""" Initialize the underlying widget.
"""
super(AndroidTimePicker, self).init_widget()
d = self.declaration
w = self.widget
self.set_hour(d.hour)
self.set_minute(d.minute)
self.set_hour_mode(d.hour_mode)
w.setOnTimeChangedL... | Initialize the underlying widget. | entailment |
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:
parent = self.parent_widget()
if parent is not None:
... | A reimplemented destructor.
This destructor will clear the reference to the toolkit widget
and set its parent to None. | entailment |
def create_widget(self):
""" Create the underlying widget.
"""
d = self.declaration
self.widget = ToggleButton(self.get_context(), None,
d.style or "@attr/buttonStyleToggle") | Create the underlying widget. | entailment |
def init_widget(self):
""" Bind the on property to the checked state """
super(UiKitSwitch, self).init_widget()
d = self.declaration
if d.checked:
self.set_checked(d.checked)
#: Watch the on property for change
#: So apparently UISwitch is not KVO compliant.... | Bind the on property to the checked state | entailment |
def on_checked_changed(self, on):
""" See https://stackoverflow.com/questions/19628310/ """
#: Since iOS decides to call this like 100 times for each defer it
d = self.declaration
with self.widget.setOn.suppressed():
d.checked = on | See https://stackoverflow.com/questions/19628310/ | entailment |
def create_widget(self):
""" Create the underlying widget.
"""
d = self.declaration
self.widget = Chronometer(self.get_context(), None, d.style) | Create the underlying widget. | entailment |
def init_widget(self):
""" Initialize the underlying widget.
"""
super(AndroidChronometer, self).init_widget()
w = self.widget
w.setOnChronometerTickListener(w.getId())
w.onChronometerTick.connect(self.on_chronometer_tick) | Initialize the underlying widget. | entailment |
def update_function(old, new):
"""Upgrade the code object of a function"""
for name in func_attrs:
try:
setattr(old, name, getattr(new, name))
except (AttributeError, TypeError):
pass | Upgrade the code object of a function | entailment |
def update_property(old, new):
"""Replace get/set/del functions of a property"""
update_generic(old.fdel, new.fdel)
update_generic(old.fget, new.fget)
update_generic(old.fset, new.fset) | Replace get/set/del functions of a property | entailment |
def superreload(module, reload=reload, old_objects={}):
"""Enhanced version of the builtin reload function.
superreload remembers objects previously in the module, and
- upgrades the class dictionary of every old class in the module
- upgrades the code object of every old function and method
- cle... | Enhanced version of the builtin reload function.
superreload remembers objects previously in the module, and
- upgrades the class dictionary of every old class in the module
- upgrades the code object of every old function and method
- clears the module's namespace before reloading | entailment |
def mark_module_skipped(self, module_name):
"""Skip reloading the named module in the future"""
try:
del self.modules[module_name]
except KeyError:
pass
self.skip_modules[module_name] = True | Skip reloading the named module in the future | entailment |
def mark_module_reloadable(self, module_name):
"""Reload the named module in the future (if it is imported)"""
try:
del self.skip_modules[module_name]
except KeyError:
pass
self.modules[module_name] = True | Reload the named module in the future (if it is imported) | entailment |
def aimport_module(self, module_name):
"""Import a module, and mark it reloadable
Returns
-------
top_module : module
The imported module if it is top-level, or the top-level
top_name : module
Name of top_module
"""
self.mark_module_reloa... | Import a module, and mark it reloadable
Returns
-------
top_module : module
The imported module if it is top-level, or the top-level
top_name : module
Name of top_module | entailment |
def check(self, check_all=False, do_reload=True):
"""Check whether some modules need to be reloaded."""
if not self.enabled and not check_all:
return
if check_all or self.check_all:
modules = list(sys.modules.keys())
else:
modules = list(self.modules... | Check whether some modules need to be reloaded. | entailment |
def autoreload(self, parameter_s=''):
r"""%autoreload => Reload modules automatically
%autoreload
Reload all modules (except those excluded by %aimport) automatically
now.
%autoreload 0
Disable automatic reloading.
%autoreload 1
Reload all modules impor... | r"""%autoreload => Reload modules automatically
%autoreload
Reload all modules (except those excluded by %aimport) automatically
now.
%autoreload 0
Disable automatic reloading.
%autoreload 1
Reload all modules imported with %aimport every time before executing
... | entailment |
def aimport(self, parameter_s='', stream=None):
"""%aimport => Import modules for automatic reloading.
%aimport
List modules to automatically import and not to import.
%aimport foo
Import module 'foo' and mark it to be autoreloaded for %autoreload 1
%aimport foo, bar
... | %aimport => Import modules for automatic reloading.
%aimport
List modules to automatically import and not to import.
%aimport foo
Import module 'foo' and mark it to be autoreloaded for %autoreload 1
%aimport foo, bar
Import modules 'foo', 'bar' and mark them to be auto... | entailment |
def post_execute(self):
"""Cache the modification times of any modules imported in this execution
"""
newly_loaded_modules = set(sys.modules) - self.loaded_modules
for modname in newly_loaded_modules:
_, pymtime = self._reloader.filename_and_mtime(sys.modules[modname])
... | Cache the modification times of any modules imported in this execution | entailment |
def create_widget(self):
""" Create the underlying widget.
"""
d = self.declaration
self.widget = EditText(self.get_context(), None,
d.style or "@attr/editTextStyle") | Create the underlying widget. | entailment |
def create_widget(self):
""" Create the underlying widget.
"""
d = self.declaration
style = d.style if d.style else (
'@attr/borderlessButtonStyle' if d.flat else '@attr/buttonStyle')
self.widget = Button(self.get_context(), None, style) | Create the underlying widget. | entailment |
def create_widget(self):
""" Create the underlying widget.
"""
d = self.declaration
self.widget = FloatingActionButton(self.get_context(), None, d.style) | Create the underlying widget. | entailment |
def create_widget(self):
""" Create the underlying widget.
"""
d = self.declaration
self.widget = Picker(self.get_context(), None,
d.style or '@attr/numberPickerStyle') | Create the underlying widget. | entailment |
def init_widget(self):
""" Set the checked state after all children have
been populated.
"""
super(AndroidPicker, self).init_widget()
d = self.declaration
w = self.widget
if d.items:
self.set_items(d.items)
else:
if d.max_v... | Set the checked state after all children have
been populated. | entailment |
def on_value_change(self, picker, old, new):
""" Set the checked property based on the checked state
of all the children
"""
d = self.declaration
with self.widget.setValue.suppressed():
d.value = new | Set the checked property based on the checked state
of all the children | entailment |
def create_widget(self):
""" Create the underlying label widget.
"""
d = self.declaration
mode = 1 if d.mode == 'dropdown' else 0
self.widget = Spinner(self.get_context(), mode)
# Create the adapter simple_spinner_item = 0x01090008
self.adapter = ArrayAdapter(se... | Create the underlying label widget. | entailment |
def init_widget(self):
""" Initialize the underlying widget.
"""
w = self.widget
# Selection listener
w.setAdapter(self.adapter)
w.setOnItemSelectedListener(w.getId())
w.onItemSelected.connect(self.on_item_selected)
w.onNothingSelected.connect(self.on_not... | Initialize the underlying widget. | entailment |
def set_items(self, items):
""" Generate the view cache
"""
self.adapter.clear()
self.adapter.addAll(items) | Generate the view cache | entailment |
def _default_objc(self):
""" Load the objc library using ctypes. """
objc = ctypes.cdll.LoadLibrary(find_library('objc'))
objc.objc_getClass.restype = ctypes.c_void_p
objc.sel_registerName.restype = ctypes.c_void_p
objc.objc_msgSend.restype = ctypes.c_void_p
objc.objc_msg... | Load the objc library using ctypes. | entailment |
def _default_bridge(self):
""" Get an instance of the ENBridge object using ctypes. """
objc = self.objc
ENBridge = objc.objc_getClass('ENBridge')
return objc.objc_msgSend(ENBridge, objc.sel_registerName('instance')) | Get an instance of the ENBridge object using ctypes. | entailment |
def processEvents(self, data):
""" Sends msgpack data to the ENBridge instance
by calling the processEvents method via ctypes. """
objc = self.objc
bridge = self.bridge
#: This must come after the above as it changes the arguments!
objc.objc_msgSend.argtypes = [ctypes... | Sends msgpack data to the ENBridge instance
by calling the processEvents method via ctypes. | entailment |
def _update_proxy(self, change):
""" An observer which sends the state change to the proxy.
"""
if change['type'] == 'event' and self.proxy_is_active:
self.proxy.set_opened(change['name'] == 'show')
else:
super(ActionMenuView, self)._update_proxy(change) | An observer which sends the state change to the proxy. | entailment |
def current(instance=True):
"""Returns the current thread's `IOLoop`.
If an `IOLoop` is currently running or has been marked as
current by `make_current`, returns that instance. If there is
no current `IOLoop` and ``instance`` is true, creates one.
.. versionchanged:: 4.1
... | Returns the current thread's `IOLoop`.
If an `IOLoop` is currently running or has been marked as
current by `make_current`, returns that instance. If there is
no current `IOLoop` and ``instance`` is true, creates one.
.. versionchanged:: 4.1
Added ``instance`` argument to c... | entailment |
def log_stack(self, signal, frame):
"""Signal handler to log the stack trace of the current thread.
For use with `set_blocking_signal_threshold`.
"""
gen_log.warning('IOLoop blocked for %f seconds in\n%s',
self._blocking_signal_threshold,
... | Signal handler to log the stack trace of the current thread.
For use with `set_blocking_signal_threshold`. | entailment |
def run_sync(self, func, timeout=None):
"""Starts the `IOLoop`, runs the given function, and stops the loop.
The function must return either a yieldable object or
``None``. If the function returns a yieldable object, the
`IOLoop` will run until the yieldable is resolved (and
`ru... | Starts the `IOLoop`, runs the given function, and stops the loop.
The function must return either a yieldable object or
``None``. If the function returns a yieldable object, the
`IOLoop` will run until the yieldable is resolved (and
`run_sync()` will return the yieldable's result). If i... | entailment |
def add_timeout(self, deadline, callback, *args, **kwargs):
"""Runs the ``callback`` at the time ``deadline`` from the I/O loop.
Returns an opaque handle that may be passed to
`remove_timeout` to cancel.
``deadline`` may be a number denoting a time (on the same
scale as `IOLoop... | Runs the ``callback`` at the time ``deadline`` from the I/O loop.
Returns an opaque handle that may be passed to
`remove_timeout` to cancel.
``deadline`` may be a number denoting a time (on the same
scale as `IOLoop.time`, normally `time.time`), or a
`datetime.timedelta` object... | entailment |
def call_later(self, delay, callback, *args, **kwargs):
"""Runs the ``callback`` after ``delay`` seconds have passed.
Returns an opaque handle that may be passed to `remove_timeout`
to cancel. Note that unlike the `asyncio` method of the same
name, the returned object does not have a `... | Runs the ``callback`` after ``delay`` seconds have passed.
Returns an opaque handle that may be passed to `remove_timeout`
to cancel. Note that unlike the `asyncio` method of the same
name, the returned object does not have a ``cancel()`` method.
See `add_timeout` for comments on thre... | entailment |
def call_at(self, when, callback, *args, **kwargs):
"""Runs the ``callback`` at the absolute time designated by ``when``.
``when`` must be a number using the same reference point as
`IOLoop.time`.
Returns an opaque handle that may be passed to `remove_timeout`
to cancel. Note ... | Runs the ``callback`` at the absolute time designated by ``when``.
``when`` must be a number using the same reference point as
`IOLoop.time`.
Returns an opaque handle that may be passed to `remove_timeout`
to cancel. Note that unlike the `asyncio` method of the same
name, the ... | entailment |
def spawn_callback(self, callback, *args, **kwargs):
"""Calls the given callback on the next IOLoop iteration.
Unlike all other callback-related methods on IOLoop,
``spawn_callback`` does not associate the callback with its caller's
``stack_context``, so it is suitable for fire-and-forg... | Calls the given callback on the next IOLoop iteration.
Unlike all other callback-related methods on IOLoop,
``spawn_callback`` does not associate the callback with its caller's
``stack_context``, so it is suitable for fire-and-forget callbacks
that should not interfere with the caller.
... | entailment |
def add_future(self, future, callback):
"""Schedules a callback on the ``IOLoop`` when the given
`.Future` is finished.
The callback is invoked with one argument, the
`.Future`.
"""
assert is_future(future)
callback = stack_context.wrap(callback)
future.a... | Schedules a callback on the ``IOLoop`` when the given
`.Future` is finished.
The callback is invoked with one argument, the
`.Future`. | entailment |
def _run_callback(self, callback):
"""Runs a callback with error handling.
For use in subclasses.
"""
try:
ret = callback()
if ret is not None:
from . import gen
# Functions that return Futures typically swallow all
... | Runs a callback with error handling.
For use in subclasses. | entailment |
def handle_callback_exception(self, callback):
"""This method is called whenever a callback run by the `IOLoop`
throws an exception.
By default simply logs the exception as an error. Subclasses
may override this method to customize reporting of exceptions.
The exception itself... | This method is called whenever a callback run by the `IOLoop`
throws an exception.
By default simply logs the exception as an error. Subclasses
may override this method to customize reporting of exceptions.
The exception itself is not passed explicitly, but is available
in `sy... | entailment |
def close_fd(self, fd):
"""Utility method to close an ``fd``.
If ``fd`` is a file-like object, we close it directly; otherwise
we use `os.close`.
This method is provided for use by `IOLoop` subclasses (in
implementations of ``IOLoop.close(all_fds=True)`` and should
not ... | Utility method to close an ``fd``.
If ``fd`` is a file-like object, we close it directly; otherwise
we use `os.close`.
This method is provided for use by `IOLoop` subclasses (in
implementations of ``IOLoop.close(all_fds=True)`` and should
not generally be used by application co... | entailment |
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.
Note: This does ... | 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.
Note: This does NOT initialize text properties by d... | entailment |
def create_widget(self):
""" Create the underlying widget.
A toast is not a subclass of view, hence we don't set name as widget
or children will try to use it as their parent (which crashes).
"""
d = self.declaration
Snackbar.make(self.parent_widget(), d.text,
... | Create the underlying widget.
A toast is not a subclass of view, hence we don't set name as widget
or children will try to use it as their parent (which crashes). | entailment |
def init_widget(self):
""" Our widget may not exist yet so we have to diverge from the normal
way of doing initialization. See `update_widget`
"""
if not self.widget:
return
super(AndroidSnackbar, self).init_widget()
d = self.declaration
#:... | Our widget may not exist yet so we have to diverge from the normal
way of doing initialization. See `update_widget` | entailment |
def on_widget_created(self, ref):
""" Using Snackbar.make returns async so we have to
initialize it later.
"""
d = self.declaration
self.widget = Snackbar(__id__=ref)
self.init_widget() | Using Snackbar.make returns async so we have to
initialize it later. | entailment |
def set_duration(self, duration):
""" Android for whatever stupid reason doesn't let you set the time
it only allows 1-long or 0-short. So we have to repeatedly call show
until the duration expires, hence this method does nothing see
`set_show`.
"""
if duration ... | Android for whatever stupid reason doesn't let you set the time
it only allows 1-long or 0-short. So we have to repeatedly call show
until the duration expires, hence this method does nothing see
`set_show`. | entailment |
def create_widget(self):
""" Create the underlying widget.
"""
d = self.declaration
self.widget = SeekBar(self.get_context(), None,
d.style or '@attr/seekBarStyle') | Create the underlying widget. | entailment |
def init_widget(self):
""" Initialize the underlying widget.
"""
super(AndroidSeekBar, self).init_widget()
w = self.widget
#: Setup listener
w.setOnSeekBarChangeListener(w.getId())
w.onProgressChanged.connect(self.on_progress_changed) | Initialize the underlying widget. | entailment |
def create_widget(self):
""" Create the underlying widget.
"""
d = self.declaration
self.widget = TextView(self.get_context(), None,
d.style or '@attr/textViewStyle') | Create the underlying widget. | entailment |
def init_widget(self):
""" Initialize the underlying widget.
"""
super(AndroidTextView, self).init_widget()
d = self.declaration
w = self.widget
if d.input_type:
self.set_input_type(d.input_type)
w.addTextChangedListener(w.getId())
w.o... | Initialize the underlying widget. | entailment |
def set_text(self, text):
""" Set the text in the widget.
"""
d = self.declaration
if d.input_type == 'html':
text = Spanned(__id__=Html.fromHtml(text))
self.widget.setTextKeepState(text) | Set the text in the widget. | entailment |
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
self.dialog = BottomSheetDialog(self.get_context(), d.style) | 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. | entailment |
def encode(obj):
""" Encode an object for proper decoding by Java or ObjC
"""
if hasattr(obj, '__id__'):
return msgpack.ExtType(ExtType.REF, msgpack.packb(obj.__id__))
return obj | Encode an object for proper decoding by Java or ObjC | entailment |
def get_handler(ptr, method):
""" Dereference the pointer and return the handler method. """
obj = CACHE.get(ptr, None)
if obj is None:
raise BridgeReferenceError(
"Reference id={} never existed or has already been destroyed"
.format(ptr))
elif not hasattr(obj, method):
... | Dereference the pointer and return the handler method. | entailment |
def suppressed(self, obj):
""" Suppress calls within this context to avoid feedback loops"""
obj.__suppressed__[self.name] = True
yield
obj.__suppressed__[self.name] = False | Suppress calls within this context to avoid feedback loops | entailment |
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... | 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. | entailment |
def is_wifi_enabled(cls):
""" Check if wifi is currently enabled.
Returns
--------
result: future
A future that resolves with the value.
"""
app = AndroidApplication.instance()
f = app.create_future()
def on_permission_result(r... | Check if wifi is currently enabled.
Returns
--------
result: future
A future that resolves with the value. | entailment |
def set_wifi_enabled(cls, state=True):
""" Set the wifi enabled state.
Returns
--------
result: future
A future that resolves with whether the operation succeeded.
"""
app = AndroidApplication.instance()
f = app.create_future()
... | Set the wifi enabled state.
Returns
--------
result: future
A future that resolves with whether the operation succeeded. | entailment |
def get_networks(cls):
""" Get the wifi networks currently available.
Returns
--------
result: future
A future that resolves with the list of networks available
or None if wifi could not be enabled (permission denied,
etc...)
... | Get the wifi networks currently available.
Returns
--------
result: future
A future that resolves with the list of networks available
or None if wifi could not be enabled (permission denied,
etc...) | entailment |
def disconnect(cls):
""" Disconnect from the current network (if connected).
Returns
--------
result: future
A future that resolves to true if the disconnect was
successful. Will be set to None if the change network
pe... | Disconnect from the current network (if connected).
Returns
--------
result: future
A future that resolves to true if the disconnect was
successful. Will be set to None if the change network
permission is denied. | entailment |
def connect(cls, ssid, key=None, **kwargs):
""" Connect to the given ssid using the key (if given).
Returns
--------
result: future
A future that resolves with the result of the connect
"""
app = AndroidApplication.instance()
f = app.... | Connect to the given ssid using the key (if given).
Returns
--------
result: future
A future that resolves with the result of the connect | entailment |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.