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
codelv/enaml-native
src/enamlnative/ios/uikit_view_group.py
UiKitViewGroup.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) layout = self.layo...
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) layout = self.layo...
[ "def", "child_added", "(", "self", ",", "child", ")", ":", "super", "(", "UiKitView", ",", "self", ")", ".", "child_added", "(", "child", ")", "layout", "=", "self", ".", "layout", "for", "i", ",", "child_widget", "in", "enumerate", "(", "self", ".", ...
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_group.py#L80-L93
codelv/enaml-native
src/enamlnative/ios/uikit_view_group.py
UiKitViewGroup.child_removed
def child_removed(self, child): """ Handle the child removed event from the declaration. The child must be both removed from the arrangement and removed normally. """ layout = self.layout if child.widget is not None: layout.removeArrangedSubview(child.widge...
python
def child_removed(self, child): """ Handle the child removed event from the declaration. The child must be both removed from the arrangement and removed normally. """ layout = self.layout if child.widget is not None: layout.removeArrangedSubview(child.widge...
[ "def", "child_removed", "(", "self", ",", "child", ")", ":", "layout", "=", "self", ".", "layout", "if", "child", ".", "widget", "is", "not", "None", ":", "layout", ".", "removeArrangedSubview", "(", "child", ".", "widget", ")", "layout", ".", "removeSub...
Handle the child removed event from the declaration. The child must be both removed from the arrangement and removed normally.
[ "Handle", "the", "child", "removed", "event", "from", "the", "declaration", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/ios/uikit_view_group.py#L95-L105
codelv/enaml-native
src/enamlnative/ios/uikit_view_group.py
UiKitViewGroup.destroy
def destroy(self): """ A reimplemented destructor that destroys the layout widget. """ layout = self.layout if layout is not None: layout.removeFromSuperview() self.layout = None super(UiKitViewGroup, self).destroy()
python
def destroy(self): """ A reimplemented destructor that destroys the layout widget. """ layout = self.layout if layout is not None: layout.removeFromSuperview() self.layout = None super(UiKitViewGroup, self).destroy()
[ "def", "destroy", "(", "self", ")", ":", "layout", "=", "self", ".", "layout", "if", "layout", "is", "not", "None", ":", "layout", ".", "removeFromSuperview", "(", ")", "self", ".", "layout", "=", "None", "super", "(", "UiKitViewGroup", ",", "self", ")...
A reimplemented destructor that destroys the layout widget.
[ "A", "reimplemented", "destructor", "that", "destroys", "the", "layout", "widget", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/ios/uikit_view_group.py#L108-L116
codelv/enaml-native
src/enamlnative/ios/bridge.py
ObjcMethod.pack_args
def pack_args(self, obj, *args, **kwargs): """ Arguments must be packed according to the kwargs passed and the signature defined. """ signature = self.__signature__ #: No arguments expected if not signature: return (self.name, []) #: Build args, firs...
python
def pack_args(self, obj, *args, **kwargs): """ Arguments must be packed according to the kwargs passed and the signature defined. """ signature = self.__signature__ #: No arguments expected if not signature: return (self.name, []) #: Build args, firs...
[ "def", "pack_args", "(", "self", ",", "obj", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "signature", "=", "self", ".", "__signature__", "#: No arguments expected", "if", "not", "signature", ":", "return", "(", "self", ".", "name", ",", "[", "...
Arguments must be packed according to the kwargs passed and the signature defined.
[ "Arguments", "must", "be", "packed", "according", "to", "the", "kwargs", "passed", "and", "the", "signature", "defined", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/ios/bridge.py#L59-L91
codelv/enaml-native
src/enamlnative/android/android_rating_bar.py
AndroidRatingBar.create_widget
def create_widget(self): """ Create the underlying widget. """ d = self.declaration self.widget = RatingBar(self.get_context(), None, d.style or '@attr/ratingBarStyle')
python
def create_widget(self): """ Create the underlying widget. """ d = self.declaration self.widget = RatingBar(self.get_context(), None, d.style or '@attr/ratingBarStyle')
[ "def", "create_widget", "(", "self", ")", ":", "d", "=", "self", ".", "declaration", "self", ".", "widget", "=", "RatingBar", "(", "self", ".", "get_context", "(", ")", ",", "None", ",", "d", ".", "style", "or", "'@attr/ratingBarStyle'", ")" ]
Create the underlying widget.
[ "Create", "the", "underlying", "widget", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_rating_bar.py#L48-L54
codelv/enaml-native
src/enamlnative/android/android_rating_bar.py
AndroidRatingBar.init_widget
def init_widget(self): """ Initialize the underlying widget. """ super(AndroidRatingBar, self).init_widget() d = self.declaration self.set_rating(d.rating) w = self.widget w.setOnRatingBarChangeListener(w.getId()) w.onRatingChanged.connect(self.on_rating_...
python
def init_widget(self): """ Initialize the underlying widget. """ super(AndroidRatingBar, self).init_widget() d = self.declaration self.set_rating(d.rating) w = self.widget w.setOnRatingBarChangeListener(w.getId()) w.onRatingChanged.connect(self.on_rating_...
[ "def", "init_widget", "(", "self", ")", ":", "super", "(", "AndroidRatingBar", ",", "self", ")", ".", "init_widget", "(", ")", "d", "=", "self", ".", "declaration", "self", ".", "set_rating", "(", "d", ".", "rating", ")", "w", "=", "self", ".", "widg...
Initialize the underlying widget.
[ "Initialize", "the", "underlying", "widget", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_rating_bar.py#L56-L65
codelv/enaml-native
src/enamlnative/android/android_linear_layout.py
AndroidLinearLayout.create_widget
def create_widget(self): """ Create the underlying widget. """ d = self.declaration self.widget = LinearLayout(self.get_context(), None, d.style)
python
def create_widget(self): """ Create the underlying widget. """ d = self.declaration self.widget = LinearLayout(self.get_context(), None, d.style)
[ "def", "create_widget", "(", "self", ")", ":", "d", "=", "self", ".", "declaration", "self", ".", "widget", "=", "LinearLayout", "(", "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_linear_layout.py#L45-L50
codelv/enaml-native
src/enamlnative/android/android_frame_layout.py
AndroidFrameLayout.create_widget
def create_widget(self): """ Create the underlying widget. """ d = self.declaration self.widget = FrameLayout(self.get_context(), None, d.style)
python
def create_widget(self): """ Create the underlying widget. """ d = self.declaration self.widget = FrameLayout(self.get_context(), None, d.style)
[ "def", "create_widget", "(", "self", ")", ":", "d", "=", "self", ".", "declaration", "self", ".", "widget", "=", "FrameLayout", "(", "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_frame_layout.py#L47-L52
codelv/enaml-native
src/enamlnative/android/android_auto_complete_text_view.py
AndroidAutoCompleteTextView.create_widget
def create_widget(self): """ Create the underlying widget. """ context = self.get_context() d = self.declaration style = d.style or '@attr/autoCompleteTextViewStyle' self.widget = AutoCompleteTextView(context, None, style) self.adapter = ArrayAdapter(context, '@l...
python
def create_widget(self): """ Create the underlying widget. """ context = self.get_context() d = self.declaration style = d.style or '@attr/autoCompleteTextViewStyle' self.widget = AutoCompleteTextView(context, None, style) self.adapter = ArrayAdapter(context, '@l...
[ "def", "create_widget", "(", "self", ")", ":", "context", "=", "self", ".", "get_context", "(", ")", "d", "=", "self", ".", "declaration", "style", "=", "d", ".", "style", "or", "'@attr/autoCompleteTextViewStyle'", "self", ".", "widget", "=", "AutoCompleteTe...
Create the underlying widget.
[ "Create", "the", "underlying", "widget", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_auto_complete_text_view.py#L43-L51
codelv/enaml-native
src/enamlnative/android/android_auto_complete_text_view.py
AndroidAutoCompleteTextView.init_widget
def init_widget(self): """ Initialize the underlying widget. """ super(AndroidAutoCompleteTextView, self).init_widget() self.widget.setAdapter(self.adapter)
python
def init_widget(self): """ Initialize the underlying widget. """ super(AndroidAutoCompleteTextView, self).init_widget() self.widget.setAdapter(self.adapter)
[ "def", "init_widget", "(", "self", ")", ":", "super", "(", "AndroidAutoCompleteTextView", ",", "self", ")", ".", "init_widget", "(", ")", "self", ".", "widget", ".", "setAdapter", "(", "self", ".", "adapter", ")" ]
Initialize the underlying widget.
[ "Initialize", "the", "underlying", "widget", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_auto_complete_text_view.py#L53-L58
codelv/enaml-native
src/enamlnative/android/android_iconify.py
AndroidIcon.create_widget
def create_widget(self): """ Create the underlying widget. """ d = self.declaration self.widget = Icon(self.get_context(), None, d.style)
python
def create_widget(self): """ Create the underlying widget. """ d = self.declaration self.widget = Icon(self.get_context(), None, d.style)
[ "def", "create_widget", "(", "self", ")", ":", "d", "=", "self", ".", "declaration", "self", ".", "widget", "=", "Icon", "(", "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_iconify.py#L53-L58
codelv/enaml-native
src/enamlnative/core/eventloop/stack_context.py
_remove_deactivated
def _remove_deactivated(contexts): """Remove deactivated handlers from the chain""" # Clean ctx handlers stack_contexts = tuple([h for h in contexts[0] if h.active]) # Find new head head = contexts[1] while head is not None and not head.active: head = head.old_contexts[1] # Process...
python
def _remove_deactivated(contexts): """Remove deactivated handlers from the chain""" # Clean ctx handlers stack_contexts = tuple([h for h in contexts[0] if h.active]) # Find new head head = contexts[1] while head is not None and not head.active: head = head.old_contexts[1] # Process...
[ "def", "_remove_deactivated", "(", "contexts", ")", ":", "# Clean ctx handlers", "stack_contexts", "=", "tuple", "(", "[", "h", "for", "h", "in", "contexts", "[", "0", "]", "if", "h", ".", "active", "]", ")", "# Find new head", "head", "=", "contexts", "["...
Remove deactivated handlers from the chain
[ "Remove", "deactivated", "handlers", "from", "the", "chain" ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/eventloop/stack_context.py#L246-L269
codelv/enaml-native
src/enamlnative/core/eventloop/stack_context.py
wrap
def wrap(fn): """Returns a callable object that will restore the current `StackContext` when executed. Use this whenever saving a callback to be executed later in a different execution context (either in a different thread or asynchronously in the same thread). """ # Check if function is al...
python
def wrap(fn): """Returns a callable object that will restore the current `StackContext` when executed. Use this whenever saving a callback to be executed later in a different execution context (either in a different thread or asynchronously in the same thread). """ # Check if function is al...
[ "def", "wrap", "(", "fn", ")", ":", "# Check if function is already wrapped", "if", "fn", "is", "None", "or", "hasattr", "(", "fn", ",", "'_wrapped'", ")", ":", "return", "fn", "# Capture current stack head", "# TODO: Any other better way to store contexts and update them...
Returns a callable object that will restore the current `StackContext` when executed. Use this whenever saving a callback to be executed later in a different execution context (either in a different thread or asynchronously in the same thread).
[ "Returns", "a", "callable", "object", "that", "will", "restore", "the", "current", "StackContext", "when", "executed", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/eventloop/stack_context.py#L272-L368
codelv/enaml-native
src/enamlnative/android/android_sensors.py
Sensor.get
def get(cls, sensor_type): """ Shortcut that acquires the default Sensor of a given type. Parameters ---------- sensor_type: int Type of sensor to get. Returns ------- result: Future A future that resolve...
python
def get(cls, sensor_type): """ Shortcut that acquires the default Sensor of a given type. Parameters ---------- sensor_type: int Type of sensor to get. Returns ------- result: Future A future that resolve...
[ "def", "get", "(", "cls", ",", "sensor_type", ")", ":", "app", "=", "AndroidApplication", ".", "instance", "(", ")", "f", "=", "app", ".", "create_future", "(", ")", "def", "on_sensor", "(", "sid", ",", "mgr", ")", ":", "if", "sid", "is", "None", "...
Shortcut that acquires the default Sensor of a given type. Parameters ---------- sensor_type: int Type of sensor to get. Returns ------- result: Future A future that resolves to an instance of the Sensor or None ...
[ "Shortcut", "that", "acquires", "the", "default", "Sensor", "of", "a", "given", "type", ".", "Parameters", "----------", "sensor_type", ":", "int", "Type", "of", "sensor", "to", "get", ".", "Returns", "-------", "result", ":", "Future", "A", "future", "that"...
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_sensors.py#L101-L129
codelv/enaml-native
src/enamlnative/android/android_sensors.py
Sensor.start
def start(self, callback, rate=SENSOR_DELAY_NORMAL): """ Start listening to sensor events. Sensor event data depends on the type of sensor that was given to Parameters ---------- callback: Callable A callback that takes one argument that will be pass...
python
def start(self, callback, rate=SENSOR_DELAY_NORMAL): """ Start listening to sensor events. Sensor event data depends on the type of sensor that was given to Parameters ---------- callback: Callable A callback that takes one argument that will be pass...
[ "def", "start", "(", "self", ",", "callback", ",", "rate", "=", "SENSOR_DELAY_NORMAL", ")", ":", "if", "not", "self", ".", "manager", ":", "raise", "RuntimeError", "(", "\"Cannot start a sensor without a SensorManager!\"", ")", "self", ".", "onSensorChanged", ".",...
Start listening to sensor events. Sensor event data depends on the type of sensor that was given to Parameters ---------- callback: Callable A callback that takes one argument that will be passed the sensor data. Sensor data is a dict with da...
[ "Start", "listening", "to", "sensor", "events", ".", "Sensor", "event", "data", "depends", "on", "the", "type", "of", "sensor", "that", "was", "given", "to", "Parameters", "----------", "callback", ":", "Callable", "A", "callback", "that", "takes", "one", "a...
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_sensors.py#L131-L155
codelv/enaml-native
src/enamlnative/android/android_list_view.py
AndroidListView.init_widget
def init_widget(self): """ Initialize the underlying widget. """ super(AndroidListView, self).init_widget() d = self.declaration self.set_arrangement(d.arrangement)
python
def init_widget(self): """ Initialize the underlying widget. """ super(AndroidListView, self).init_widget() d = self.declaration self.set_arrangement(d.arrangement)
[ "def", "init_widget", "(", "self", ")", ":", "super", "(", "AndroidListView", ",", "self", ")", ".", "init_widget", "(", ")", "d", "=", "self", ".", "declaration", "self", ".", "set_arrangement", "(", "d", ".", "arrangement", ")" ]
Initialize the underlying widget.
[ "Initialize", "the", "underlying", "widget", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_list_view.py#L180-L186
codelv/enaml-native
src/enamlnative/android/android_list_view.py
AndroidListView.get_declared_items
def get_declared_items(self): """ Override to do it manually """ for k, v in super(AndroidListView, self).get_declared_items(): if k == 'layout': yield k, v break
python
def get_declared_items(self): """ Override to do it manually """ for k, v in super(AndroidListView, self).get_declared_items(): if k == 'layout': yield k, v break
[ "def", "get_declared_items", "(", "self", ")", ":", "for", "k", ",", "v", "in", "super", "(", "AndroidListView", ",", "self", ")", ".", "get_declared_items", "(", ")", ":", "if", "k", "==", "'layout'", ":", "yield", "k", ",", "v", "break" ]
Override to do it manually
[ "Override", "to", "do", "it", "manually" ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_list_view.py#L201-L208
codelv/enaml-native
src/enamlnative/android/android_list_view.py
AndroidListView.init_layout
def init_layout(self): """ Initialize the underlying widget. """ super(AndroidListView, self).init_layout() d = self.declaration w = self.widget # Prepare adapter adapter = self.adapter = BridgedRecyclerAdapter(w) # I'm sure this will make someone upset...
python
def init_layout(self): """ Initialize the underlying widget. """ super(AndroidListView, self).init_layout() d = self.declaration w = self.widget # Prepare adapter adapter = self.adapter = BridgedRecyclerAdapter(w) # I'm sure this will make someone upset...
[ "def", "init_layout", "(", "self", ")", ":", "super", "(", "AndroidListView", ",", "self", ")", ".", "init_layout", "(", ")", "d", "=", "self", ".", "declaration", "w", "=", "self", ".", "widget", "# Prepare adapter", "adapter", "=", "self", ".", "adapte...
Initialize the underlying widget.
[ "Initialize", "the", "underlying", "widget", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_list_view.py#L210-L229
codelv/enaml-native
src/enamlnative/android/android_list_view.py
AndroidListView.on_recycle_view
def on_recycle_view(self, index, position): """ Update the item the view at the given index should display """ item = self.list_items[index] self.item_mapping[position] = item item.recycle_view(position)
python
def on_recycle_view(self, index, position): """ Update the item the view at the given index should display """ item = self.list_items[index] self.item_mapping[position] = item item.recycle_view(position)
[ "def", "on_recycle_view", "(", "self", ",", "index", ",", "position", ")", ":", "item", "=", "self", ".", "list_items", "[", "index", "]", "self", ".", "item_mapping", "[", "position", "]", "=", "item", "item", ".", "recycle_view", "(", "position", ")" ]
Update the item the view at the given index should display
[ "Update", "the", "item", "the", "view", "at", "the", "given", "index", "should", "display" ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_list_view.py#L234-L239
codelv/enaml-native
src/enamlnative/android/android_list_view.py
AndroidListView.refresh_views
def refresh_views(self, change=None): """ Set the views that the adapter will cycle through. """ adapter = self.adapter # Set initial ListItem state item_mapping = self.item_mapping for i, item in enumerate(self.list_items): item_mapping[i] = item item.re...
python
def refresh_views(self, change=None): """ Set the views that the adapter will cycle through. """ adapter = self.adapter # Set initial ListItem state item_mapping = self.item_mapping for i, item in enumerate(self.list_items): item_mapping[i] = item item.re...
[ "def", "refresh_views", "(", "self", ",", "change", "=", "None", ")", ":", "adapter", "=", "self", ".", "adapter", "# Set initial ListItem state", "item_mapping", "=", "self", ".", "item_mapping", "for", "i", ",", "item", "in", "enumerate", "(", "self", ".",...
Set the views that the adapter will cycle through.
[ "Set", "the", "views", "that", "the", "adapter", "will", "cycle", "through", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_list_view.py#L247-L260
codelv/enaml-native
src/enamlnative/android/android_list_view.py
AndroidListView._on_items_changed
def _on_items_changed(self, change): """ Observe container events on the items list and update the adapter appropriately. """ if change['type'] != 'container': return op = change['operation'] if op == 'append': i = len(change['value'])-1 ...
python
def _on_items_changed(self, change): """ Observe container events on the items list and update the adapter appropriately. """ if change['type'] != 'container': return op = change['operation'] if op == 'append': i = len(change['value'])-1 ...
[ "def", "_on_items_changed", "(", "self", ",", "change", ")", ":", "if", "change", "[", "'type'", "]", "!=", "'container'", ":", "return", "op", "=", "change", "[", "'operation'", "]", "if", "op", "==", "'append'", ":", "i", "=", "len", "(", "change", ...
Observe container events on the items list and update the adapter appropriately.
[ "Observe", "container", "events", "on", "the", "items", "list", "and", "update", "the", "adapter", "appropriately", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_list_view.py#L268-L290
codelv/enaml-native
src/enamlnative/android/android_list_view.py
AndroidListItem.recycle_view
def recycle_view(self, position): """ Tell the view to render the item at the given position """ d = self.declaration if position < len(d.parent.items): d.index = position d.item = d.parent.items[position] else: d.index = -1 d.item = None
python
def recycle_view(self, position): """ Tell the view to render the item at the given position """ d = self.declaration if position < len(d.parent.items): d.index = position d.item = d.parent.items[position] else: d.index = -1 d.item = None
[ "def", "recycle_view", "(", "self", ",", "position", ")", ":", "d", "=", "self", ".", "declaration", "if", "position", "<", "len", "(", "d", ".", "parent", ".", "items", ")", ":", "d", ".", "index", "=", "position", "d", ".", "item", "=", "d", "....
Tell the view to render the item at the given position
[ "Tell", "the", "view", "to", "render", "the", "item", "at", "the", "given", "position" ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_list_view.py#L351-L360
codelv/enaml-native
src/enamlnative/core/eventloop/util.py
errno_from_exception
def errno_from_exception(e): # type: (BaseException) -> Optional[int] """Provides the errno from an Exception object. There are cases that the errno attribute was not set so we pull the errno out of the args but if someone instantiates an Exception without any args you will get a tuple error. So th...
python
def errno_from_exception(e): # type: (BaseException) -> Optional[int] """Provides the errno from an Exception object. There are cases that the errno attribute was not set so we pull the errno out of the args but if someone instantiates an Exception without any args you will get a tuple error. So th...
[ "def", "errno_from_exception", "(", "e", ")", ":", "# type: (BaseException) -> Optional[int]", "if", "hasattr", "(", "e", ",", "'errno'", ")", ":", "return", "e", ".", "errno", "# type: ignore", "elif", "e", ".", "args", ":", "return", "e", ".", "args", "[",...
Provides the errno from an Exception object. There are cases that the errno attribute was not set so we pull the errno out of the args but if someone instantiates an Exception without any args you will get a tuple error. So this function abstracts all that behavior to give you a safe way to get the ...
[ "Provides", "the", "errno", "from", "an", "Exception", "object", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/eventloop/util.py#L223-L239
codelv/enaml-native
src/enamlnative/core/eventloop/util.py
_websocket_mask_python
def _websocket_mask_python(mask, data): # type: (bytes, bytes) -> bytes """Websocket masking function. `mask` is a `bytes` object of length 4; `data` is a `bytes` object of any length. Returns a `bytes` object of the same length as `data` with the mask applied as specified in section 5.3 of RFC 645...
python
def _websocket_mask_python(mask, data): # type: (bytes, bytes) -> bytes """Websocket masking function. `mask` is a `bytes` object of length 4; `data` is a `bytes` object of any length. Returns a `bytes` object of the same length as `data` with the mask applied as specified in section 5.3 of RFC 645...
[ "def", "_websocket_mask_python", "(", "mask", ",", "data", ")", ":", "# type: (bytes, bytes) -> bytes", "mask_arr", "=", "array", ".", "array", "(", "\"B\"", ",", "mask", ")", "unmasked_arr", "=", "array", ".", "array", "(", "\"B\"", ",", "data", ")", "for",...
Websocket masking function. `mask` is a `bytes` object of length 4; `data` is a `bytes` object of any length. Returns a `bytes` object of the same length as `data` with the mask applied as specified in section 5.3 of RFC 6455. This pure-python implementation may be replaced by an optimized version whe...
[ "Websocket", "masking", "function", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/eventloop/util.py#L463-L483
codelv/enaml-native
src/enamlnative/core/eventloop/util.py
Configurable.configure
def configure(cls, impl, **kwargs): # type: (Any, **Any) -> None """Sets the class to use when the base class is instantiated. Keyword arguments will be saved and added to the arguments passed to the constructor. This can be used to set global defaults for some parameters. ...
python
def configure(cls, impl, **kwargs): # type: (Any, **Any) -> None """Sets the class to use when the base class is instantiated. Keyword arguments will be saved and added to the arguments passed to the constructor. This can be used to set global defaults for some parameters. ...
[ "def", "configure", "(", "cls", ",", "impl", ",", "*", "*", "kwargs", ")", ":", "# type: (Any, **Any) -> None", "base", "=", "cls", ".", "configurable_base", "(", ")", "if", "isinstance", "(", "impl", ",", "(", "str", ",", "unicode_type", ")", ")", ":", ...
Sets the class to use when the base class is instantiated. Keyword arguments will be saved and added to the arguments passed to the constructor. This can be used to set global defaults for some parameters.
[ "Sets", "the", "class", "to", "use", "when", "the", "base", "class", "is", "instantiated", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/eventloop/util.py#L342-L356
codelv/enaml-native
src/enamlnative/core/eventloop/util.py
Configurable.configured_class
def configured_class(cls): # type: () -> type """Returns the currently configured class.""" base = cls.configurable_base() # Manually mangle the private name to see whether this base # has been configured (and not another base higher in the # hierarchy). if base._...
python
def configured_class(cls): # type: () -> type """Returns the currently configured class.""" base = cls.configurable_base() # Manually mangle the private name to see whether this base # has been configured (and not another base higher in the # hierarchy). if base._...
[ "def", "configured_class", "(", "cls", ")", ":", "# type: () -> type", "base", "=", "cls", ".", "configurable_base", "(", ")", "# Manually mangle the private name to see whether this base", "# has been configured (and not another base higher in the", "# hierarchy).", "if", "base"...
Returns the currently configured class.
[ "Returns", "the", "currently", "configured", "class", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/eventloop/util.py#L359-L368
codelv/enaml-native
src/enamlnative/core/eventloop/util.py
ArgReplacer.get_old_value
def get_old_value(self, args, kwargs, default=None): # type: (List[Any], Dict[str, Any], Any) -> Any """Returns the old value of the named argument without replacing it. Returns ``default`` if the argument is not present. """ if self.arg_pos is not None and len(args) > self.arg_...
python
def get_old_value(self, args, kwargs, default=None): # type: (List[Any], Dict[str, Any], Any) -> Any """Returns the old value of the named argument without replacing it. Returns ``default`` if the argument is not present. """ if self.arg_pos is not None and len(args) > self.arg_...
[ "def", "get_old_value", "(", "self", ",", "args", ",", "kwargs", ",", "default", "=", "None", ")", ":", "# type: (List[Any], Dict[str, Any], Any) -> Any", "if", "self", ".", "arg_pos", "is", "not", "None", "and", "len", "(", "args", ")", ">", "self", ".", ...
Returns the old value of the named argument without replacing it. Returns ``default`` if the argument is not present.
[ "Returns", "the", "old", "value", "of", "the", "named", "argument", "without", "replacing", "it", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/eventloop/util.py#L423-L432
codelv/enaml-native
src/enamlnative/core/eventloop/util.py
ArgReplacer.replace
def replace(self, new_value, args, kwargs): # type: (Any, List[Any], Dict[str, Any]) -> Tuple[Any, List[Any], Dict[str, Any]] """Replace the named argument in ``args, kwargs`` with ``new_value``. Returns ``(old_value, args, kwargs)``. The returned ``args`` and ``kwargs`` objects may no...
python
def replace(self, new_value, args, kwargs): # type: (Any, List[Any], Dict[str, Any]) -> Tuple[Any, List[Any], Dict[str, Any]] """Replace the named argument in ``args, kwargs`` with ``new_value``. Returns ``(old_value, args, kwargs)``. The returned ``args`` and ``kwargs`` objects may no...
[ "def", "replace", "(", "self", ",", "new_value", ",", "args", ",", "kwargs", ")", ":", "# type: (Any, List[Any], Dict[str, Any]) -> Tuple[Any, List[Any], Dict[str, Any]]", "if", "self", ".", "arg_pos", "is", "not", "None", "and", "len", "(", "args", ")", ">", "sel...
Replace the named argument in ``args, kwargs`` with ``new_value``. Returns ``(old_value, args, kwargs)``. The returned ``args`` and ``kwargs`` objects may not be the same as the input objects, or the input objects may be mutated. If the named argument was not found, ``new_value`` will...
[ "Replace", "the", "named", "argument", "in", "args", "kwargs", "with", "new_value", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/eventloop/util.py#L434-L454
codelv/enaml-native
src/enamlnative/widgets/notification.py
Notification.popup
def popup(self): """ Show the notification from code. This will initialize and activate if needed. Notes ------ This does NOT block. Callbacks should be used to handle click events or the `show` state should be observed to know when it is closed. ...
python
def popup(self): """ Show the notification from code. This will initialize and activate if needed. Notes ------ This does NOT block. Callbacks should be used to handle click events or the `show` state should be observed to know when it is closed. ...
[ "def", "popup", "(", "self", ")", ":", "if", "not", "self", ".", "is_initialized", ":", "self", ".", "initialize", "(", ")", "if", "not", "self", ".", "proxy_is_active", ":", "self", ".", "activate_proxy", "(", ")", "self", ".", "show", "=", "True" ]
Show the notification from code. This will initialize and activate if needed. Notes ------ This does NOT block. Callbacks should be used to handle click events or the `show` state should be observed to know when it is closed.
[ "Show", "the", "notification", "from", "code", ".", "This", "will", "initialize", "and", "activate", "if", "needed", ".", "Notes", "------", "This", "does", "NOT", "block", ".", "Callbacks", "should", "be", "used", "to", "handle", "click", "events", "or", ...
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/widgets/notification.py#L133-L147
codelv/enaml-native
src/enamlnative/android/android_toast.py
AndroidToast.create_widget
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 if d.text: Toast.makeText(self.get_contex...
python
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 if d.text: Toast.makeText(self.get_contex...
[ "def", "create_widget", "(", "self", ")", ":", "d", "=", "self", ".", "declaration", "if", "d", ".", "text", ":", "Toast", ".", "makeText", "(", "self", ".", "get_context", "(", ")", ",", "d", ".", "text", ",", "1", ")", ".", "then", "(", "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).
[ "Create", "the", "underlying", "widget", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_toast.py#L48-L61
codelv/enaml-native
src/enamlnative/android/android_toast.py
AndroidToast.init_widget
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.toast: return super(AndroidToast, self).init_widget() d = self.declaration if not ...
python
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.toast: return super(AndroidToast, self).init_widget() d = self.declaration if not ...
[ "def", "init_widget", "(", "self", ")", ":", "if", "not", "self", ".", "toast", ":", "return", "super", "(", "AndroidToast", ",", "self", ")", ".", "init_widget", "(", ")", "d", "=", "self", ".", "declaration", "if", "not", "self", ".", "made_toast", ...
Our widget may not exist yet so we have to diverge from the normal way of doing initialization. See `update_widget`
[ "Our", "widget", "may", "not", "exist", "yet", "so", "we", "have", "to", "diverge", "from", "the", "normal", "way", "of", "doing", "initialization", ".", "See", "update_widget" ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_toast.py#L63-L79
codelv/enaml-native
src/enamlnative/android/android_toast.py
AndroidToast.init_layout
def init_layout(self): """ If a view is given show it """ super(AndroidToast, self).init_layout() if not self.made_toast: for view in self.child_widgets(): self.toast.setView(view) break
python
def init_layout(self): """ If a view is given show it """ super(AndroidToast, self).init_layout() if not self.made_toast: for view in self.child_widgets(): self.toast.setView(view) break
[ "def", "init_layout", "(", "self", ")", ":", "super", "(", "AndroidToast", ",", "self", ")", ".", "init_layout", "(", ")", "if", "not", "self", ".", "made_toast", ":", "for", "view", "in", "self", ".", "child_widgets", "(", ")", ":", "self", ".", "to...
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_toast.py#L81-L87
codelv/enaml-native
src/enamlnative/android/android_toast.py
AndroidToast.child_added
def child_added(self, child): """ Overwrite the view """ view = child.widget if view is not None: self.toast.setView(view)
python
def child_added(self, child): """ Overwrite the view """ view = child.widget if view is not None: self.toast.setView(view)
[ "def", "child_added", "(", "self", ",", "child", ")", ":", "view", "=", "child", ".", "widget", "if", "view", "is", "not", "None", ":", "self", ".", "toast", ".", "setView", "(", "view", ")" ]
Overwrite the view
[ "Overwrite", "the", "view" ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_toast.py#L89-L93
codelv/enaml-native
src/enamlnative/android/android_toast.py
AndroidToast.on_make_toast
def on_make_toast(self, ref): """ Using Toast.makeToast returns async so we have to initialize it later. """ d = self.declaration self.toast = Toast(__id__=ref) self.init_widget()
python
def on_make_toast(self, ref): """ Using Toast.makeToast returns async so we have to initialize it later. """ d = self.declaration self.toast = Toast(__id__=ref) self.init_widget()
[ "def", "on_make_toast", "(", "self", ",", "ref", ")", ":", "d", "=", "self", ".", "declaration", "self", ".", "toast", "=", "Toast", "(", "__id__", "=", "ref", ")", "self", ".", "init_widget", "(", ")" ]
Using Toast.makeToast returns async so we have to initialize it later.
[ "Using", "Toast", ".", "makeToast", "returns", "async", "so", "we", "have", "to", "initialize", "it", "later", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_toast.py#L95-L102
codelv/enaml-native
src/enamlnative/android/android_toast.py
AndroidToast._refresh_show
def _refresh_show(self, dt): """ While the toast.show is true, keep calling .show() until the duration `dt` expires. Parameters ------------ dt: int Time left to keep showing """ d = self.declaration if dt <= 0: #: Done, hide ...
python
def _refresh_show(self, dt): """ While the toast.show is true, keep calling .show() until the duration `dt` expires. Parameters ------------ dt: int Time left to keep showing """ d = self.declaration if dt <= 0: #: Done, hide ...
[ "def", "_refresh_show", "(", "self", ",", "dt", ")", ":", "d", "=", "self", ".", "declaration", "if", "dt", "<=", "0", ":", "#: Done, hide", "d", ".", "show", "=", "False", "elif", "d", ".", "show", ":", "#: If user didn't cancel it, keep it alive", "self"...
While the toast.show is true, keep calling .show() until the duration `dt` expires. Parameters ------------ dt: int Time left to keep showing
[ "While", "the", "toast", ".", "show", "is", "true", "keep", "calling", ".", "show", "()", "until", "the", "duration", "dt", "expires", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_toast.py#L104-L124
codelv/enaml-native
src/enamlnative/android/android_dialog.py
AndroidDialog.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 self.dialog = Dialog(self.get_context(), d.style)
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 self.dialog = Dialog(self.get_context(), d.style)
[ "def", "create_widget", "(", "self", ")", ":", "d", "=", "self", ".", "declaration", "self", ".", "dialog", "=", "Dialog", "(", "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.
[ "Create", "the", "underlying", "widget", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_dialog.py#L53-L61
codelv/enaml-native
src/enamlnative/android/android_dialog.py
AndroidDialog.init_widget
def init_widget(self): """ Set the listeners """ w = self.dialog # Listen for events w.setOnDismissListener(w.getId()) w.onDismiss.connect(self.on_dismiss) w.setOnCancelListener(w.getId()) w.onCancel.connect(self.on_cancel) super(AndroidDialog, sel...
python
def init_widget(self): """ Set the listeners """ w = self.dialog # Listen for events w.setOnDismissListener(w.getId()) w.onDismiss.connect(self.on_dismiss) w.setOnCancelListener(w.getId()) w.onCancel.connect(self.on_cancel) super(AndroidDialog, sel...
[ "def", "init_widget", "(", "self", ")", ":", "w", "=", "self", ".", "dialog", "# Listen for events", "w", ".", "setOnDismissListener", "(", "w", ".", "getId", "(", ")", ")", "w", ".", "onDismiss", ".", "connect", "(", "self", ".", "on_dismiss", ")", "w...
Set the listeners
[ "Set", "the", "listeners" ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_dialog.py#L63-L72
codelv/enaml-native
src/enamlnative/android/android_dialog.py
AndroidDialog.init_layout
def init_layout(self): """ If a view is given show it """ super(AndroidDialog, self).init_layout() #: Set the content for view in self.child_widgets(): self.dialog.setContentView(view) break #: Show it if needed d = self.declara...
python
def init_layout(self): """ If a view is given show it """ super(AndroidDialog, self).init_layout() #: Set the content for view in self.child_widgets(): self.dialog.setContentView(view) break #: Show it if needed d = self.declara...
[ "def", "init_layout", "(", "self", ")", ":", "super", "(", "AndroidDialog", ",", "self", ")", ".", "init_layout", "(", ")", "#: Set the content", "for", "view", "in", "self", ".", "child_widgets", "(", ")", ":", "self", ".", "dialog", ".", "setContentView"...
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_dialog.py#L74-L88
codelv/enaml-native
src/enamlnative/android/android_dialog.py
AndroidDialog.child_added
def child_added(self, child): """ Overwrite the content view """ view = child.widget if view is not None: self.dialog.setContentView(view)
python
def child_added(self, child): """ Overwrite the content view """ view = child.widget if view is not None: self.dialog.setContentView(view)
[ "def", "child_added", "(", "self", ",", "child", ")", ":", "view", "=", "child", ".", "widget", "if", "view", "is", "not", "None", ":", "self", ".", "dialog", ".", "setContentView", "(", "view", ")" ]
Overwrite the content view
[ "Overwrite", "the", "content", "view" ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_dialog.py#L90-L94
codelv/enaml-native
src/enamlnative/android/android_dialog.py
AndroidDialog.destroy
def destroy(self): """ A reimplemented destructor that cancels the dialog before destroying. """ dialog = self.dialog if dialog: #: Clear the dismiss listener #: (or we get an error during the callback) dialog.setOnDismissListener(No...
python
def destroy(self): """ A reimplemented destructor that cancels the dialog before destroying. """ dialog = self.dialog if dialog: #: Clear the dismiss listener #: (or we get an error during the callback) dialog.setOnDismissListener(No...
[ "def", "destroy", "(", "self", ")", ":", "dialog", "=", "self", ".", "dialog", "if", "dialog", ":", "#: Clear the dismiss listener", "#: (or we get an error during the callback)", "dialog", ".", "setOnDismissListener", "(", "None", ")", "dialog", ".", "dismiss", "("...
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_dialog.py#L96-L108
codelv/enaml-native
src/enamlnative/android/android_location.py
LocationManager.start
def start(cls, callback, provider='gps', min_time=1000, min_distance=0): """ Convenience method that checks and requests permission if necessary and if successful calls the callback with a populated `Location` instance on updates. Note you must have the permissions in your manifest or ...
python
def start(cls, callback, provider='gps', min_time=1000, min_distance=0): """ Convenience method that checks and requests permission if necessary and if successful calls the callback with a populated `Location` instance on updates. Note you must have the permissions in your manifest or ...
[ "def", "start", "(", "cls", ",", "callback", ",", "provider", "=", "'gps'", ",", "min_time", "=", "1000", ",", "min_distance", "=", "0", ")", ":", "app", "=", "AndroidApplication", ".", "instance", "(", ")", "f", "=", "app", ".", "create_future", "(", ...
Convenience method that checks and requests permission if necessary and if successful calls the callback with a populated `Location` instance on updates. Note you must have the permissions in your manifest or requests will be denied immediately.
[ "Convenience", "method", "that", "checks", "and", "requests", "permission", "if", "necessary", "and", "if", "successful", "calls", "the", "callback", "with", "a", "populated", "Location", "instance", "on", "updates", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_location.py#L61-L105
codelv/enaml-native
src/enamlnative/android/android_location.py
LocationManager.stop
def stop(cls): """ Stops location updates if currently updating. """ manager = LocationManager.instance() if manager: for l in manager.listeners: manager.removeUpdates(l) manager.listeners = []
python
def stop(cls): """ Stops location updates if currently updating. """ manager = LocationManager.instance() if manager: for l in manager.listeners: manager.removeUpdates(l) manager.listeners = []
[ "def", "stop", "(", "cls", ")", ":", "manager", "=", "LocationManager", ".", "instance", "(", ")", "if", "manager", ":", "for", "l", "in", "manager", ".", "listeners", ":", "manager", ".", "removeUpdates", "(", "l", ")", "manager", ".", "listeners", "=...
Stops location updates if currently updating.
[ "Stops", "location", "updates", "if", "currently", "updating", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_location.py#L108-L116
codelv/enaml-native
src/enamlnative/android/android_location.py
LocationManager.check_permission
def check_permission(cls, fine=True): """ Returns a future that returns a boolean indicating if permission is currently granted or denied. If permission is denied, you can request using `LocationManager.request_permission()` below. """ app = AndroidApplication.instance() ...
python
def check_permission(cls, fine=True): """ Returns a future that returns a boolean indicating if permission is currently granted or denied. If permission is denied, you can request using `LocationManager.request_permission()` below. """ app = AndroidApplication.instance() ...
[ "def", "check_permission", "(", "cls", ",", "fine", "=", "True", ")", ":", "app", "=", "AndroidApplication", ".", "instance", "(", ")", "permission", "=", "(", "cls", ".", "ACCESS_FINE_PERMISSION", "if", "fine", "else", "cls", ".", "ACCESS_COARSE_PERMISSION", ...
Returns a future that returns a boolean indicating if permission is currently granted or denied. If permission is denied, you can request using `LocationManager.request_permission()` below.
[ "Returns", "a", "future", "that", "returns", "a", "boolean", "indicating", "if", "permission", "is", "currently", "granted", "or", "denied", ".", "If", "permission", "is", "denied", "you", "can", "request", "using", "LocationManager", ".", "request_permission", ...
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_location.py#L120-L129
codelv/enaml-native
src/enamlnative/android/android_location.py
LocationManager.request_permission
def request_permission(cls, fine=True): """ Requests permission and returns an async result that returns a boolean indicating if the permission was granted or denied. """ app = AndroidApplication.instance() permission = (cls.ACCESS_FINE_PERMISSION ...
python
def request_permission(cls, fine=True): """ Requests permission and returns an async result that returns a boolean indicating if the permission was granted or denied. """ app = AndroidApplication.instance() permission = (cls.ACCESS_FINE_PERMISSION ...
[ "def", "request_permission", "(", "cls", ",", "fine", "=", "True", ")", ":", "app", "=", "AndroidApplication", ".", "instance", "(", ")", "permission", "=", "(", "cls", ".", "ACCESS_FINE_PERMISSION", "if", "fine", "else", "cls", ".", "ACCESS_COARSE_PERMISSION"...
Requests permission and returns an async result that returns a boolean indicating if the permission was granted or denied.
[ "Requests", "permission", "and", "returns", "an", "async", "result", "that", "returns", "a", "boolean", "indicating", "if", "the", "permission", "was", "granted", "or", "denied", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_location.py#L132-L147
codelv/enaml-native
src/enamlnative/android/android_web_view.py
AndroidWebView.create_widget
def create_widget(self): """ Create the underlying widget. """ d = self.declaration self.widget = WebView(self.get_context(), None, d.style)
python
def create_widget(self): """ Create the underlying widget. """ d = self.declaration self.widget = WebView(self.get_context(), None, d.style)
[ "def", "create_widget", "(", "self", ")", ":", "d", "=", "self", ".", "declaration", "self", ".", "widget", "=", "WebView", "(", "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_web_view.py#L71-L76
codelv/enaml-native
src/enamlnative/android/android_web_view.py
AndroidWebView.init_widget
def init_widget(self): """ Initialize the underlying widget. """ # Create and init the client c = self.client = BridgedWebViewClient() c.setWebView(self.widget, c.getId()) c.onLoadResource.connect(self.on_load_resource) c.onPageFinished.connect(self.on_page_finis...
python
def init_widget(self): """ Initialize the underlying widget. """ # Create and init the client c = self.client = BridgedWebViewClient() c.setWebView(self.widget, c.getId()) c.onLoadResource.connect(self.on_load_resource) c.onPageFinished.connect(self.on_page_finis...
[ "def", "init_widget", "(", "self", ")", ":", "# Create and init the client", "c", "=", "self", ".", "client", "=", "BridgedWebViewClient", "(", ")", "c", ".", "setWebView", "(", "self", ".", "widget", ",", "c", ".", "getId", "(", ")", ")", "c", ".", "o...
Initialize the underlying widget.
[ "Initialize", "the", "underlying", "widget", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_web_view.py#L78-L93
codelv/enaml-native
src/enamlnative/android/android_web_view.py
AndroidWebView.destroy
def destroy(self): """ Destroy the client """ if self.client: #: Stop listening self.client.setWebView(self.widget, None) del self.client super(AndroidWebView, self).destroy()
python
def destroy(self): """ Destroy the client """ if self.client: #: Stop listening self.client.setWebView(self.widget, None) del self.client super(AndroidWebView, self).destroy()
[ "def", "destroy", "(", "self", ")", ":", "if", "self", ".", "client", ":", "#: Stop listening", "self", ".", "client", ".", "setWebView", "(", "self", ".", "widget", ",", "None", ")", "del", "self", ".", "client", "super", "(", "AndroidWebView", ",", "...
Destroy the client
[ "Destroy", "the", "client" ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_web_view.py#L95-L103
codelv/enaml-native
src/enamlnative/ios/uikit_slider.py
UiKitSlider.init_widget
def init_widget(self): """ Bind the on property to the checked state """ super(UiKitSlider, self).init_widget() d = self.declaration if d.min: self.set_min(d.min) if d.max: self.set_max(d.max) if d.progress: self.set_progress(d.progres...
python
def init_widget(self): """ Bind the on property to the checked state """ super(UiKitSlider, self).init_widget() d = self.declaration if d.min: self.set_min(d.min) if d.max: self.set_max(d.max) if d.progress: self.set_progress(d.progres...
[ "def", "init_widget", "(", "self", ")", ":", "super", "(", "UiKitSlider", ",", "self", ")", ".", "init_widget", "(", ")", "d", "=", "self", ".", "declaration", "if", "d", ".", "min", ":", "self", ".", "set_min", "(", "d", ".", "min", ")", "if", "...
Bind the on property to the checked state
[ "Bind", "the", "on", "property", "to", "the", "checked", "state" ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/ios/uikit_slider.py#L59-L81
codelv/enaml-native
src/enamlnative/ios/uikit_slider.py
UiKitSlider.on_checked_changed
def on_checked_changed(self, value): """ 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.setValue.suppressed(): d.progress = int(value)
python
def on_checked_changed(self, value): """ 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.setValue.suppressed(): d.progress = int(value)
[ "def", "on_checked_changed", "(", "self", ",", "value", ")", ":", "#: Since iOS decides to call this like 100 times for each defer it", "d", "=", "self", ".", "declaration", "with", "self", ".", "widget", ".", "setValue", ".", "suppressed", "(", ")", ":", "d", "."...
See https://stackoverflow.com/questions/19628310/
[ "See", "https", ":", "//", "stackoverflow", ".", "com", "/", "questions", "/", "19628310", "/" ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/ios/uikit_slider.py#L87-L92
codelv/enaml-native
src/enamlnative/android/android_radio_group.py
AndroidRadioGroup.init_layout
def init_layout(self): """ Set the checked state after all children have been populated. """ super(AndroidRadioGroup, self).init_layout() d = self.declaration w = self.widget if d.checked: self.set_checked(d.checked) else: ...
python
def init_layout(self): """ Set the checked state after all children have been populated. """ super(AndroidRadioGroup, self).init_layout() d = self.declaration w = self.widget if d.checked: self.set_checked(d.checked) else: ...
[ "def", "init_layout", "(", "self", ")", ":", "super", "(", "AndroidRadioGroup", ",", "self", ")", ".", "init_layout", "(", ")", "d", "=", "self", ".", "declaration", "w", "=", "self", ".", "widget", "if", "d", ".", "checked", ":", "self", ".", "set_c...
Set the checked state after all children have been populated.
[ "Set", "the", "checked", "state", "after", "all", "children", "have", "been", "populated", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_radio_group.py#L47-L64
codelv/enaml-native
src/enamlnative/android/android_radio_group.py
AndroidRadioGroup.on_checked_changed
def on_checked_changed(self, group, checked_id): """ Set the checked property based on the checked state of all the children """ d = self.declaration if checked_id < 0: with self.widget.clearCheck.suppressed(): d.checked = None ret...
python
def on_checked_changed(self, group, checked_id): """ Set the checked property based on the checked state of all the children """ d = self.declaration if checked_id < 0: with self.widget.clearCheck.suppressed(): d.checked = None ret...
[ "def", "on_checked_changed", "(", "self", ",", "group", ",", "checked_id", ")", ":", "d", "=", "self", ".", "declaration", "if", "checked_id", "<", "0", ":", "with", "self", ".", "widget", ".", "clearCheck", ".", "suppressed", "(", ")", ":", "d", ".", ...
Set the checked property based on the checked state of all the children
[ "Set", "the", "checked", "property", "based", "on", "the", "checked", "state", "of", "all", "the", "children" ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_radio_group.py#L69-L84
codelv/enaml-native
src/enamlnative/android/android_radio_group.py
AndroidRadioGroup.set_checked
def set_checked(self, checked): """ Properly check the correct radio button. """ if not checked: self.widget.clearCheck() else: #: Checked is a reference to the radio declaration #: so we need to get the ID of it rb = checked.proxy.widget ...
python
def set_checked(self, checked): """ Properly check the correct radio button. """ if not checked: self.widget.clearCheck() else: #: Checked is a reference to the radio declaration #: so we need to get the ID of it rb = checked.proxy.widget ...
[ "def", "set_checked", "(", "self", ",", "checked", ")", ":", "if", "not", "checked", ":", "self", ".", "widget", ".", "clearCheck", "(", ")", "else", ":", "#: Checked is a reference to the radio declaration", "#: so we need to get the ID of it", "rb", "=", "checked"...
Properly check the correct radio button.
[ "Properly", "check", "the", "correct", "radio", "button", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_radio_group.py#L89-L101
codelv/enaml-native
src/enamlnative/android/app.py
AndroidApplication.init_widget
def init_widget(self): """ Initialize on the first call """ #: Add a ActivityLifecycleListener to update the application state activity = self.widget activity.addActivityLifecycleListener(activity.getId()) activity.onActivityLifecycleChanged.connect( ...
python
def init_widget(self): """ Initialize on the first call """ #: Add a ActivityLifecycleListener to update the application state activity = self.widget activity.addActivityLifecycleListener(activity.getId()) activity.onActivityLifecycleChanged.connect( ...
[ "def", "init_widget", "(", "self", ")", ":", "#: Add a ActivityLifecycleListener to update the application state", "activity", "=", "self", ".", "widget", "activity", ".", "addActivityLifecycleListener", "(", "activity", ".", "getId", "(", ")", ")", "activity", ".", "...
Initialize on the first call
[ "Initialize", "on", "the", "first", "call" ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/app.py#L79-L95
codelv/enaml-native
src/enamlnative/android/app.py
AndroidApplication.has_permission
def has_permission(self, permission): """ Return a future that resolves with the result of the permission """ f = self.create_future() #: Old versions of android did permissions at install time if self.api_level < 23: f.set_result(True) return f...
python
def has_permission(self, permission): """ Return a future that resolves with the result of the permission """ f = self.create_future() #: Old versions of android did permissions at install time if self.api_level < 23: f.set_result(True) return f...
[ "def", "has_permission", "(", "self", ",", "permission", ")", ":", "f", "=", "self", ".", "create_future", "(", ")", "#: Old versions of android did permissions at install time", "if", "self", ".", "api_level", "<", "23", ":", "f", ".", "set_result", "(", "True"...
Return a future that resolves with the result of the permission
[ "Return", "a", "future", "that", "resolves", "with", "the", "result", "of", "the", "permission" ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/app.py#L100-L117
codelv/enaml-native
src/enamlnative/android/app.py
AndroidApplication.request_permissions
def request_permissions(self, permissions): """ Return a future that resolves with the results of the permission requests """ f = self.create_future() #: Old versions of android did permissions at install time if self.api_level < 23: f.set_result({p...
python
def request_permissions(self, permissions): """ Return a future that resolves with the results of the permission requests """ f = self.create_future() #: Old versions of android did permissions at install time if self.api_level < 23: f.set_result({p...
[ "def", "request_permissions", "(", "self", ",", "permissions", ")", ":", "f", "=", "self", ".", "create_future", "(", ")", "#: Old versions of android did permissions at install time", "if", "self", ".", "api_level", "<", "23", ":", "f", ".", "set_result", "(", ...
Return a future that resolves with the results of the permission requests
[ "Return", "a", "future", "that", "resolves", "with", "the", "results", "of", "the", "permission", "requests" ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/app.py#L119-L151
codelv/enaml-native
src/enamlnative/android/app.py
AndroidApplication.show_toast
def show_toast(self, msg, long=True): """ Show a toast message for the given duration. This is an android specific api. Parameters ----------- msg: str Text to display in the toast message long: bool Display for a long or short (system defined) du...
python
def show_toast(self, msg, long=True): """ Show a toast message for the given duration. This is an android specific api. Parameters ----------- msg: str Text to display in the toast message long: bool Display for a long or short (system defined) du...
[ "def", "show_toast", "(", "self", ",", "msg", ",", "long", "=", "True", ")", ":", "from", ".", "android_toast", "import", "Toast", "def", "on_toast", "(", "ref", ")", ":", "t", "=", "Toast", "(", "__id__", "=", "ref", ")", "t", ".", "show", "(", ...
Show a toast message for the given duration. This is an android specific api. Parameters ----------- msg: str Text to display in the toast message long: bool Display for a long or short (system defined) duration
[ "Show", "a", "toast", "message", "for", "the", "given", "duration", ".", "This", "is", "an", "android", "specific", "api", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/app.py#L153-L171
codelv/enaml-native
src/enamlnative/android/app.py
AndroidApplication.on_back_pressed
def on_back_pressed(self): """ Fire the `back_pressed` event with a dictionary with a 'handled' key when the back hardware button is pressed If 'handled' is set to any value that evaluates to True the default event implementation will be ignored. """ try...
python
def on_back_pressed(self): """ Fire the `back_pressed` event with a dictionary with a 'handled' key when the back hardware button is pressed If 'handled' is set to any value that evaluates to True the default event implementation will be ignored. """ try...
[ "def", "on_back_pressed", "(", "self", ")", ":", "try", ":", "event", "=", "{", "'handled'", ":", "False", "}", "self", ".", "back_pressed", "(", "event", ")", "return", "bool", "(", "event", ".", "get", "(", "'handled'", ",", "False", ")", ")", "exc...
Fire the `back_pressed` event with a dictionary with a 'handled' key when the back hardware button is pressed If 'handled' is set to any value that evaluates to True the default event implementation will be ignored.
[ "Fire", "the", "back_pressed", "event", "with", "a", "dictionary", "with", "a", "handled", "key", "when", "the", "back", "hardware", "button", "is", "pressed", "If", "handled", "is", "set", "to", "any", "value", "that", "evaluates", "to", "True", "the", "d...
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/app.py#L182-L196
codelv/enaml-native
src/enamlnative/android/app.py
AndroidApplication.on_configuration_changed
def on_configuration_changed(self, config): """ Handles a screen configuration change. """ self.width = config['width'] self.height = config['height'] self.orientation = ('square', 'portrait', 'landscape')[ config['orientation']]
python
def on_configuration_changed(self, config): """ Handles a screen configuration change. """ self.width = config['width'] self.height = config['height'] self.orientation = ('square', 'portrait', 'landscape')[ config['orientation']]
[ "def", "on_configuration_changed", "(", "self", ",", "config", ")", ":", "self", ".", "width", "=", "config", "[", "'width'", "]", "self", ".", "height", "=", "config", "[", "'height'", "]", "self", ".", "orientation", "=", "(", "'square'", ",", "'portra...
Handles a screen configuration change.
[ "Handles", "a", "screen", "configuration", "change", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/app.py#L198-L205
codelv/enaml-native
src/enamlnative/android/app.py
AndroidApplication.show_view
def show_view(self): """ Show the current `app.view`. This will fade out the previous with the new view. """ if not self.build_info: def on_build_info(info): """ Make sure the build info is ready before we display the view ...
python
def show_view(self): """ Show the current `app.view`. This will fade out the previous with the new view. """ if not self.build_info: def on_build_info(info): """ Make sure the build info is ready before we display the view ...
[ "def", "show_view", "(", "self", ")", ":", "if", "not", "self", ".", "build_info", ":", "def", "on_build_info", "(", "info", ")", ":", "\"\"\" Make sure the build info is ready before we \n display the view \n \n \"\"\"", "self", "...
Show the current `app.view`. This will fade out the previous with the new view.
[ "Show", "the", "current", "app", ".", "view", ".", "This", "will", "fade", "out", "the", "previous", "with", "the", "new", "view", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/app.py#L210-L233
codelv/enaml-native
src/enamlnative/android/app.py
AndroidApplication._on_permission_result
def _on_permission_result(self, code, perms, results): """ Handles a permission request result by passing it to the handler with the given code. """ #: Get the handler for this request handler = self._permission_requests.get(code, None) if handler is not None: ...
python
def _on_permission_result(self, code, perms, results): """ Handles a permission request result by passing it to the handler with the given code. """ #: Get the handler for this request handler = self._permission_requests.get(code, None) if handler is not None: ...
[ "def", "_on_permission_result", "(", "self", ",", "code", ",", "perms", ",", "results", ")", ":", "#: Get the handler for this request", "handler", "=", "self", ".", "_permission_requests", ".", "get", "(", "code", ",", "None", ")", "if", "handler", "is", "not...
Handles a permission request result by passing it to the handler with the given code.
[ "Handles", "a", "permission", "request", "result", "by", "passing", "it", "to", "the", "handler", "with", "the", "given", "code", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/app.py#L246-L257
codelv/enaml-native
src/enamlnative/android/app.py
AndroidApplication._observe_keep_screen_on
def _observe_keep_screen_on(self, change): """ Sets or clears the flag to keep the screen on. """ def set_screen_on(window): from .android_window import Window window = Window(__id__=window) if self.keep_screen_on: window.addFlags(Win...
python
def _observe_keep_screen_on(self, change): """ Sets or clears the flag to keep the screen on. """ def set_screen_on(window): from .android_window import Window window = Window(__id__=window) if self.keep_screen_on: window.addFlags(Win...
[ "def", "_observe_keep_screen_on", "(", "self", ",", "change", ")", ":", "def", "set_screen_on", "(", "window", ")", ":", "from", ".", "android_window", "import", "Window", "window", "=", "Window", "(", "__id__", "=", "window", ")", "if", "self", ".", "keep...
Sets or clears the flag to keep the screen on.
[ "Sets", "or", "clears", "the", "flag", "to", "keep", "the", "screen", "on", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/app.py#L259-L271
codelv/enaml-native
src/enamlnative/android/app.py
AndroidApplication.load_plugin_factories
def load_plugin_factories(self): """ Add any plugin toolkit widgets to the ANDROID_FACTORIES """ for plugin in self.get_plugins(group='enaml_native_android_factories'): get_factories = plugin.load() PLUGIN_FACTORIES = get_factories() factories.ANDROI...
python
def load_plugin_factories(self): """ Add any plugin toolkit widgets to the ANDROID_FACTORIES """ for plugin in self.get_plugins(group='enaml_native_android_factories'): get_factories = plugin.load() PLUGIN_FACTORIES = get_factories() factories.ANDROI...
[ "def", "load_plugin_factories", "(", "self", ")", ":", "for", "plugin", "in", "self", ".", "get_plugins", "(", "group", "=", "'enaml_native_android_factories'", ")", ":", "get_factories", "=", "plugin", ".", "load", "(", ")", "PLUGIN_FACTORIES", "=", "get_factor...
Add any plugin toolkit widgets to the ANDROID_FACTORIES
[ "Add", "any", "plugin", "toolkit", "widgets", "to", "the", "ANDROID_FACTORIES" ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/app.py#L283-L290
codelv/enaml-native
src/enamlnative/ios/uikit_edit_text.py
UiKitEditText.init_widget
def init_widget(self): """ Bind the on property to the checked state """ super(UiKitEditText, self).init_widget() #: Init font properties etc... self.init_text() d = self.declaration if d.placeholder: self.set_placeholder(d.placeholder) if d.input_ty...
python
def init_widget(self): """ Bind the on property to the checked state """ super(UiKitEditText, self).init_widget() #: Init font properties etc... self.init_text() d = self.declaration if d.placeholder: self.set_placeholder(d.placeholder) if d.input_ty...
[ "def", "init_widget", "(", "self", ")", ":", "super", "(", "UiKitEditText", ",", "self", ")", ".", "init_widget", "(", ")", "#: Init font properties etc...", "self", ".", "init_text", "(", ")", "d", "=", "self", ".", "declaration", "if", "d", ".", "placeho...
Bind the on property to the checked state
[ "Bind", "the", "on", "property", "to", "the", "checked", "state" ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/ios/uikit_edit_text.py#L79-L104
codelv/enaml-native
src/enamlnative/ios/uikit_edit_text.py
UiKitEditText.on_value_changed
def on_value_changed(self, text): """ Update text field """ d = self.declaration with self.widget.get_member('text').suppressed(self.widget): d.text = text
python
def on_value_changed(self, text): """ Update text field """ d = self.declaration with self.widget.get_member('text').suppressed(self.widget): d.text = text
[ "def", "on_value_changed", "(", "self", ",", "text", ")", ":", "d", "=", "self", ".", "declaration", "with", "self", ".", "widget", ".", "get_member", "(", "'text'", ")", ".", "suppressed", "(", "self", ".", "widget", ")", ":", "d", ".", "text", "=",...
Update text field
[ "Update", "text", "field" ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/ios/uikit_edit_text.py#L106-L110
codelv/enaml-native
src/enamlnative/android/android_date_picker.py
AndroidDatePicker.create_widget
def create_widget(self): """ Create the underlying widget. """ d = self.declaration self.widget = DatePicker(self.get_context(), None, d.style or "@attr/datePickerStyle")
python
def create_widget(self): """ Create the underlying widget. """ d = self.declaration self.widget = DatePicker(self.get_context(), None, d.style or "@attr/datePickerStyle")
[ "def", "create_widget", "(", "self", ")", ":", "d", "=", "self", ".", "declaration", "self", ".", "widget", "=", "DatePicker", "(", "self", ".", "get_context", "(", ")", ",", "None", ",", "d", ".", "style", "or", "\"@attr/datePickerStyle\"", ")" ]
Create the underlying widget.
[ "Create", "the", "underlying", "widget", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_date_picker.py#L46-L52
codelv/enaml-native
src/enamlnative/android/android_date_picker.py
AndroidDatePicker.init_widget
def init_widget(self): """ Initialize the underlying widget. """ d = self.declaration w = self.widget date = d.date w.init(date.year, date.month-1, date.day, w.getId()) super(AndroidDatePicker, self).init_widget() w.onDateChanged.connect(self.on_date_chan...
python
def init_widget(self): """ Initialize the underlying widget. """ d = self.declaration w = self.widget date = d.date w.init(date.year, date.month-1, date.day, w.getId()) super(AndroidDatePicker, self).init_widget() w.onDateChanged.connect(self.on_date_chan...
[ "def", "init_widget", "(", "self", ")", ":", "d", "=", "self", ".", "declaration", "w", "=", "self", ".", "widget", "date", "=", "d", ".", "date", "w", ".", "init", "(", "date", ".", "year", ",", "date", ".", "month", "-", "1", ",", "date", "."...
Initialize the underlying widget.
[ "Initialize", "the", "underlying", "widget", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_date_picker.py#L54-L63
codelv/enaml-native
src/enamlnative/__init__.py
imports
def imports(): """ Install the import hook to load python extensions from app's lib folder during the context of this block. This method is preferred as it's faster than using install. """ from .core.import_hooks import ExtensionImporter importer = ExtensionImporter() sys.meta_path....
python
def imports(): """ Install the import hook to load python extensions from app's lib folder during the context of this block. This method is preferred as it's faster than using install. """ from .core.import_hooks import ExtensionImporter importer = ExtensionImporter() sys.meta_path....
[ "def", "imports", "(", ")", ":", "from", ".", "core", ".", "import_hooks", "import", "ExtensionImporter", "importer", "=", "ExtensionImporter", "(", ")", "sys", ".", "meta_path", ".", "append", "(", "importer", ")", "yield", "sys", ".", "meta_path", ".", "...
Install the import hook to load python extensions from app's lib folder during the context of this block. This method is preferred as it's faster than using install.
[ "Install", "the", "import", "hook", "to", "load", "python", "extensions", "from", "app", "s", "lib", "folder", "during", "the", "context", "of", "this", "block", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/__init__.py#L17-L27
codelv/enaml-native
src/enamlnative/__init__.py
install
def install(): """ Install the import hook to load extensions from the app Lib folder. Like imports but leaves it in the meta_path, thus it is slower. """ from .core.import_hooks import ExtensionImporter importer = ExtensionImporter() sys.meta_path.append(importer)
python
def install(): """ Install the import hook to load extensions from the app Lib folder. Like imports but leaves it in the meta_path, thus it is slower. """ from .core.import_hooks import ExtensionImporter importer = ExtensionImporter() sys.meta_path.append(importer)
[ "def", "install", "(", ")", ":", "from", ".", "core", ".", "import_hooks", "import", "ExtensionImporter", "importer", "=", "ExtensionImporter", "(", ")", "sys", ".", "meta_path", ".", "append", "(", "importer", ")" ]
Install the import hook to load extensions from the app Lib folder. Like imports but leaves it in the meta_path, thus it is slower.
[ "Install", "the", "import", "hook", "to", "load", "extensions", "from", "the", "app", "Lib", "folder", ".", "Like", "imports", "but", "leaves", "it", "in", "the", "meta_path", "thus", "it", "is", "slower", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/__init__.py#L30-L36
codelv/enaml-native
src/enamlnative/core/hotswap/openpy.py
source_from_cache
def source_from_cache(path): """Given the path to a .pyc. file, return the path to its .py file. The .pyc file does not need to exist; this simply returns the path to the .py file calculated to correspond to the .pyc file. If path does not conform to PEP 3147/488 format, ValueError will be raised. If ...
python
def source_from_cache(path): """Given the path to a .pyc. file, return the path to its .py file. The .pyc file does not need to exist; this simply returns the path to the .py file calculated to correspond to the .pyc file. If path does not conform to PEP 3147/488 format, ValueError will be raised. If ...
[ "def", "source_from_cache", "(", "path", ")", ":", "#if sys.implementation.cache_tag is None:", "# raise NotImplementedError('sys.implementation.cache_tag is None')", "#path = os.fspath(path)", "head", ",", "pycache_filename", "=", "os", ".", "path", ".", "split", "(", "path...
Given the path to a .pyc. file, return the path to its .py file. The .pyc file does not need to exist; this simply returns the path to the .py file calculated to correspond to the .pyc file. If path does not conform to PEP 3147/488 format, ValueError will be raised. If sys.implementation.cache_tag is N...
[ "Given", "the", "path", "to", "a", ".", "pyc", ".", "file", "return", "the", "path", "to", "its", ".", "py", "file", ".", "The", ".", "pyc", "file", "does", "not", "need", "to", "exist", ";", "this", "simply", "returns", "the", "path", "to", "the",...
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/hotswap/openpy.py#L11-L40
codelv/enaml-native
src/enamlnative/android/http.py
AndroidHttpRequest.init_request
def init_request(self): """ Init the native request using the okhttp3.Request.Builder """ #: Build the request builder = Request.Builder() builder.url(self.url) #: Set any headers for k, v in self.headers.items(): builder.addHeader(k, v) #: Get the ...
python
def init_request(self): """ Init the native request using the okhttp3.Request.Builder """ #: Build the request builder = Request.Builder() builder.url(self.url) #: Set any headers for k, v in self.headers.items(): builder.addHeader(k, v) #: Get the ...
[ "def", "init_request", "(", "self", ")", ":", "#: Build the request", "builder", "=", "Request", ".", "Builder", "(", ")", "builder", ".", "url", "(", "self", ".", "url", ")", "#: Set any headers", "for", "k", ",", "v", "in", "self", ".", "headers", ".",...
Init the native request using the okhttp3.Request.Builder
[ "Init", "the", "native", "request", "using", "the", "okhttp3", ".", "Request", ".", "Builder" ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/http.py#L140-L170
codelv/enaml-native
src/enamlnative/android/http.py
AndroidHttpRequest._default_body
def _default_body(self): """ If the body is not passed in by the user try to create one using the given data parameters. """ if not self.data: return "" if self.content_type == 'application/json': import json return json.dumps(self.data) ...
python
def _default_body(self): """ If the body is not passed in by the user try to create one using the given data parameters. """ if not self.data: return "" if self.content_type == 'application/json': import json return json.dumps(self.data) ...
[ "def", "_default_body", "(", "self", ")", ":", "if", "not", "self", ".", "data", ":", "return", "\"\"", "if", "self", ".", "content_type", "==", "'application/json'", ":", "import", "json", "return", "json", ".", "dumps", "(", "self", ".", "data", ")", ...
If the body is not passed in by the user try to create one using the given data parameters.
[ "If", "the", "body", "is", "not", "passed", "in", "by", "the", "user", "try", "to", "create", "one", "using", "the", "given", "data", "parameters", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/http.py#L188-L204
codelv/enaml-native
src/enamlnative/android/http.py
AndroidHttpRequest.on_finish
def on_finish(self): """ Called regardless of success or failure """ r = self.response r.request_time = time.time() - self.start_time if self.callback: self.callback(r)
python
def on_finish(self): """ Called regardless of success or failure """ r = self.response r.request_time = time.time() - self.start_time if self.callback: self.callback(r)
[ "def", "on_finish", "(", "self", ")", ":", "r", "=", "self", ".", "response", "r", ".", "request_time", "=", "time", ".", "time", "(", ")", "-", "self", ".", "start_time", "if", "self", ".", "callback", ":", "self", ".", "callback", "(", "r", ")" ]
Called regardless of success or failure
[ "Called", "regardless", "of", "success", "or", "failure" ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/http.py#L237-L242
codelv/enaml-native
src/enamlnative/android/http.py
AsyncHttpClient._fetch
def _fetch(self, request): """ Fetch using the OkHttpClient """ client = self.client #: Dispatch the async call call = Call(__id__=client.newCall(request.request)) call.enqueue(request.handler) #: Save the call reference request.call = call
python
def _fetch(self, request): """ Fetch using the OkHttpClient """ client = self.client #: Dispatch the async call call = Call(__id__=client.newCall(request.request)) call.enqueue(request.handler) #: Save the call reference request.call = call
[ "def", "_fetch", "(", "self", ",", "request", ")", ":", "client", "=", "self", ".", "client", "#: Dispatch the async call", "call", "=", "Call", "(", "__id__", "=", "client", ".", "newCall", "(", "request", ".", "request", ")", ")", "call", ".", "enqueue...
Fetch using the OkHttpClient
[ "Fetch", "using", "the", "OkHttpClient" ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/http.py#L276-L285
codelv/enaml-native
src/enamlnative/android/android_checkbox.py
AndroidCheckBox.create_widget
def create_widget(self): """ Create the underlying widget. """ d = self.declaration self.widget = CheckBox(self.get_context(), None, d.style or "@attr/checkboxStyle")
python
def create_widget(self): """ Create the underlying widget. """ d = self.declaration self.widget = CheckBox(self.get_context(), None, d.style or "@attr/checkboxStyle")
[ "def", "create_widget", "(", "self", ")", ":", "d", "=", "self", ".", "declaration", "self", ".", "widget", "=", "CheckBox", "(", "self", ".", "get_context", "(", ")", ",", "None", ",", "d", ".", "style", "or", "\"@attr/checkboxStyle\"", ")" ]
Create the underlying widget.
[ "Create", "the", "underlying", "widget", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_checkbox.py#L33-L39
codelv/enaml-native
src/enamlnative/core/http.py
AbstractAsyncHttpClient.fetch
def fetch(self, url, callback=None, raise_error=True, **kwargs): """ Fetch the given url and fire the callback when ready. Optionally pass a `streaming_callback` to handle data from large requests. Parameters ---------- url: string The url to access....
python
def fetch(self, url, callback=None, raise_error=True, **kwargs): """ Fetch the given url and fire the callback when ready. Optionally pass a `streaming_callback` to handle data from large requests. Parameters ---------- url: string The url to access....
[ "def", "fetch", "(", "self", ",", "url", ",", "callback", "=", "None", ",", "raise_error", "=", "True", ",", "*", "*", "kwargs", ")", ":", "app", "=", "BridgedApplication", ".", "instance", "(", ")", "f", "=", "app", ".", "create_future", "(", ")", ...
Fetch the given url and fire the callback when ready. Optionally pass a `streaming_callback` to handle data from large requests. Parameters ---------- url: string The url to access. callback: callable The callback to invoke when th...
[ "Fetch", "the", "given", "url", "and", "fire", "the", "callback", "when", "ready", ".", "Optionally", "pass", "a", "streaming_callback", "to", "handle", "data", "from", "large", "requests", ".", "Parameters", "----------", "url", ":", "string", "The", "url", ...
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/http.py#L144-L193
codelv/enaml-native
src/enamlnative/android/android_grid_layout.py
AndroidGridLayout.create_widget
def create_widget(self): """ Create the underlying widget. """ d = self.declaration self.widget = GridLayout(self.get_context(), None, d.style)
python
def create_widget(self): """ Create the underlying widget. """ d = self.declaration self.widget = GridLayout(self.get_context(), None, d.style)
[ "def", "create_widget", "(", "self", ")", ":", "d", "=", "self", ".", "declaration", "self", ".", "widget", "=", "GridLayout", "(", "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_grid_layout.py#L48-L53
codelv/enaml-native
src/enamlnative/android/android_switch.py
AndroidSwitch.create_widget
def create_widget(self): """ Create the underlying widget. """ d = self.declaration self.widget = Switch(self.get_context(), None, d.style or '@attr/switchStyle')
python
def create_widget(self): """ Create the underlying widget. """ d = self.declaration self.widget = Switch(self.get_context(), None, d.style or '@attr/switchStyle')
[ "def", "create_widget", "(", "self", ")", ":", "d", "=", "self", ".", "declaration", "self", ".", "widget", "=", "Switch", "(", "self", ".", "get_context", "(", ")", ",", "None", ",", "d", ".", "style", "or", "'@attr/switchStyle'", ")" ]
Create the underlying widget.
[ "Create", "the", "underlying", "widget", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_switch.py#L38-L44
codelv/enaml-native
src/enamlnative/android/android_switch.py
AndroidSwitch.init_widget
def init_widget(self): """ Initialize the underlying widget. """ super(AndroidSwitch, self).init_widget() d = self.declaration self.set_show_text(d.show_text) if d.split_track: self.set_split_track(d.split_track) if d.text_off: self.set_te...
python
def init_widget(self): """ Initialize the underlying widget. """ super(AndroidSwitch, self).init_widget() d = self.declaration self.set_show_text(d.show_text) if d.split_track: self.set_split_track(d.split_track) if d.text_off: self.set_te...
[ "def", "init_widget", "(", "self", ")", ":", "super", "(", "AndroidSwitch", ",", "self", ")", ".", "init_widget", "(", ")", "d", "=", "self", ".", "declaration", "self", ".", "set_show_text", "(", "d", ".", "show_text", ")", "if", "d", ".", "split_trac...
Initialize the underlying widget.
[ "Initialize", "the", "underlying", "widget", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_switch.py#L46-L58
codelv/enaml-native
src/enamlnative/core/app.py
Plugin.load
def load(self): """ Load the object defined by the plugin entry point """ print("[DEBUG] Loading plugin {} from {}".format(self.name, self.source)) import pydoc path, attr = self.source.split(":") module = pydoc.locate(path...
python
def load(self): """ Load the object defined by the plugin entry point """ print("[DEBUG] Loading plugin {} from {}".format(self.name, self.source)) import pydoc path, attr = self.source.split(":") module = pydoc.locate(path...
[ "def", "load", "(", "self", ")", ":", "print", "(", "\"[DEBUG] Loading plugin {} from {}\"", ".", "format", "(", "self", ".", "name", ",", "self", ".", "source", ")", ")", "import", "pydoc", "path", ",", "attr", "=", "self", ".", "source", ".", "split", ...
Load the object defined by the plugin entry point
[ "Load", "the", "object", "defined", "by", "the", "plugin", "entry", "point" ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/app.py#L34-L41
codelv/enaml-native
src/enamlnative/core/app.py
BridgedApplication._default_plugins
def _default_plugins(self): """ Get entry points to load any plugins installed. The build process should create an "entry_points.json" file with all of the data from the installed entry points. """ plugins = {} try: with open('entry_points.json') as ...
python
def _default_plugins(self): """ Get entry points to load any plugins installed. The build process should create an "entry_points.json" file with all of the data from the installed entry points. """ plugins = {} try: with open('entry_points.json') as ...
[ "def", "_default_plugins", "(", "self", ")", ":", "plugins", "=", "{", "}", "try", ":", "with", "open", "(", "'entry_points.json'", ")", "as", "f", ":", "entry_points", "=", "json", ".", "load", "(", "f", ")", "for", "ep", ",", "obj", "in", "entry_po...
Get entry points to load any plugins installed. The build process should create an "entry_points.json" file with all of the data from the installed entry points.
[ "Get", "entry", "points", "to", "load", "any", "plugins", "installed", ".", "The", "build", "process", "should", "create", "an", "entry_points", ".", "json", "file", "with", "all", "of", "the", "data", "from", "the", "installed", "entry", "points", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/app.py#L104-L120
codelv/enaml-native
src/enamlnative/core/app.py
BridgedApplication.start
def start(self): """ Start the application's main event loop using either twisted or tornado. """ #: Schedule a load view if given and remote debugging is not active #: the remote debugging init call this after dev connection is ready if self.load_view and self.d...
python
def start(self): """ Start the application's main event loop using either twisted or tornado. """ #: Schedule a load view if given and remote debugging is not active #: the remote debugging init call this after dev connection is ready if self.load_view and self.d...
[ "def", "start", "(", "self", ")", ":", "#: Schedule a load view if given and remote debugging is not active", "#: the remote debugging init call this after dev connection is ready", "if", "self", ".", "load_view", "and", "self", ".", "dev", "!=", "\"remote\"", ":", "self", "....
Start the application's main event loop using either twisted or tornado.
[ "Start", "the", "application", "s", "main", "event", "loop", "using", "either", "twisted", "or", "tornado", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/app.py#L140-L150
codelv/enaml-native
src/enamlnative/core/app.py
BridgedApplication.timed_call
def timed_call(self, ms, callback, *args, **kwargs): """ Invoke a callable on the main event loop thread at a specified time in the future. Parameters ---------- ms : int The time to delay, in milliseconds, before executing the callable. callback...
python
def timed_call(self, ms, callback, *args, **kwargs): """ Invoke a callable on the main event loop thread at a specified time in the future. Parameters ---------- ms : int The time to delay, in milliseconds, before executing the callable. callback...
[ "def", "timed_call", "(", "self", ",", "ms", ",", "callback", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "loop", ".", "timed_call", "(", "ms", ",", "callback", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
Invoke a callable on the main event loop thread at a specified time in the future. Parameters ---------- ms : int The time to delay, in milliseconds, before executing the callable. callback : callable The callable object to execute at some po...
[ "Invoke", "a", "callable", "on", "the", "main", "event", "loop", "thread", "at", "a", "specified", "time", "in", "the", "future", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/app.py#L174-L192
codelv/enaml-native
src/enamlnative/core/app.py
BridgedApplication.add_done_callback
def add_done_callback(self, future, callback): """ Add a callback on a future object put here so it can be implemented with different event loops. Parameters ----------- future: Future or Deferred Future implementation for the current EventLoop ...
python
def add_done_callback(self, future, callback): """ Add a callback on a future object put here so it can be implemented with different event loops. Parameters ----------- future: Future or Deferred Future implementation for the current EventLoop ...
[ "def", "add_done_callback", "(", "self", ",", "future", ",", "callback", ")", ":", "if", "future", "is", "None", ":", "raise", "bridge", ".", "BridgeReferenceError", "(", "\"Tried to add a callback to a nonexistent Future. \"", "\"Make sure you pass the `returns` argument t...
Add a callback on a future object put here so it can be implemented with different event loops. Parameters ----------- future: Future or Deferred Future implementation for the current EventLoop callback: callable Callback ...
[ "Add", "a", "callback", "on", "a", "future", "object", "put", "here", "so", "it", "can", "be", "implemented", "with", "different", "event", "loops", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/app.py#L236-L253
codelv/enaml-native
src/enamlnative/core/app.py
BridgedApplication.get_view
def get_view(self): """ Get the root view to display. Make sure it is properly initialized. """ view = self.view if not view.is_initialized: view.initialize() if not view.proxy_is_active: view.activate_proxy() return view.proxy.wid...
python
def get_view(self): """ Get the root view to display. Make sure it is properly initialized. """ view = self.view if not view.is_initialized: view.initialize() if not view.proxy_is_active: view.activate_proxy() return view.proxy.wid...
[ "def", "get_view", "(", "self", ")", ":", "view", "=", "self", ".", "view", "if", "not", "view", ".", "is_initialized", ":", "view", ".", "initialize", "(", ")", "if", "not", "view", ".", "proxy_is_active", ":", "view", ".", "activate_proxy", "(", ")",...
Get the root view to display. Make sure it is properly initialized.
[ "Get", "the", "root", "view", "to", "display", ".", "Make", "sure", "it", "is", "properly", "initialized", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/app.py#L278-L288
codelv/enaml-native
src/enamlnative/core/app.py
BridgedApplication.send_event
def send_event(self, name, *args, **kwargs): """ Send an event to the native handler. This call is queued and batched. Parameters ---------- name : str The event name to be processed by MainActivity.processMessages. *args: args The arguments requ...
python
def send_event(self, name, *args, **kwargs): """ Send an event to the native handler. This call is queued and batched. Parameters ---------- name : str The event name to be processed by MainActivity.processMessages. *args: args The arguments requ...
[ "def", "send_event", "(", "self", ",", "name", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "n", "=", "len", "(", "self", ".", "_bridge_queue", ")", "# Add to queue", "self", ".", "_bridge_queue", ".", "append", "(", "(", "name", ",", "args",...
Send an event to the native handler. This call is queued and batched. Parameters ---------- name : str The event name to be processed by MainActivity.processMessages. *args: args The arguments required by the event. **kwargs: kwargs O...
[ "Send", "an", "event", "to", "the", "native", "handler", ".", "This", "call", "is", "queued", "and", "batched", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/app.py#L296-L330
codelv/enaml-native
src/enamlnative/core/app.py
BridgedApplication._bridge_send
def _bridge_send(self, now=False): """ Send the events over the bridge to be processed by the native handler. Parameters ---------- now: boolean Send all pending events now instead of waiting for deferred calls to finish. Use this when you want to updat...
python
def _bridge_send(self, now=False): """ Send the events over the bridge to be processed by the native handler. Parameters ---------- now: boolean Send all pending events now instead of waiting for deferred calls to finish. Use this when you want to updat...
[ "def", "_bridge_send", "(", "self", ",", "now", "=", "False", ")", ":", "if", "len", "(", "self", ".", "_bridge_queue", ")", ":", "if", "self", ".", "debug", ":", "print", "(", "\"======== Py --> Native ======\"", ")", "for", "event", "in", "self", ".", ...
Send the events over the bridge to be processed by the native handler. Parameters ---------- now: boolean Send all pending events now instead of waiting for deferred calls to finish. Use this when you want to update the screen
[ "Send", "the", "events", "over", "the", "bridge", "to", "be", "processed", "by", "the", "native", "handler", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/app.py#L337-L355
codelv/enaml-native
src/enamlnative/core/app.py
BridgedApplication.process_events
def process_events(self, data): """ The native implementation must use this call to """ events = bridge.loads(data) if self.debug: print("======== Py <-- Native ======") for event in events: print(event) print("===========================") ...
python
def process_events(self, data): """ The native implementation must use this call to """ events = bridge.loads(data) if self.debug: print("======== Py <-- Native ======") for event in events: print(event) print("===========================") ...
[ "def", "process_events", "(", "self", ",", "data", ")", ":", "events", "=", "bridge", ".", "loads", "(", "data", ")", "if", "self", ".", "debug", ":", "print", "(", "\"======== Py <-- Native ======\"", ")", "for", "event", "in", "events", ":", "print", "...
The native implementation must use this call to
[ "The", "native", "implementation", "must", "use", "this", "call", "to" ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/app.py#L363-L373
codelv/enaml-native
src/enamlnative/core/app.py
BridgedApplication.handle_event
def handle_event(self, event): """ When we get an 'event' type from the bridge handle it by invoking the handler and if needed sending back the result. """ result_id, ptr, method, args = event[1] obj = None result = None try: obj, hand...
python
def handle_event(self, event): """ When we get an 'event' type from the bridge handle it by invoking the handler and if needed sending back the result. """ result_id, ptr, method, args = event[1] obj = None result = None try: obj, hand...
[ "def", "handle_event", "(", "self", ",", "event", ")", ":", "result_id", ",", "ptr", ",", "method", ",", "args", "=", "event", "[", "1", "]", "obj", "=", "None", "result", "=", "None", "try", ":", "obj", ",", "handler", "=", "bridge", ".", "get_han...
When we get an 'event' type from the bridge handle it by invoking the handler and if needed sending back the result.
[ "When", "we", "get", "an", "event", "type", "from", "the", "bridge", "handle", "it", "by", "invoking", "the", "handler", "and", "if", "needed", "sending", "back", "the", "result", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/app.py#L375-L411
codelv/enaml-native
src/enamlnative/core/app.py
BridgedApplication.handle_error
def handle_error(self, callback): """ Called when an error occurs in an event loop callback. By default, sets the error view. """ self.loop.log_error(callback) msg = "\n".join([ "Exception in callback %r"%callback, traceback.format_exc() ]...
python
def handle_error(self, callback): """ Called when an error occurs in an event loop callback. By default, sets the error view. """ self.loop.log_error(callback) msg = "\n".join([ "Exception in callback %r"%callback, traceback.format_exc() ]...
[ "def", "handle_error", "(", "self", ",", "callback", ")", ":", "self", ".", "loop", ".", "log_error", "(", "callback", ")", "msg", "=", "\"\\n\"", ".", "join", "(", "[", "\"Exception in callback %r\"", "%", "callback", ",", "traceback", ".", "format_exc", ...
Called when an error occurs in an event loop callback. By default, sets the error view.
[ "Called", "when", "an", "error", "occurs", "in", "an", "event", "loop", "callback", ".", "By", "default", "sets", "the", "error", "view", "." ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/app.py#L413-L423
codelv/enaml-native
src/enamlnative/core/app.py
BridgedApplication.start_dev_session
def start_dev_session(self): """ Start a client that attempts to connect to the dev server running on the host `app.dev` """ try: from .dev import DevServerSession session = DevServerSession.initialize(host=self.dev) session.start() ...
python
def start_dev_session(self): """ Start a client that attempts to connect to the dev server running on the host `app.dev` """ try: from .dev import DevServerSession session = DevServerSession.initialize(host=self.dev) session.start() ...
[ "def", "start_dev_session", "(", "self", ")", ":", "try", ":", "from", ".", "dev", "import", "DevServerSession", "session", "=", "DevServerSession", ".", "initialize", "(", "host", "=", "self", ".", "dev", ")", "session", ".", "start", "(", ")", "#: Save a...
Start a client that attempts to connect to the dev server running on the host `app.dev`
[ "Start", "a", "client", "that", "attempts", "to", "connect", "to", "the", "dev", "server", "running", "on", "the", "host", "app", ".", "dev" ]
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/app.py#L460-L473
codelv/enaml-native
src/enamlnative/core/app.py
BridgedApplication.load_plugin_widgets
def load_plugin_widgets(self): """ Pull widgets added via plugins using the `enaml_native_widgets` entry point. The entry point function must return a dictionary of Widget declarations to add to the core api. def install(): from charts.widgets.chart_view import BarChart, L...
python
def load_plugin_widgets(self): """ Pull widgets added via plugins using the `enaml_native_widgets` entry point. The entry point function must return a dictionary of Widget declarations to add to the core api. def install(): from charts.widgets.chart_view import BarChart, L...
[ "def", "load_plugin_widgets", "(", "self", ")", ":", "from", "enamlnative", ".", "widgets", "import", "api", "for", "plugin", "in", "self", ".", "get_plugins", "(", "group", "=", "'enaml_native_widgets'", ")", ":", "get_widgets", "=", "plugin", ".", "load", ...
Pull widgets added via plugins using the `enaml_native_widgets` entry point. The entry point function must return a dictionary of Widget declarations to add to the core api. def install(): from charts.widgets.chart_view import BarChart, LineChart return { ...
[ "Pull", "widgets", "added", "via", "plugins", "using", "the", "enaml_native_widgets", "entry", "point", ".", "The", "entry", "point", "function", "must", "return", "a", "dictionary", "of", "Widget", "declarations", "to", "add", "to", "the", "core", "api", "." ...
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/app.py#L485-L503
codelv/enaml-native
src/enamlnative/android/android_content.py
BroadcastReceiver.for_action
def for_action(cls, action, callback, single_shot=True): """ Create a BroadcastReceiver that is invoked when the given action is received. Parameters ---------- action: String Action to receive callback: Callable Callback to invoke when t...
python
def for_action(cls, action, callback, single_shot=True): """ Create a BroadcastReceiver that is invoked when the given action is received. Parameters ---------- action: String Action to receive callback: Callable Callback to invoke when t...
[ "def", "for_action", "(", "cls", ",", "action", ",", "callback", ",", "single_shot", "=", "True", ")", ":", "receiver", "=", "cls", "(", ")", "activity", "=", "receiver", ".", "__app__", ".", "widget", "receiver", ".", "setReceiver", "(", "receiver", "."...
Create a BroadcastReceiver that is invoked when the given action is received. Parameters ---------- action: String Action to receive callback: Callable Callback to invoke when the action is received single_shot: Bool Cleanup a...
[ "Create", "a", "BroadcastReceiver", "that", "is", "invoked", "when", "the", "given", "action", "is", "received", ".", "Parameters", "----------", "action", ":", "String", "Action", "to", "receive", "callback", ":", "Callable", "Callback", "to", "invoke", "when",...
train
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_content.py#L198-L227
openxc/openxc-python
openxc/vehicle.py
Vehicle.get
def get(self, measurement_class): """Return the latest measurement for the given class or None if nothing has been received from the vehicle. """ name = Measurement.name_from_class(measurement_class) return self._construct_measurement(name)
python
def get(self, measurement_class): """Return the latest measurement for the given class or None if nothing has been received from the vehicle. """ name = Measurement.name_from_class(measurement_class) return self._construct_measurement(name)
[ "def", "get", "(", "self", ",", "measurement_class", ")", ":", "name", "=", "Measurement", ".", "name_from_class", "(", "measurement_class", ")", "return", "self", ".", "_construct_measurement", "(", "name", ")" ]
Return the latest measurement for the given class or None if nothing has been received from the vehicle.
[ "Return", "the", "latest", "measurement", "for", "the", "given", "class", "or", "None", "if", "nothing", "has", "been", "received", "from", "the", "vehicle", "." ]
train
https://github.com/openxc/openxc-python/blob/4becb4a6310bd658c125195ef6ffea4deaf7d7e7/openxc/vehicle.py#L39-L44
openxc/openxc-python
openxc/vehicle.py
Vehicle.add_source
def add_source(self, source): """Add a vehicle data source to the instance. The Vehicle instance will be set as the callback of the source, and the source will be started if it is startable. (i.e. it has a ``start()`` method). """ if source is not None: self....
python
def add_source(self, source): """Add a vehicle data source to the instance. The Vehicle instance will be set as the callback of the source, and the source will be started if it is startable. (i.e. it has a ``start()`` method). """ if source is not None: self....
[ "def", "add_source", "(", "self", ",", "source", ")", ":", "if", "source", "is", "not", "None", ":", "self", ".", "sources", ".", "add", "(", "source", ")", "source", ".", "callback", "=", "self", ".", "_receive", "if", "hasattr", "(", "source", ",",...
Add a vehicle data source to the instance. The Vehicle instance will be set as the callback of the source, and the source will be started if it is startable. (i.e. it has a ``start()`` method).
[ "Add", "a", "vehicle", "data", "source", "to", "the", "instance", "." ]
train
https://github.com/openxc/openxc-python/blob/4becb4a6310bd658c125195ef6ffea4deaf7d7e7/openxc/vehicle.py#L65-L76
openxc/openxc-python
openxc/vehicle.py
Vehicle.add_sink
def add_sink(self, sink): """Add a vehicle data sink to the instance. ``sink`` should be a sub-class of ``DataSink`` or at least have a ``receive(message, **kwargs)`` method. The sink will be started if it is startable. (i.e. it has a ``start()`` method). """ if ...
python
def add_sink(self, sink): """Add a vehicle data sink to the instance. ``sink`` should be a sub-class of ``DataSink`` or at least have a ``receive(message, **kwargs)`` method. The sink will be started if it is startable. (i.e. it has a ``start()`` method). """ if ...
[ "def", "add_sink", "(", "self", ",", "sink", ")", ":", "if", "sink", "is", "not", "None", ":", "self", ".", "sinks", ".", "add", "(", "sink", ")", "if", "hasattr", "(", "sink", ",", "'start'", ")", ":", "sink", ".", "start", "(", ")" ]
Add a vehicle data sink to the instance. ``sink`` should be a sub-class of ``DataSink`` or at least have a ``receive(message, **kwargs)`` method. The sink will be started if it is startable. (i.e. it has a ``start()`` method).
[ "Add", "a", "vehicle", "data", "sink", "to", "the", "instance", ".", "sink", "should", "be", "a", "sub", "-", "class", "of", "DataSink", "or", "at", "least", "have", "a", "receive", "(", "message", "**", "kwargs", ")", "method", "." ]
train
https://github.com/openxc/openxc-python/blob/4becb4a6310bd658c125195ef6ffea4deaf7d7e7/openxc/vehicle.py#L78-L89
openxc/openxc-python
openxc/sinks/notifier.py
MeasurementNotifierSink.register
def register(self, measurement_class, callback): """Call the ``callback`` with any new values of ``measurement_class`` received. """ self.callbacks[Measurement.name_from_class(measurement_class) ].add(callback)
python
def register(self, measurement_class, callback): """Call the ``callback`` with any new values of ``measurement_class`` received. """ self.callbacks[Measurement.name_from_class(measurement_class) ].add(callback)
[ "def", "register", "(", "self", ",", "measurement_class", ",", "callback", ")", ":", "self", ".", "callbacks", "[", "Measurement", ".", "name_from_class", "(", "measurement_class", ")", "]", ".", "add", "(", "callback", ")" ]
Call the ``callback`` with any new values of ``measurement_class`` received.
[ "Call", "the", "callback", "with", "any", "new", "values", "of", "measurement_class", "received", "." ]
train
https://github.com/openxc/openxc-python/blob/4becb4a6310bd658c125195ef6ffea4deaf7d7e7/openxc/sinks/notifier.py#L26-L31
openxc/openxc-python
openxc/sinks/notifier.py
MeasurementNotifierSink.unregister
def unregister(self, measurement_class, callback): """Stop notifying ``callback`` of new values of ``measurement_class``. If the callback wasn't previously registered, this method will have no effect. """ self.callbacks[Measurement.name_from_class(measurement_class) ...
python
def unregister(self, measurement_class, callback): """Stop notifying ``callback`` of new values of ``measurement_class``. If the callback wasn't previously registered, this method will have no effect. """ self.callbacks[Measurement.name_from_class(measurement_class) ...
[ "def", "unregister", "(", "self", ",", "measurement_class", ",", "callback", ")", ":", "self", ".", "callbacks", "[", "Measurement", ".", "name_from_class", "(", "measurement_class", ")", "]", ".", "remove", "(", "callback", ")" ]
Stop notifying ``callback`` of new values of ``measurement_class``. If the callback wasn't previously registered, this method will have no effect.
[ "Stop", "notifying", "callback", "of", "new", "values", "of", "measurement_class", "." ]
train
https://github.com/openxc/openxc-python/blob/4becb4a6310bd658c125195ef6ffea4deaf7d7e7/openxc/sinks/notifier.py#L33-L40
openxc/openxc-python
openxc/controllers/usb.py
UsbControllerMixin._send_complex_request
def _send_complex_request(self, request): """Send a request via the USB control request endpoint, rather than as a bulk transfer. """ self.device.ctrl_transfer(0x40, self.COMPLEX_CONTROL_COMMAND, 0, 0, self.streamer.serialize_for_stream(request))
python
def _send_complex_request(self, request): """Send a request via the USB control request endpoint, rather than as a bulk transfer. """ self.device.ctrl_transfer(0x40, self.COMPLEX_CONTROL_COMMAND, 0, 0, self.streamer.serialize_for_stream(request))
[ "def", "_send_complex_request", "(", "self", ",", "request", ")", ":", "self", ".", "device", ".", "ctrl_transfer", "(", "0x40", ",", "self", ".", "COMPLEX_CONTROL_COMMAND", ",", "0", ",", "0", ",", "self", ".", "streamer", ".", "serialize_for_stream", "(", ...
Send a request via the USB control request endpoint, rather than as a bulk transfer.
[ "Send", "a", "request", "via", "the", "USB", "control", "request", "endpoint", "rather", "than", "as", "a", "bulk", "transfer", "." ]
train
https://github.com/openxc/openxc-python/blob/4becb4a6310bd658c125195ef6ffea4deaf7d7e7/openxc/controllers/usb.py#L32-L37
openxc/openxc-python
openxc/controllers/usb.py
UsbControllerMixin.out_endpoint
def out_endpoint(self): """Open a reference to the USB device's only OUT endpoint. This method assumes that the USB device configuration has already been set. """ if getattr(self, '_out_endpoint', None) is None: config = self.device.get_active_configuration() inte...
python
def out_endpoint(self): """Open a reference to the USB device's only OUT endpoint. This method assumes that the USB device configuration has already been set. """ if getattr(self, '_out_endpoint', None) is None: config = self.device.get_active_configuration() inte...
[ "def", "out_endpoint", "(", "self", ")", ":", "if", "getattr", "(", "self", ",", "'_out_endpoint'", ",", "None", ")", "is", "None", ":", "config", "=", "self", ".", "device", ".", "get_active_configuration", "(", ")", "interface_number", "=", "config", "["...
Open a reference to the USB device's only OUT endpoint. This method assumes that the USB device configuration has already been set.
[ "Open", "a", "reference", "to", "the", "USB", "device", "s", "only", "OUT", "endpoint", ".", "This", "method", "assumes", "that", "the", "USB", "device", "configuration", "has", "already", "been", "set", "." ]
train
https://github.com/openxc/openxc-python/blob/4becb4a6310bd658c125195ef6ffea4deaf7d7e7/openxc/controllers/usb.py#L40-L59
openxc/openxc-python
openxc/controllers/base.py
ResponseReceiver.wait_for_responses
def wait_for_responses(self): """Block the thread and wait for the response to the given request to arrive from the VI. If no matching response is received in COMMAND_RESPONSE_TIMEOUT_S seconds, returns anyway. """ self.thread.join(self.COMMAND_RESPONSE_TIMEOUT_S) self.r...
python
def wait_for_responses(self): """Block the thread and wait for the response to the given request to arrive from the VI. If no matching response is received in COMMAND_RESPONSE_TIMEOUT_S seconds, returns anyway. """ self.thread.join(self.COMMAND_RESPONSE_TIMEOUT_S) self.r...
[ "def", "wait_for_responses", "(", "self", ")", ":", "self", ".", "thread", ".", "join", "(", "self", ".", "COMMAND_RESPONSE_TIMEOUT_S", ")", "self", ".", "running", "=", "False", "return", "self", ".", "responses" ]
Block the thread and wait for the response to the given request to arrive from the VI. If no matching response is received in COMMAND_RESPONSE_TIMEOUT_S seconds, returns anyway.
[ "Block", "the", "thread", "and", "wait", "for", "the", "response", "to", "the", "given", "request", "to", "arrive", "from", "the", "VI", ".", "If", "no", "matching", "response", "is", "received", "in", "COMMAND_RESPONSE_TIMEOUT_S", "seconds", "returns", "anywa...
train
https://github.com/openxc/openxc-python/blob/4becb4a6310bd658c125195ef6ffea4deaf7d7e7/openxc/controllers/base.py#L56-L65